-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
146 lines (115 loc) · 3.09 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# You can set these variables from the command line.
DOCS_DIR = docs
SPHINXBUILD = sphinx-build
GRAPHVIZ_DOT = dot
PACKAGE_NAME = wax
IPYKERNEL_NAME = python3
# Always rebuild these targets
.PHONY: all
.PHONY: help
help:
@echo "Usage: make <target>"
@echo
@echo " act Run actions: flake8, mypy, tests"
@echo " flake8 Run the flake8."
@echo " format Format python files with autofloke, isort and black."
@echo " tests Run the tests."
@echo " coverage Generate a coverage report for unit tests."
@echo " docs Build the documentation in the docs/_build/html/ directory."
@echo " clean Remove documentation build, coverage and Python stuff."
@echo " release Create a source distribution in the dist/ directory."
@echo
.PHONY: autoflake
autoflake:
autoflake --in-place --remove-all-unused-imports -r $(PACKAGE_NAME)
.PHONY: isort
isort:
python -m isort --profile black --float-to-top $(PACKAGE_NAME)
.PHONY: black
black:
python -m black $(PACKAGE_NAME)
.PHONY: format-package
format-package: autoflake isort black
.PHONY: format-notebooks
format-notebooks :
cd docs/notebooks && $(MAKE) format
.PHONY: format
format: format-package format-notebooks
.PHONY: check-format
check-format: format
git diff
./build/has_changed.sh
.PHONY: flake8
flake8:
# stop the build if there are Python syntax errors or undefined names
python -m flake8 --count --select=E9,F63,F7,F82 --show-source --statistics $(PACKAGE_NAME)
# all Python files should follow PEP8 (except some notebooks, see setup.cfg)
python -m flake8 $(PACKAGE_NAME)
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --statistics
.PHONY: mypy
mypy:
python -m mypy -p $(PACKAGE_NAME)
.PHONY: tests
tests:
python -m pytest \
--doctest-modules \
-n auto \
--durations=30 \
$(PACKAGE_NAME)
.PHONY: coverage
coverage:
python -m pytest \
--cov-report xml \
--cov-report html \
--cov-report term \
--cov $(PACKAGE_NAME) \
--doctest-modules \
-n auto \
$(PACKAGE_NAME)
.PHONY: docs
docs:
cd docs && $(MAKE) html
.PHONY: docs-fast
docs-fast:
sphinx-build -b html -D jupyter_execute_notebooks=off docs docs/_build/html
.PHONY: env
env:
python -m virtualenv venv
.PHONY: release
release:
python setup.py sdist
.PHONY: clean-py
clean-py:
find . \( -name '*.pyc' -o -name '*.py,cover' -o -name '*~' -o -name '*__pycache__' \) -prune -exec rm -rf {} \;
rm -rf *.egg-info dist
.PHONY: clean-doc
clean-doc:
rm -rf docs/_build/*
.PHONY: clean-coverage
clean-coverage:
rm -rf htmlcov/
.PHONY: clean
clean: clean-docs clean-py clean-coverage
.PHONY: distclean
distclean: clean clean-venv
.PHONY: tags
tags: clean
ctags -e -R --languages=python
.PHONY: ipykernel
ipykernel:
python -m ipykernel install --user --name $(IPYKERNEL_NAME)
.PHONY: license
license:
./build/set_license.sh
.PHONY: check-license
check-license: license
./build/has_changed.sh
.PHONY: run-notebooks
run-notebooks :
cd docs/notebooks && $(MAKE) run
.PHONY: act
act : flake8 mypy check-license check-format coverage run-notebooks
.PHONY: pre-commit
pre-commit:
pre-commit run --all