]> git.k1024.org Git - pyxattr.git/blob - Makefile
Introduce an any_subject fixture which includes symlinks
[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.6.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 test; \
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 test; \
59         fi
60
61 benchmark: $(MODNAME)
62         @set -e; \
63         TESTFILE=`mktemp`;\
64         trap 'rm $$TESTFILE' EXIT; \
65         for ver in $(PYVERS) ; do \
66             if type python$$ver >/dev/null; then \
67               echo Benchmarking with python$$ver; \
68               python$$ver ./setup.py build -q; \
69               echo "  - set (with override)"; \
70               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello')"; \
71               echo "  - list"; \
72               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.list('$$TESTFILE')"; \
73               echo "  - get"; \
74               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.get('$$TESTFILE', 'user.comment')"; \
75               echo "  - set + remove"; \
76               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello'); xattr.remove('$$TESTFILE', 'user.comment')"; \
77             fi; \
78         done;
79
80 coverage:
81         $(MAKE) clean
82         $(MAKE) test CFLAGS="-coverage"
83         lcov --capture --directory . --no-external --output-file coverage.info
84         genhtml coverage.info --output-directory out
85
86 clean:
87         rm -rf $(DOCHTML) $(DOCTREES)
88         rm -f doc/readme.md doc/news.rst
89         rm -f $(MODNAME)
90         rm -f *.so
91         rm -rf build
92
93 .PHONY: doc test clean dist distcheck coverage