-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
117 lines (97 loc) · 3.41 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
BROWSER ?= xdg-open
PYTHON_PACKAGE = nexus-challenge-webapp
TESTS_PACKAGE = tests
.PHONY: clean clean-test clean-pyc clean-build docs help requirements
.DEFAULT_GOAL := help
help:
@echo "Available Makefile targets:"
@echo
@echo "dist builds source and wheel package"
@echo "install install the package to the active Python environment"
@echo "requirements pip-compile requirements file templates"
@echo "docs generate Sphinx HTML documentation, including API docs"
@echo "test run tests with the default Python version"
@echo "test-all run tests on every Python version with tox"
@echo "flake8 run style checks and static analysis with flake8"
@echo "pylint run style checks and static analysis with pylint"
@echo "docstrings check docstring presence and style conventions with pydocstyle"
@echo "coverage check code coverage with the default Python version"
@echo "metrics print code metrics with radon"
@echo "clean remove all build, test, coverage and Python artifacts"
@echo "clean-build remove Python file artifacts"
@echo "clean-pyc remove Python file artifacts"
## remove all build, test, coverage and Python artifacts
clean: clean-build clean-pyc clean-test
## remove build artifacts
clean-build:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
## remove Python file artifacts
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
## remove test and coverage artifacts
clean-test:
rm -fr .tox/
rm -f .coverage
rm -fr reports/
## run tests quickly with the default Python
test:
py.test -v tests/
## run tests on every Python version with tox
test-all:
tox
## run style checks and static analysis with pylint
pylint:
@-mkdir -p reports/
@-pylint -f html $(PYTHON_PACKAGE) $(TESTS_PACKAGE) > reports/pylint.html
@$(BROWSER) reports/pylint.html
pylint $(PYTHON_PACKAGE) $(TESTS_PACKAGE)
## run style checks and static analysis with flake8
flake8:
flake8 $(PYTHON_PACKAGE) $(TESTS_PACKAGE)
## check docstring presence and style conventions with pydocstyle
docstrings:
pydocstyle $(PYTHON_PACKAGE)
lint: flake8 docstrings pylint
## check code coverage quickly with the default Python
coverage:
@-mkdir -p reports/htmlcov
coverage run --source $(PYTHON_PACKAGE) `which py.test`
coverage report -m
@coverage html -d reports/htmlcov
@$(BROWSER) reports/htmlcov/index.html
## print code metrics with radon
metrics:
radon raw -s $(PYTHON_PACKAGE) $(TEST_PACKAGE)
radon cc -s $(PYTHON_PACKAGE) $(TEST_PACKAGE)
radon mi -s $(PYTHON_PACKAGE) $(TEST_PACKAGE)
## generate Sphinx HTML documentation, including API docs
docs:
rm -f docs/$(PYTHON_PACKAGE).rst
sphinx-apidoc --no-toc -o docs/ $(PYTHON_PACKAGE)
$(MAKE) -C docs clean
$(MAKE) -C docs html
$(BROWSER) docs/_build/html/index.html
## pip-compile requirements templates
requirements:
$(MAKE) -C requirements all
requirements_dev:
$(MAKE) -C requirements dev.txt
## package and upload a release
release: clean
python setup.py sdist upload
python setup.py bdist_wheel upload
## builds source and wheel package
dist: clean
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
## install the package to the active Python's site-packages
install: clean
python setup.py install