forked from robbert-harms/MDT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
177 lines (151 loc) · 5.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
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
PYTHON=$$(which python3)
PIP=$$(which pip3)
PROJECT_NAME=mdt
PROJECT_VERSION=$$($(PYTHON) setup.py --version)
GPG_SIGN_KEY=6F4438DB0E1AA560
UBUNTU_DISTRIBUTIONS=focal bionic xenial
.PHONY: help
help:
@echo "clean - remove all build, test, coverage and Python artifacts (no uninstall)"
@echo "lint - check style with flake8"
@echo "test(s)- run tests quickly with the default Python"
@echo "test-all - run tests on every Python version with tox"
@echo "coverage - check code coverage quickly with the default Python"
@echo "docs - generate Sphinx HTML documentation, including API docs"
@echo "docs-pdf - generate the PDF documentation, including API docs"
@echo "docs-man - generate the linux manpages"
@echo "docs-changelog - generate the changelog documentation"
@echo "prepare-release - prepare for a new release"
@echo "release - package and upload a release"
@echo "dist - create a pip package"
@echo "dist-ubuntu - create an Ubuntu package"
@echo "install - installs the package using pip"
@echo "uninstall - uninstalls the package using pip"
.PHONY: clean
clean: clean-build clean-pyc clean-test
$(PYTHON) setup.py clean
.PHONY: clean-build
clean-build:
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
.PHONY: clean-pyc
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 {} +
.PHONY: clean-test
clean-test:
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
.PHONY: lint
lint:
flake8 $(PROJECT_NAME) tests
.PHONY: test
test:
$(PYTHON) setup.py test
.PHONY: tests
tests: test
.PHONY: test-all
test-all:
tox
.PHONY: coverage
coverage:
coverage run --source $(PROJECT_NAME) setup.py test
coverage report -m
coverage html
@echo "To view results type: htmlcov/index.html &"
.PHONY: docs
docs:
rm -f docs/$(PROJECT_NAME)*.rst
rm -f docs/modules.rst
$(MAKE) -C docs clean
sphinx-apidoc -o docs/ $(PROJECT_NAME)
$(MAKE) -C docs html SPHINXBUILD='python3 $(shell which sphinx-build)'
@echo "To view results type: firefox docs/_build/html/index.html &"
.PHONY: docs-pdf
docs-pdf:
rm -f docs/$(PROJECT_NAME)*.rst
rm -f docs/modules.rst
$(MAKE) -C docs clean
sphinx-apidoc -o docs/ $(PROJECT_NAME)
$(MAKE) -C docs latexpdf SPHINXBUILD='python3 $(shell which sphinx-build)'
@echo "To view results use something like: evince docs/_build/latex/$(PROJECT_NAME).pdf &"
.PHONY: docs-man
docs-man:
rm -f docs/$(PROJECT_NAME)*.rst
rm -f docs/modules.rst
$(MAKE) -C docs clean
sphinx-apidoc -o docs/ $(PROJECT_NAME)
$(MAKE) -C docs man SPHINXBUILD='python3 $(shell which sphinx-build)'
@echo "To view results use something like: man docs/_build/man/$(PROJECT_NAME).1 &"
.PHONY: docs-changelog
docs-changelog:
gitchangelog
.PHONY: prepare-release
prepare-release: clean
@echo "Current version: "$(PROJECT_VERSION)
@while [ -z "$$NEW_VERSION" ]; do \
read -r -p "Give new version: " NEW_VERSION;\
done && \
( \
printf 'Setting new version: %s \n\n' \
"$$NEW_VERSION " \
) && sed -i -e "s/^\(VERSION\ =\ \)\('.*'\)\(\ *\)/\1'$$NEW_VERSION'/g" $(PROJECT_NAME)/__version__.py
$(MAKE) docs-changelog
@echo "Consider manually inspecting CHANGELOG.rst for possible improvements."
.PHONY: release
release: clean release-pip release-github
.PHONY: release-pip
release-pip:
$(PYTHON) setup.py sdist bdist_wheel
twine upload dist/$(PROJECT_NAME)-$(PROJECT_VERSION).tar.gz dist/$(PROJECT_NAME)-$(PROJECT_VERSION)-py2.py3-none-any.whl
.PHONY: release-ubuntu-ppa
release-ubuntu-ppa: dist-ubuntu
for ubuntu_distro in $(UBUNTU_DISTRIBUTIONS) ; do \
dput ppa:robbert-harms/cbclab dist/$(PROJECT_NAME)_$(PROJECT_VERSION)-1~$${ubuntu_distro}1_source.changes ; \
done
.PHONY: release-github
release-github:
git push . master:latest_release
git tag -a v$(PROJECT_VERSION) -m "Version $(PROJECT_VERSION)"
git push origin latest_release
git push origin --tags
.PHONY: dist
dist: clean
$(PYTHON) setup.py sdist
$(PYTHON) setup.py bdist_wheel
ls -l dist
.PHONY: dist-ubuntu
dist-ubuntu: clean
$(PYTHON) setup.py sdist
cp dist/$(PROJECT_NAME)-$(PROJECT_VERSION).tar.gz dist/$(PROJECT_NAME)_$(PROJECT_VERSION).orig.tar.gz
tar -xzf dist/$(PROJECT_NAME)-$(PROJECT_VERSION).tar.gz -C dist/
build_flag=-sa;\
for ubuntu_distro in $(UBUNTU_DISTRIBUTIONS) ; do \
$(MAKE) _package-ubuntu suite=$$ubuntu_distro debian-version=1~$${ubuntu_distro}1 build-flag=$$build_flag ; \
build_flag=-sd;\
done
.PHONY: _package-ubuntu
_package-ubuntu:
# Requires the following parameters to be set:
# suite: the suite argument in the debianize command
# debian-version: the debian-version argument in the debianize command
# build-flag: the build flag for the debuild command. Commonly something like '-sa' or '-sd'
rm -rf debian/source
$(PYTHON) setup.py --command-packages=stdeb.command debianize --suite $(suite) --debian-version $(debian-version) --with-python2 False --with-python3 True
$(PYTHON) setup.py prepare_debian_dist
rm -rf dist/$(PROJECT_NAME)-$(PROJECT_VERSION)/debian/
cp -r debian dist/$(PROJECT_NAME)-$(PROJECT_VERSION)/
cd dist/$(PROJECT_NAME)-$(PROJECT_VERSION)/; dpkg-source -b .
cd dist/$(PROJECT_NAME)-$(PROJECT_VERSION)/; debuild -S $(build-flag) -k$(GPG_SIGN_KEY)
.PHONY: install
install: dist
$(PIP) install --upgrade --no-deps --force-reinstall dist/$(PROJECT_NAME)-*.tar.gz
.PHONY: uninstall
uninstall:
$(PIP) uninstall -y $(PROJECT_NAME)