]> git.k1024.org Git - pyxattr.git/blob - Makefile
CI: Bump cache key version
[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.2
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 3.9
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 dist:
29         fakeroot $(PYTHON) ./setup.py sdist
30
31 distcheck: dist
32         set -e; \
33         TDIR=$$(mktemp -d) && \
34         trap "rm -rf $$TDIR" EXIT; \
35         tar xzf dist/$(DISTFILE) -C $$TDIR && \
36         (cd $$TDIR/$(FULLVER) && make doc && make test && make dist) && \
37         echo "All good, you can upload $(DISTFILE)!"
38
39 test:
40         @for ver in $(PYVERS); do \
41           for flavour in "" "-dbg"; do \
42             if type python$$ver$$flavour >/dev/null; then \
43               echo Testing with python$$ver$$flavour; \
44               python$$ver$$flavour setup.py build_ext -i; \
45               python$$ver$$flavour -m pytest tests; \
46             fi; \
47           done; \
48         done;
49         @if type pypy3 >/dev/null; then \
50           echo Testing with pypy3; \
51           pypy3 setup.py build_ext -i; \
52           pypy3 -m pytest tests; \
53         fi
54
55 fast-test:
56         python3 setup.py build_ext -i
57         python3 -m pytest tests -v
58
59 benchmark: $(MODNAME)
60         @set -e; \
61         TESTFILE=`mktemp`;\
62         trap 'rm $$TESTFILE' EXIT; \
63         for ver in $(PYVERS) ; do \
64             if type python$$ver >/dev/null; then \
65               echo Benchmarking with python$$ver; \
66               python$$ver ./setup.py build -q; \
67               echo "  - set (with override)"; \
68               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello')"; \
69               echo "  - list"; \
70               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.list('$$TESTFILE')"; \
71               echo "  - get"; \
72               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.get('$$TESTFILE', 'user.comment')"; \
73               echo "  - set + remove"; \
74               python$$ver -m timeit -r $(REPS) -s 'import xattr' "xattr.set('$$TESTFILE', 'user.comment', 'hello'); xattr.remove('$$TESTFILE', 'user.comment')"; \
75             fi; \
76         done;
77
78 coverage:
79         $(MAKE) clean
80         $(MAKE) test CFLAGS="-coverage"
81         lcov --capture --directory . --no-external --output-file coverage.info
82         genhtml coverage.info --output-directory out
83
84 clean:
85         rm -rf $(DOCHTML) $(DOCTREES)
86         rm -f $(MODNAME)
87         rm -f *.so
88         rm -rf build
89
90 .PHONY: doc test fast-test clean dist distcheck coverage