forked from apragacz/django-rest-registration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
129 lines (104 loc) · 4 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
SHELL := /bin/bash
PACKAGE_DIR := rest_registration
TESTS_DIR := tests
DIST_DIR := dist
BUILD_DIR := build
DOCS_DIR := docs
DOCS_SRC_DIR := ${DOCS_DIR}
DOCS_BUILD_DIR := "${DOCS_DIR}/_build"
DOCS_REFERENCE_DIR := "${DOCS_DIR}/reference"
GREP := grep
AWK := awk
SORT := sort
RM := rm
FIND := find
XARGS := xargs
CAT := cat
PYTHON := python
FLAKE8 := flake8
FLAKE8_OPTS :=
MYPY := mypy
MYPY_OPTS :=
PYLINT := pylint
PYLINT_OPTS := --rcfile=setup.cfg
PYTEST := py.test
PYTEST_OPTS :=
TWINE := twine
PIP_COMPILE := pip-compile
PIP_COMPILE_OPTS := --upgrade
SPHINXBUILD := sphinx-build
SPHINXBUILD_OPTS :=
SPHINXBUILD_WARNING_LOG = sphinx-warnings.log
SPHINXAUTOBUILD := sphinx-autobuild
SPHINXAUTOBUILD_OPTS := --watch ${PACKAGE_DIR} --ignore ${DOCS_REFERENCE_DIR}
.PHONY: help
help: ## Display this help screen
@grep -E '^[\.a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: all
all: check test build check_package ## check code, test, build, check package
.PHONY: install_dev
install_dev: ## install all pip requirements and the package as editable
${PYTHON} -m pip install -r requirements/requirements-dev.lock.txt ${ARGS}
${PYTHON} -m pip install -e .
.PHONY: install_test
install_test: ## install all pip requirements needed for testing and the package as editable
${PYTHON} -m pip install -r requirements/requirements-test.lock.txt ${ARGS}
${PYTHON} -m pip install -e .
.PHONY: upgrade_requirements
upgrade_requirements: ## upgrade pip requirements lock files
${PIP_COMPILE} ${PIP_COMPILE_OPTS} --output-file=requirements/requirements-base.lock.txt requirements/requirements-base.in
${PIP_COMPILE} ${PIP_COMPILE_OPTS} --output-file=requirements/requirements-test.lock.txt requirements/requirements-base.lock.txt requirements/requirements-test.in
${PIP_COMPILE} ${PIP_COMPILE_OPTS} --output-file=requirements/requirements-dev.lock.txt requirements/requirements-test.lock.txt requirements/requirements-dev.in
.PHONY: test
test: ## run tests
${PYTEST} ${PYTEST_OPTS} ${ARGS}
.PHONY: check
check: flake8 mypy pylint check_docs ## run checks: flake8, mypy, pylint, check_docs
.PHONY: flake8
flake8: ## run flake8
${FLAKE8} ${FLAKE8_OPTS} ${ARGS}
.PHONY: mypy
mypy: ## run mypy
${MYPY} ${MYPY_OPTS} ${PACKAGE_DIR} ${ARGS}
.PHONY: pylint
pylint: ## run pylint
# run pylint for production code and test code separately
${PYLINT} ${PYLINT_OPTS} ${PACKAGE_DIR} ${DOCS_DIR} ./*.py ${ARGS}
${PYLINT} ${PYLINT_OPTS} --disable=duplicate-code --disable=redefined-outer-name --disable=too-many-arguments ${TESTS_DIR} ${ARGS}
.PHONY: upload_package
upload_package: build_package check_package ## upload the package to PyPI
${TWINE} upload ${DIST_DIR}/*
.PHONY: check_package
check_package: build_package ## check that the built package is well-formed
${TWINE} check ${DIST_DIR}/*
.PHONY: build
build: build_package ## alias for build_package
.PHONY: build_package
build_package: ## build package (source + wheel)
-${RM} -r ${DIST_DIR}
${PYTHON} setup.py sdist
${PYTHON} setup.py bdist_wheel
.PHONY: build_docs
build_docs: ## build documentation
${SPHINXBUILD} ${SPHINXBUILD_OPTS} ${DOCS_SRC_DIR} ${DOCS_BUILD_DIR}/html ${ARGS}
.PHONY: check_docs
check_docs: ## check that the docs do not contain any warnings / errors
${SPHINXBUILD} ${SPHINXBUILD_OPTS} ${DOCS_SRC_DIR} ${DOCS_BUILD_DIR}/html -w ${SPHINXBUILD_WARNING_LOG} ${ARGS}
${CAT} ${SPHINXBUILD_WARNING_LOG}
@${SHELL} -c '[ ! -s ${SPHINXBUILD_WARNING_LOG} ]'
.PHONY: watch_docs
watch_docs: ## build documentation in watch mode (will start additonal http server)
${SPHINXAUTOBUILD} ${SPHINXAUTOBUILD_OPTS} ${DOCS_SRC_DIR} ${DOCS_BUILD_DIR}/html ${ARGS}
.PHONY: clean
clean: ## remove generated files
-${RM} -r .tox
-${RM} -r .pytest_cache
-${RM} -r .mypy_cache
${FIND} "." -iname '__pycache__' -type d -print0 | ${XARGS} -0 ${RM} -r
-${RM} TEST-*.xml
-${RM} .coverage
-${RM} coverage.xml
-${RM} -r coverage_html_report
-${RM} -r ${DIST_DIR}
-${RM} -r ${BUILD_DIR}
-${RM} -r ${DOCS_BUILD_DIR}