-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
181 lines (124 loc) · 3.58 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
# PN - Project Name
PN := scaraplate
# PN - Project Version
PV := `python setup.py -q --version`
PYTHON := python3
SHELL := /bin/sh
LINT_TARGET := setup.py src/ tests/
MYPY_TARGET := src/${PN} tests/
# Create the file below if you need to override the variables above
# or add additional make targets.
-include Makefile.inc
.PHONY: all
all: help
.PHONY: check
# target: check - Run all checks: linters and tests (with coverage)
check: lint test
@${PYTHON} setup.py check
.PHONY: clean
# target: clean - Remove intermediate and generated files
clean:
@${PYTHON} setup.py clean
@find . -type f -name '*.py[co]' -delete
@find . -type d -name '__pycache__' -delete
@rm -rf {build,htmlcov,cover,coverage,dist,.coverage,.hypothesis}
@rm -rf src/*.egg-info
@rm -f VERSION
.PHONY: develop
# target: develop - Install package in editable mode with `develop` extras
develop:
@${PYTHON} -m pip install --upgrade pip setuptools wheel
@${PYTHON} -m pip install -e .[develop,gitlab]
.PHONY: dist
# target: dist - Build all artifacts
dist: dist-sdist dist-wheel
.PHONY: dist-sdist
# target: dist-sdist - Build sdist artifact
dist-sdist:
@${PYTHON} setup.py sdist
.PHONY: dist-wheel
# target: dist-wheel - Build wheel artifact
dist-wheel:
@${PYTHON} setup.py bdist_wheel
.PHONY: distcheck
# target: distcheck - Verify distributed artifacts
distcheck: distcheck-clean sdist
@mkdir -p dist/$(PN)
@tar -xf dist/$(PN)-$(PV).tar.gz -C dist/$(PN) --strip-components=1
@$(MAKE) -C dist/$(PN) venv
. dist/$(PN)/venv/bin/activate && $(MAKE) -C dist/$(PN) develop
. dist/$(PN)/venv/bin/activate && $(MAKE) -C dist/$(PN) check
@rm -rf dist/$(PN)
.PHONY: distcheck-clean
distcheck-clean:
@rm -rf dist/$(PN)
.PHONY: format
# target: format - Format the code according to the coding styles
format: format-black format-isort
.PHONY: format-black
format-black:
@black ${LINT_TARGET}
.PHONY: format-isort
format-isort:
@isort ${LINT_TARGET}
.PHONY: help
# target: help - Print this help
help:
@egrep "^# target: " Makefile \
| sed -e 's/^# target: //g' \
| sort -h \
| awk '{printf(" %-16s", $$1); $$1=$$2=""; print "-" $$0}'
.PHONY: install
# target: install - Install the project
install:
@pip install .
.PHONY: lint
# target: lint - Check source code with linters
lint: lint-isort lint-black lint-flake8 lint-mypy lint-pylint
.PHONY: lint-black
lint-black:
@${PYTHON} -m black --check --diff ${LINT_TARGET}
.PHONY: lint-flake8
lint-flake8:
@${PYTHON} -m flake8 --statistics ${LINT_TARGET}
.PHONY: lint-isort
lint-isort:
@${PYTHON} -m isort --check-only ${LINT_TARGET}
.PHONY: lint-mypy
lint-mypy:
@${PYTHON} -m mypy ${MYPY_TARGET}
.PHONY: lint-pylint
lint-pylint:
@${PYTHON} -m pylint --rcfile=.pylintrc --errors-only ${LINT_TARGET}
.PHONY: purge
# target: purge - Remove all unversioned files and reset working copy
purge:
@git reset --hard HEAD
@git clean -xdff
.PHONY: report-coverage
# target: report-coverage - Print coverage report
report-coverage:
@${PYTHON} -m coverage report
.PHONY: report-pylint
# target: report-pylint - Generate pylint report
report-pylint:
@${PYTHON} -m pylint ${LINT_TARGET}
.PHONY: test
# target: test - Run tests with coverage
test:
@${PYTHON} -m coverage run -m pytest
@${PYTHON} -m coverage report
.PHONY: uninstall
# target: uninstall - Uninstall the project
uninstall:
@pip uninstall $(PN)
# `venv` target is intentionally not PHONY.
# target: venv - Creates virtual environment
venv:
@${PYTHON} -m venv venv
.PHONY: version
# target: version - Generate and print project version in PEP-440 format
version: VERSION
@cat VERSION
VERSION:
@echo ${PV} > $@