]> git.k1024.org Git - pyxattr.git/blob - Makefile
Switch build system to Python 3
[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
9 MODNAME = xattr.so
10 RSTFILES = doc/index.rst doc/module.rst NEWS README.rst doc/conf.py
11 PYVERS = 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7
12 REPS = 5
13
14 all: doc test
15
16 $(MODNAME): xattr.c
17         $(PYTHON) ./setup.py build_ext --inplace
18
19 $(DOCHTML)/index.html: $(MODNAME) $(RSTFILES)
20         $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(DOCHTML)
21         touch $@
22
23 doc: $(DOCHTML)/index.html
24
25 dist:
26         fakeroot $(PYTHON) ./setup.py sdist
27
28 test:
29         @for ver in $(PYVERS); do \
30           for flavour in "" "-dbg"; do \
31             if type python$$ver$$flavour >/dev/null; then \
32               echo Testing with python$$ver$$flavour; \
33               python$$ver$$flavour ./setup.py test -q; \
34             fi; \
35           done; \
36         done;
37         @if type pypy >/dev/null; then \
38           echo Testing with pypy; \
39           pypy ./setup.py test -q; \
40         fi
41
42 benchmark: $(MODNAME)
43         @set -e; \
44         TESTFILE=`mktemp`;\
45         trap 'rm $$TESTFILE' EXIT; \
46         for ver in $(PYVERS) ; do \
47             if type python$$ver >/dev/null; then \
48               echo Benchmarking with python$$ver; \
49               python$$ver ./setup.py build -q; \
50               echo "  - set (with override)"; \
51               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello')"; \
52               echo "  - list"; \
53               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.list('$$TESTFILE')"; \
54               echo "  - get"; \
55               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.get('$$TESTFILE', 'user.comment')"; \
56               echo "  - set + remove"; \
57               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello'); xattr.remove('$$TESTFILE', 'user.comment')"; \
58             fi; \
59         done;
60
61 coverage:
62         $(MAKE) clean
63         $(MAKE) test CFLAGS="-coverage"
64         lcov --capture --directory . --output-file coverage.info
65         genhtml coverage.info --output-directory out
66
67 clean:
68         rm -rf $(DOCHTML) $(DOCTREES)
69         rm -f $(MODNAME)
70         rm -f *.so
71         rm -rf build
72
73 .PHONY: doc test clean dist coverage