-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
181 lines (128 loc) · 3.94 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
SHELL=/bin/bash
.DEFAULT_GOAL := help
# ---------------------------------
# Project specific targets
# ---------------------------------
#
# Add any targets specific to the current project in here.
# -------------------------------
# Common targets for Dev projects
# -------------------------------
#
# Edit these targets so they work as expected on the current project.
#
# Remember there may be other tools which use these targets, so if a target is not suitable for
# the current project, then keep the target and simply make it do nothing.
help: ## This help dialog.
help: help-display
clean: ## Remove unneeded files generated from the various build tasks.
clean: build-clean coverage-clean
reset: ## Reset your local environment. Useful after switching branches, etc.
reset: venv-check venv-wipe install-local
check: ## Check for any obvious errors in the project's setup.
check: pipdeptree-check
format: ## Run this project's code formatters.
format: yapf-format isort-format
lint: ## Lint the project.
lint: yapf-lint isort-lint flake8-lint
test: ## Run unit and integration tests.
test: pytest-test
test-report: ## Run and report on unit and integration tests.
test-report: coverage-clean test coverage-report
deploy: ## Deploy this project to demo or live.
deploy:
@echo "Not a deployable project. Maybe you want to do a 'make release' instead?"
release: ## Package and release this project to PyPi.
release: clean build-release
dist: ## Builds source and wheel package
dist: clean build-dist
docs: ## Build the docs
docs: sphinx-apidoc sphinx-html
# ---------------
# Utility targets
# ---------------
#
# Targets which are used by the common targets. You likely want to customise these per project,
# to ensure they're pointing at the correct directories, etc.
# Build
build-clean:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
build-release:
@echo
@echo "This will package and release this project to PyPi."
@echo
@echo "A checklist before you continue:"
@echo
@echo " - have you ran 'versionbump'?"
@echo " - have you pushed the commit and tag created by 'versionbump'?"
@echo " - are you sure the project is in a state to be released?"
@echo
@read -p "Press <enter> to continue. Or <ctrl>-c to quit and address the above points."
python setup.py sdist upload
python setup.py bdist_wheel upload
build-dist:
python setup.py sdist
python setup.py bdist_wheel
ls -l dist
# Virtual Environments
venv-check:
ifndef VIRTUAL_ENV
$(error Must be in a virtualenv)
endif
venv-wipe: venv-check
if ! pip list --format=freeze | grep -v "^appdirs=\|^distribute=\|^packaging=\|^pip=\|^pyparsing=\|^setuptools=\|^six=\|^wheel=" | xargs pip uninstall -y; then \
echo "Nothing to remove"; \
fi
# Installs
install-local: pip-install-local
# Pip
pip-install-local: venv-check
pip install -r requirements/local.txt
# ISort
isort-version:
isort --version
isort-lint: isort-version
isort --recursive --check-only --diff cofecms
isort-format: isort-version
isort --recursive cofecms
# Flake8
flake8-lint:
flake8 cofecms
# Pytest
pytest-test:
coverage run --source cofecms -m pytest
# Coverage
coverage-report: coverage-html coverage-xml
coverage report --show-missing
coverage-html:
coverage html
coverage-xml:
coverage xml
coverage-clean:
rm -rf htmlcov
rm -rf reports
rm -f .coverage
# YAPF
yapf-lint:
yapf_lint_output="`yapf -r -p -d --style .style.yapf cofecms tests`" && \
if [[ $$yapf_lint_output ]]; then echo -e "$$yapf_lint_output"; exit 1; fi
yapf-format:
yapf -r -i -p --style .style.yapf cofecms tests
#pipdeptree
pipdeptree-check:
@pipdeptree --warn fail > /dev/null
# Help
help-display:
@awk '/^[[:alnum:]-]*: ##/ { split($$0, x, "##"); printf "%20s%s\n", x[1], x[2]; }' $(MAKEFILE_LIST)
# Sphinx
sphinx-html:
$(MAKE) -C docs clean
$(MAKE) -C docs html
sphinx-apidoc:
rm -f docs/pycofecms.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ cofecms