-
Notifications
You must be signed in to change notification settings - Fork 39
/
Makefile
99 lines (71 loc) · 2.65 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
VENV_DOCS_PATH = .venv-docs
VENV_DEV_PATH = .venv-dev
VENV_PYTHON = $(firstword $(shell which python3.9 python3.8 python3.7 python3 2> /dev/null))
VENV_COMMON_DEPS = setup.py setup.cfg requirements.txt
VENV_DEV_DEPS = $(VENV_COMMON_DEPS) docs/examples/requirements.txt
VENV_DOCS_DEPS = $(VENV_COMMON_DEPS) docs/requirements.txt
PY_DIRS = testsuite
PACKAGE_VERSION = $(shell awk '/^version = /{print $$3}' setup.cfg)
TESTSUITE_GH_PAGES_REPO = /tmp/$(USER)/testsuite-gh-pages.git
.PHONY: tests
tests:
python3 -m pytest -v tests/ $(PYTEST_ARGS)
test-examples:
make -C docs/examples runtests
linters:
# stop the build if there are Python syntax errors or undefined names
flake8 $(PY_DIRS) --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 $(PY_DIRS) --count --exit-zero --max-complexity=10 --max-line-length=79 --statistics
check-black:
black --check --diff .
black:
black .
venv-linters:
venv-tests:
venv-check-black:
venv-black:
venv-start-release:
venv-release-upload-testpypi:
venv-release-upload-pypi:
venv-%: setup-dev-venv
(. $(VENV_DEV_PATH)/bin/activate && $(MAKE) $*)
setup-dev-venv: $(VENV_DEV_PATH)/.timestamp
$(VENV_DEV_PATH)/.timestamp: $(VENV_DEV_DEPS)
test -x $(VENV_DEV_PATH)/bin/python || \
virtualenv --python=$(VENV_PYTHON) $(VENV_DEV_PATH)
$(VENV_DEV_PATH)/bin/pip install -r requirements.txt
$(VENV_DEV_PATH)/bin/pip install -r docs/examples/requirements.txt
touch $@
setup-docs-venv: $(VENV_DOCS_PATH)/.timestamp
build-docs: build-docs-html
build-docs-%: setup-docs-venv
(. $(VENV_DOCS_PATH)/bin/activate && PYTHONPATH="$$PYTHONPATH:$(PWD)" \
$(MAKE) -C docs $*)
$(VENV_DOCS_PATH)/.timestamp: $(VENV_DOCS_DEPS)
test -x $(VENV_DOCS_PATH)/bin/python || \
virtualenv --python=$(VENV_PYTHON) $(VENV_DOCS_PATH)
$(VENV_DOCS_PATH)/bin/pip install -r requirements.txt
$(VENV_DOCS_PATH)/bin/pip install -r docs/requirements.txt
touch $@
start-release:
./tools/release.sh
release-upload-testpypi:
$(MAKE) release-upload-testpypi-$(PACKAGE_VERSION)
release-upload-pypi:
$(MAKE) release-upload-pypi-$(PACKAGE_VERSION)
release-upload-pypi-%: dist/%/.timestamp
python3 -m twine upload --repository pypi dist/$*/*
release-upload-testpypi-%: dist/%/.timestamp
python3 -m twine upload --repository testpypi dist/$*/*
build-package-%: dist/%/.timestamp
@echo "Package version $*"
.PRECIOUS: dist/%/.timestamp
dist/%/.timestamp:
rm -rf $@
python3 -m build -o dist/$*
touch $@
publish-gh-pages: build-docs-dirhtml
./tools/publish-gh-repo.sh $(TESTSUITE_GH_PAGES_REPO) $(PACKAGE_VERSION)
clean:
rm -rf dist $(VENV_DEV_PATH) $(VENV_DOCS_PATH) docs/_build