-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
272 lines (229 loc) · 8.05 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
.PHONY: help build test dist docs tags cookiecutter docker requirements
SRC_DIRS = ./mishmash
TEST_DIR = ./tests
NAME ?= Travis Shirk
EMAIL ?= travis@pobox.com
GITHUB_USER ?= nicfit
GITHUB_REPO ?= MishMash
PYPI_REPO = pypitest
PROJECT_NAME = $(shell python setup.py --name 2> /dev/null)
VERSION = $(shell python setup.py --version 2> /dev/null)
RELEASE_NAME = $(shell python setup.py --release-name 2> /dev/null)
RELEASE_TAG = v$(VERSION)
CHANGELOG = HISTORY.rst
CHANGELOG_HEADER = v${VERSION} ($(shell date --iso-8601))$(if ${RELEASE_NAME}, : ${RELEASE_NAME},)
help:
@echo "test - run tests quickly with the default Python"
@echo "docs - generate Sphinx HTML documentation, including API docs"
@echo "clean - remove all build, test, coverage and Python artifacts"
@echo "clean-build - remove build artifacts"
@echo "clean-pyc - remove Python file artifacts"
@echo "clean-test - remove test and coverage artifacts"
@echo "clean-docs - remove autogenerating doc artifacts"
@echo "clean-patch - remove patch artifacts (.rej, .orig)"
@echo "build - byte-compile python files and generate other build objects"
@echo "lint - check style with flake8"
@echo "test - run tests quickly with the default Python"
@echo "coverage - check code coverage quickly with the default Python"
@echo "test-all - run tests on various Python versions with tox"
@echo "release - package and upload a release"
@echo " PYPI_REPO=[pypitest]|pypi"
@echo "pre-release - check repo and show version, generate changelog, etc."
@echo "dist - package"
@echo "install - install the package to the active Python's site-packages"
@echo "build - build package source files"
@echo ""
@echo "Options:"
@echo "TEST_PDB - If defined PDB options are added when 'pytest' is invoked"
@echo "BROWSER - HTML viewer used by docs-view/coverage-view"
@echo "CC_MERGE - Set to no to disable cookiecutter merging."
@echo "CC_OPTS - OVerrided the default options (--no-input) with your own."
build:
python setup.py build
clean: clean-local clean-build clean-pyc clean-test clean-patch clean-docs
clean-local:
-rm tags
@# XXX Add new clean targets here.
clean-build:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
find ./locale -name \*.mo -exec rm {} \;
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 {} +
clean-test:
rm -fr .tox/
rm -f .coverage
rm -fr .pytest_cache/
clean-patch:
find . -name '*.rej' -exec rm -f '{}' \;
find . -name '*.orig' -exec rm -f '{}' \;
lint:
tox -e lint
test:
tox -e default
test-all:
tox --parallel=all
coverage:
tox -e coverage
coverage-view: coverage
${BROWSER} build/tests/coverage/index.html
docs:
rm -f docs/mishmash.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ ${SRC_DIRS}
$(MAKE) -C docs clean
$(MAKE) -C docs html
docs-view: docs
$(BROWSER) docs/_build/html/index.html
clean-docs:
$(MAKE) -C docs clean
-rm README.html
twine-check:
twine check `ls dist/* | grep -v _docs | grep -v '.md5'`
pre-release: lint requirements test changelog
@# Keep docs off pre-release target list, else it is pruned during 'release' but
@# after a clean.
@$(MAKE) docs
@echo "VERSION: $(VERSION)"
@echo "RELEASE_TAG: $(RELEASE_TAG)"
@echo "RELEASE_NAME: $(RELEASE_NAME)"
tox -e check-manifest
@if git tag -l | grep -E '^$(shell echo $${RELEASE_TAG} | sed 's|\.|.|g')$$' > /dev/null; then \
echo "Version tag '${RELEASE_TAG}' already exists!"; \
false; \
fi
IFS=$$'\n';\
for auth in `git authors --list | \
grep -vi "nicfit@gmail.com" |\
grep -vi "dependabot\[bot\]@users.noreply.github.com" |\
grep -vi "pyup.io bot" |\
`; do \
echo "Checking $$auth...";\
grep "$$auth" AUTHORS.rst || echo "* $$auth" >> AUTHORS.rst;\
done
@test -n "${GITHUB_USER}" || (echo "GITHUB_USER not set, needed for github" && false)
@test -n "${GITHUB_TOKEN}" || (echo "GITHUB_TOKEN not set, needed for github" && false)
@github-release --version # Just a exe existence check
@git status -s -b
requirements:
tox -e requirements
changelog:
last=`git tag -l --sort=version:refname | grep '^v[0-9]' | tail -n1`;\
if ! grep "${CHANGELOG_HEADER}" ${CHANGELOG} > /dev/null; then \
rm -f ${CHANGELOG}.new; \
if test -n "$$last"; then \
gitchangelog --author-format=email \
--omit-author="travis@pobox.com" \
$${last}..HEAD |\
sed "s|^%%version%% .*|${CHANGELOG_HEADER}|" |\
sed '/^.. :changelog:/ r/dev/stdin' ${CHANGELOG} \
> ${CHANGELOG}.new; \
else \
cat ${CHANGELOG} |\
sed "s/^%%version%% .*/${CHANGELOG_HEADER}/" \
> ${CHANGELOG}.new;\
fi; \
mv ${CHANGELOG}.new ${CHANGELOG}; \
fi
build-release: test-all dist
freeze-release:
@(git diff --quiet && git diff --quiet --staged) || \
(printf "\n!!! Working repo has uncommited/unstaged changes. !!!\n" && \
printf "\nCommit and try again.\n" && false)
tag-release:
git tag -a $(RELEASE_TAG) -m "Release $(RELEASE_TAG)"
git push --tags origin
release: pre-release freeze-release build-release tag-release upload-release
github-release:
name="${RELEASE_TAG}"; \
if test -n "${RELEASE_NAME}"; then \
name="${RELEASE_TAG} (${RELEASE_NAME})"; \
fi; \
prerelease=""; \
if echo "${RELEASE_TAG}" | grep '[^v0-9\.]'; then \
prerelease="--pre-release"; \
fi; \
echo "NAME: $$name"; \
echo "PRERELEASE: $$prerelease"; \
github-release --verbose release --user "${GITHUB_USER}" \
--repo ${GITHUB_REPO} --tag ${RELEASE_TAG} \
--name "$${name}" $${prerelease}
for file in $$(find dist -type f -exec basename {} \;) ; do \
echo "Uploading: $$file"; \
github-release upload --user "${GITHUB_USER}" --repo ${GITHUB_REPO} \
--tag ${RELEASE_TAG} --name $${file} --file dist/$${file}; \
done
web-release:
@# Not implemented
@true
upload-release: pypi-release github-release web-release
pypi-release:
for f in `find dist -type f -name ${PROJECT_NAME}-${VERSION}.tar.gz \
-o -name \*.egg -o -name \*.whl`; do \
if test -f $$f ; then \
twine upload --verbose -r ${PYPI_REPO} --skip-existing $$f ; \
fi \
done
sdist: build
python setup.py sdist --formats=gztar,zip
python setup.py bdist_egg
python setup.py bdist_wheel
dist: clean gettext sdist twine-check docs
cd docs/_build && \
tar czvf ../../dist/${PROJECT_NAME}-${VERSION}_docs.tar.gz html
@# The cd dist keeps the dist/ prefix out of the md5sum files
cd dist && \
for f in $$(ls); do \
md5sum $${f} > $${f}.md5; \
done
ls -l dist
install: clean
python setup.py install
tags:
ctags -R ${SRC_DIRS}
README.html: README.rst
rst2html5.py README.rst >| README.html
if test -n "${BROWSER}"; then \
${BROWSER} README.html;\
fi
CC_MERGE ?= yes
CC_OPTS ?= --no-input
GIT_COMMIT_HOOK = .git/hooks/commit-msg
cookiecutter:
tmp_d=`mktemp -d`; cc_d=$$tmp_d/MishMash; \
if test "${CC_MERGE}" == "no"; then \
nicfit cookiecutter ${CC_OPTS} "$${tmp_d}"; \
git -C "$$cc_d" diff; \
git -C "$$cc_d" status -s -b; \
else \
nicfit cookiecutter --merge ${CC_OPTS} "$${tmp_d}" \
--extra-merge ${GIT_COMMIT_HOOK} ${GIT_COMMIT_HOOK};\
fi; \
rm -rf $$tmp_d
DOCKER_COMPOSE := VERSION=${VERSION} docker-compose -f docker/docker-compose.yml
docker:
@$(DOCKER_COMPOSE) build mishmash
docker-nocache:
@$(DOCKER_COMPOSE) build --no-cache mishmash
docker-clean:
$(DOCKER_COMPOSE) rm
-docker rmi -f mishmash:latest
docker-publish: docker
docker tag mishmash:latest nicfit/mishmash:${VERSION}
docker push nicfit/mishmash:${VERSION}
docker pull nicfit/mishmash:${VERSION}
DEF_MSG_CAT = locale/en_US/LC_MESSAGES/MishMash.po
MSG_CAT_TMPL = locale/MishMash.pot
gettext-po:
pybabel extract --no-location -o ${MSG_CAT_TMPL} -w 80 ${SRC_DIRS}
test -f ${DEF_MSG_CAT} || \
pybabel init -D MishMash -i ${MSG_CAT_TMPL} -d locale -l en_US
pybabel update -D MishMash -i ${MSG_CAT_TMPL} -d locale
gettext:
pybabel compile --statistics -D MishMash -d locale