]> git.k1024.org Git - pyxattr.git/blob - Makefile
Fix travis config after tests rename
[pyxattr.git] / Makefile
1 PYTHON        = python3
2 SPHINXOPTS    = -W
3 SPHINXBUILD   = $(PYTHON) -m sphinx
4 DOCDIR        = doc
5 DOCHTML       = $(DOCDIR)/html
6 DOCTREES      = $(DOCDIR)/doctrees
7 ALLSPHINXOPTS = -d $(DOCTREES) $(SPHINXOPTS) $(DOCDIR)
8 VERSION       = 0.7.1
9 FULLVER       = pyxattr-$(VERSION)
10 DISTFILE      = $(FULLVER).tar.gz
11
12 MODNAME = xattr.so
13 RSTFILES = doc/index.rst doc/module.rst doc/news.rst doc/readme.md doc/conf.py
14 PYVERS = 3.4 3.5 3.6 3.7 3.8
15 REPS = 5
16
17 all: doc test
18
19 $(MODNAME): xattr.c
20         $(PYTHON) ./setup.py build_ext --inplace
21
22 $(DOCHTML)/index.html: $(MODNAME) $(RSTFILES)
23         $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCHTML)
24         touch $@
25
26 doc: $(DOCHTML)/index.html
27
28 doc/readme.md: README.md
29         ln -s ../README.md doc/readme.md
30
31 doc/news.rst: NEWS
32         ln -s ../NEWS doc/news.rst
33
34 dist:
35         fakeroot $(PYTHON) ./setup.py sdist
36
37 distcheck: dist
38         set -e; \
39         TDIR=$$(mktemp -d) && \
40         trap "rm -rf $$TDIR" EXIT; \
41         tar xzf dist/$(DISTFILE) -C $$TDIR && \
42         (cd $$TDIR/$(FULLVER) && make doc && make test && make dist) && \
43         echo "All good, you can upload $(DISTFILE)!"
44
45 test:
46         @for ver in $(PYVERS); do \
47           for flavour in "" "-dbg"; do \
48             if type python$$ver$$flavour >/dev/null; then \
49               echo Testing with python$$ver$$flavour; \
50               python$$ver$$flavour setup.py build_ext -i; \
51               python$$ver$$flavour -m pytest tests; \
52             fi; \
53           done; \
54         done;
55         @if type pypy3 >/dev/null; then \
56           echo Testing with pypy3; \
57           pypy3 setup.py build_ext -i; \
58           pypy3 -m pytest tests; \
59         fi
60
61 fast-test:
62         python3 setup.py build_ext -i
63         python3 -m pytest tests -v
64
65 benchmark: $(MODNAME)
66         @set -e; \
67         TESTFILE=`mktemp`;\
68         trap 'rm $$TESTFILE' EXIT; \
69         for ver in $(PYVERS) ; do \
70             if type python$$ver >/dev/null; then \
71               echo Benchmarking with python$$ver; \
72               python$$ver ./setup.py build -q; \
73               echo "  - set (with override)"; \
74               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello')"; \
75               echo "  - list"; \
76               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.list('$$TESTFILE')"; \
77               echo "  - get"; \
78               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.get('$$TESTFILE', 'user.comment')"; \
79               echo "  - set + remove"; \
80               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello'); xattr.remove('$$TESTFILE', 'user.comment')"; \
81             fi; \
82         done;
83
84 coverage:
85         $(MAKE) clean
86         $(MAKE) test CFLAGS="-coverage"
87         lcov --capture --directory . --no-external --output-file coverage.info
88         genhtml coverage.info --output-directory out
89
90 clean:
91         rm -rf $(DOCHTML) $(DOCTREES)
92         rm -f doc/readme.md doc/news.rst
93         rm -f $(MODNAME)
94         rm -f *.so
95         rm -rf build
96
97 .PHONY: doc test fast-test clean dist distcheck coverage