Debian Codegraph @

Makefile

raw
1 PACKAGE=semantic_version
2 TESTS_DIR=tests
3 DOC_DIR=docs
4
5 # Use current python binary instead of system default.
6 COVERAGE = python $(shell which coverage)
7 FLAKE8 = flake8
8
9 all: default
10
11
12 default:
13
14 .PHONY: all default
15
16
17 # Package management
18 # ==================
19
20
21 clean:
22 find . -type f -name '*.pyc' -delete
23 find . -type f -path '*/__pycache__/*' -delete
24 find . -type d -empty -delete
25 @rm -rf tmp_test/
26
27
28 update:
29 pip install --upgrade pip setuptools
30 pip install --upgrade -e .[dev,doc]
31 pip freeze
32
33
34 release:
35 fullrelease
36
37 .PHONY: clean update release
38
39 # Tests and quality
40 # =================
41
42
43 # DOC: Run tests for all supported versions (creates a set of virtualenvs)
44 testall:
45 tox
46
47
48 # DOC: Run tests for the currently installed version
49 test:
50 python -Wdefault -m nose2
51
52 # DOC: Perform code quality tasks
53 lint: check-manifest flake8
54
55 # DOC: Verify that MANIFEST.in and .gitignore are consistent
56 check-manifest:
57 check-manifest
58
59 # Note: we run the linter in two runs, because our __init__.py files has specific warnings we want to exclude
60 # DOC: Verify code quality
61 flake8:
62 $(FLAKE8) --exclude $(PACKAGE)/__init__.py $(PACKAGE) $(TESTS_DIR) setup.py
63 $(FLAKE8) --ignore F401 $(PACKAGE)/__init__.py
64
65 # DOC: Run tests with coverage collection
66 coverage:
67 $(COVERAGE) erase
68 $(COVERAGE) run "--include=$(PACKAGE)/*.py,$(TESTS_DIR)/*.py" --branch setup.py test
69 $(COVERAGE) report "--include=$(PACKAGE)/*.py,$(TESTS_DIR)/*.py"
70 $(COVERAGE) html "--include=$(PACKAGE)/*.py,$(TESTS_DIR)/*.py"
71
72 .PHONY: testall test lint check-manifest flake8 coverage
73
74
75 # Documentation
76 # =============
77
78
79 # DOC: Compile the documentation
80 doc:
81 $(MAKE) -C $(DOC_DIR) html
82
83
84 # DOC: Show this help message
85 help:
86 @grep -A1 '^# DOC:' Makefile \
87 | awk ' \
88 BEGIN { FS="\n"; RS="--\n"; opt_len=0; } \
89 { \
90 doc=$$1; name=$$2; \
91 sub("# DOC: ", "", doc); \
92 sub(":", "", name); \
93 if (length(name) > opt_len) { \
94 opt_len = length(name) \
95 } \
96 opts[NR] = name; \
97 docs[name] = doc; \
98 } \
99 END { \
100 pat="%-" (opt_len + 4) "s %s\n"; \
101 asort(opts); \
102 for (i in opts) { \
103 opt=opts[i]; \
104 printf pat, opt, docs[opt] \
105 } \
106 }'
107
108 .PHONY: doc help