-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
222 lines (168 loc) · 5.43 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
PROJ ?= src/mode-ng
PGPIDENT ?= "Lanqing Huang"
PYTHON ?= python3
PYTEST ?= pytest
PIP ?= ${PYTHON} -m pip
GIT ?= git
TOX ?= tox
ICONV ?= iconv
FLAKE8 ?= flake8
PYDOCSTYLE ?= pydocstyle
MYPY ?= mypy
SPHINX2RST ?= sphinx2rst
BUMPVERSION ?= bumpversion
TESTDIR ?= tests
SPHINX_DIR ?= docs/
SPHINX_BUILDDIR ?= "${SPHINX_DIR}/_build"
README ?= README.rst
README_SRC ?= "docs/templates/readme.txt"
CONTRIBUTING ?= CONTRIBUTING.md
CONTRIBUTING_SRC ?= "docs/contributing.rst"
COC ?= CODE_OF_CONDUCT.md
COC_SRC ?= "docs/includes/code-of-conduct.txt"
SPHINX_HTMLDIR="${SPHINX_BUILDDIR}/html"
DOCUMENTATION=Documentation
all: help
help:
@echo "docs - Build documentation."
@echo "test-all - Run tests for all supported python versions."
@echo "develop - Install all dependencies into current virtualenv."
@echo "distcheck ---------- - Check distribution for problems."
@echo " test - Run unittests using current python."
@echo " lint ------------ - Check codebase for problems."
@echo " apicheck - Check API reference coverage."
@echo " readmecheck - Check README.rst encoding."
@echo " contribcheck - Check CONTRIBUTING.rst encoding"
@echo " flakes -------- - Check code for syntax and style errors."
@echo " typecheck - Run the mypy type checker"
@echo " flakecheck - Run flake8 on the source code."
@echo " pep257check - Run pep257 on the source code."
@echo "readme - Regenerate README.rst file."
@echo "contrib - Regenerate CONTRIBUTING.rst file"
@echo "coc - Regenerate CODE_OF_CONDUCT.rst file"
@echo "clean-dist --------- - Clean all distribution build artifacts."
@echo " clean-git-force - Remove all uncomitted files."
@echo " clean ------------ - Non-destructive clean"
@echo " clean-pyc - Remove .pyc and __pycache__ files"
@echo " clean-docs - Remove documentation build artifacts."
@echo " clean-build - Remove setup artifacts."
@echo "bump - Bump patch version number."
@echo "bump-minor - Bump minor version number."
@echo "bump-major - Bump major version number."
@echo "release - Make PyPI release."
# ------------------------ Reset and Cleanup ---------------------------------
clean: clean-docs clean-pyc clean-build
clean-all: clean
clean-dist: clean clean-git
clean-pyc:
-find . -type f -a \( -name "*.pyc" -o -name "*$$py.class" \) | xargs rm
-find . -type d -name "__pycache__" | xargs rm -r
clean-git:
${GIT} clean -xdn
clean-git-force:
${GIT} clean -xdf
# ------------------ Lint, Test and Coverage ---------------------------------
lint: flakecheck typecheck readmecheck apicheck
apicheck:
(cd "${SPHINX_DIR}"; $(MAKE) apicheck)
flakecheck:
${FLAKE8} ${PROJ} ${TESTDIR} examples/
pep257check:
${PYDOCSTYLE} ${PROJ}
flakes: flakecheck pep257check
typecheck:
${MYPY} --pretty -p ${PROJ}
test:
${PYTEST} .
# test-inc:
# ${PYTEST} --inc --inc-path tests/ --inc-path src/mode/
test-all: clean-pyc
${TOX}
cov:
$(PYTEST) -x --cov="${PROJ}" --cov-report=html
distcheck: lint test
dist: readme contrib clean-dist build
# ------------------------- Dev setup ----------------------------------------
.PHONY: venv
venv:
${PYTHON} -m venv .venv
.PHONY: deps-default
deps-default:
${PIP} install -U -r requirements/default.txt
.PHONY: deps-dev
deps-dev:
${PIP} install -U -r requirements/dev.txt
.PHONY: deps-docs
deps-docs:
${PIP} install -U -r requirements/docs.txt
.PHONY: deps-test
deps-test:
${PIP} install -U -r requirements/test.txt
.PHONY: deps-typecheck
deps-typecheck:
${PIP} install -U -r requirements/typecheck.txt
.PHONY: deps-release
deps-release:
${PIP} install -U -r requirements/release.txt
.PHONY: deps-extras
deps-extras:
${PIP} install -U -r requirements/extras/eventlet.txt
${PIP} install -U -r requirements/extras/uvloop.txt
.PHONY: develop
develop: deps-default deps-dist deps-docs deps-test deps-typecheck deps-extras
${PIP} install -e .
.PHONY: requirements
requirements:
${PIP} install --upgrade pip
for f in `ls requirements/` ; do ${PIP} install -r requirements/$$f ; done
.PHONY: clean-requirements
clean-requirements:
pip freeze | xargs pip uninstall -y
$(MAKE) requirements
# ---------------------- Release distribution --------------------------------
bump-patch:
${BUMPVERSION} patch
bump-minor:
${BUMPVERSION} minor
bump-major:
${BUMPVERSION} major
do-build:
${PYTHON} -m build -s -w
clean-build:
rm -rf build/ .eggs/ *.egg-info/ .tox/ .coverage/ cover/
.PHONY: build
build: clean-build do-build
.PHONY: release
release:
${PYTHON} -m twine check dist/*
${PYTHON} -m twine upload --skip-existing dist/*
.PHONY: cliff
cliff:
git cliff -u
# ------------------------------ Docs ----------------------------------------
.PHONY: Documentation
Documentation:
${PIP} install -r requirements/docs.txt
(cd "$(SPHINX_DIR)"; $(MAKE) html)
mv "$(SPHINX_HTMLDIR)" $(DOCUMENTATION)
.PHONY: docs
docs: Documentation
clean-docs:
-rm -rf "$(SPHINX_BUILDDIR)"
clean-readme:
-rm -f $(README)
readmecheck:
$(ICONV) -f ascii -t ascii $(README) >/dev/null
$(README):
$(SPHINX2RST) "$(README_SRC)" --ascii > $@
readme: clean-readme $(README) readmecheck
clean-contrib:
-rm -f "$(CONTRIBUTING)"
$(CONTRIBUTING):
$(SPHINX2RST) "$(CONTRIBUTING_SRC)" > $@
contrib: clean-contrib $(CONTRIBUTING)
clean-coc:
-rm -f "$(COC)"
$(COC):
$(SPHINX2RST) "$(COC_SRC)" > $@
coc: clean-coc $(COC)