-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
123 lines (88 loc) · 4.02 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
.PHONY: help clean clean-build clean-pyc clean-test clean-venv flake8-check pylint-check test test37 test38 test39 test310 test311 docs docs-pdf clean-docs black-check black isort-check isort coverage test-upload upload release release-help dist dist-check
.DEFAULT_GOAL := help
TOXOPTIONS ?=
TOXINI ?= tox.ini
TOX = tox -c $(TOXINI) $(TOXOPTIONS)
ARGS ?=
# empty TESTS delegates to TOXINI
TESTS ?=
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-z0-9A-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
help: ## show this help
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
bootstrap: ## verify that tox is available and pre-commit hooks are active
python scripts/bootstrap.py
clean: ## remove all build, docs, test, and coverage artifacts, as well as tox environments
python scripts/clean.py all
clean-build: ## remove build artifacts
python scripts/clean.py build
clean-tests: ## remove test and coverage artifacts
python scripts/clean.py tests
clean-venv: ## remove tox virtual environments
python scripts/clean.py venv
clean-docs: ## remove documentation artifacts
python scripts/clean.py docs
flake8-check: bootstrap ## check style with flake8
$(TOX) -e run-flake8
pylint-check: bootstrap ## check style with pylint
$(TOX) -e run-pylint
test: bootstrap ## run tests for all supported Python versions
$(TOX) -e py37-test,py38-test,py39-test,py310-test,py311-test -- $(TESTS)
test37: bootstrap ## run tests for Python 3.7
$(TOX) -e py37-test -- $(TESTS)
test38: bootstrap ## run tests for Python 3.8
$(TOX) -e py38-test -- $(TESTS)
test39: bootstrap ## run tests for Python 3.9
$(TOX) -e py39-test -- $(TESTS)
test310: bootstrap ## run tests for Python 3.10
$(TOX) -e py310-test -- $(TESTS)
test311: bootstrap ## run tests for Python 3.11
$(TOX) -e py311-test -- $(TESTS)
docs: bootstrap ## generate Sphinx HTML documentation, including API docs
$(TOX) -e docs
@echo "open docs/_build/html/index.html"
docs-pdf: bootstrap ## generate Sphinx PDF documentation, via latex
$(TOX) -e docs -- -b latex _build/latex
$(TOX) -e run-cmd -- python docs/build_pdf.py docs/_build/latex/*.tex
black-check: bootstrap ## Check all src and test files for complience to "black" code style
$(TOX) -e run-blackcheck
black: bootstrap ## Apply 'black' code style to all src and test files
$(TOX) -e run-black
isort-check: bootstrap ## Check all src and test files for correctly sorted imports
$(TOX) -e run-isortcheck
isort: bootstrap ## Sort imports in all src and test files
$(TOX) -e run-isort
coverage: test310 ## generate coverage report in ./htmlcov
$(TOX) -e coverage
@echo "open htmlcov/index.html"
test-upload: bootstrap clean-build dist ## package and upload a release to test.pypi.org
$(TOX) -e run-cmd -- twine check dist/*
$(TOX) -e run-cmd -- twine upload --repository-url https://test.pypi.org/legacy/ dist/*
upload: bootstrap clean-build dist ## package and upload a release to pypi.org
$(TOX) -e run-cmd -- twine check dist/*
$(TOX) -e run-cmd -- twine upload dist/*
release: clean bootstrap ## Create a new version, package and upload it
python3.10 -m venv .venv/release
.venv/release/bin/python -m pip install click
.venv/release/bin/python ./scripts/release.py $(ARGS)
release-help: bootstrap ## Show help on the release script
python3.10 -m venv .venv/release
.venv/release/bin/python -m pip install click
.venv/release/bin/python ./scripts/release.py --help
dist: bootstrap ## builds source and wheel package
$(TOX) -e run-cmd -- python setup.py sdist
$(TOX) -e run-cmd -- python setup.py bdist_wheel
ls -l dist
dist-check: bootstrap ## Check all dist files for correctness
$(TOX) -e run-cmd -- twine check dist/*
# How to execute notebook files
%.ipynb.log: %.ipynb
@echo ""
$(TOX) -e run-cmd -- jupyter nbconvert --to notebook --execute --inplace --allow-errors --ExecutePreprocessor.kernel_name='python3' --ExecutePreprocessor.timeout=-1 --config=/dev/null $< 2>&1 | tee $@