Debian Codegraph @

Makefile

raw
1 SHELL = /bin/bash
2
3 PYVERSIONS ?= $(shell py3versions -i)
4 PYVERSIONSPATHS = $(shell for PV in $(PYVERSIONS); do which $$PV; done)
5
6 TESTLOGLEVEL ?= WARN
7
8 .PHONY: test examples testinstall all
9
10 PYTHONPATH=$(shell pwd)
11 export PYTHONPATH
12
13 HIYAPYCOVERSION=$(shell PYTHONPATH=$(PYTHONPATH)/hiyapyco:$(PYTHONPATH) python -c 'from version import VERSION; print(VERSION)')
14
15 export GPGKEY=C9B1F13E67CAB37AE6D132134C2B4A1677DE7FB4
16
17 # FIXME: why this hack! w/ -p
18 DPKGBUILDPKGVERSION = $(shell dpkg-buildpackage --version | sed '1!d;s/^.* //g;s/\.$//g')
19 DPKGBUILDPKGSIGNARG = $(shell dpkg --compare-versions $DPKGBUILDPKGVERSION lt 1.17.26 && echo "-p'gpg --use-agent'")
20
21 pypiupload: PYPIREPO := pypi
22 pypiupload: PYPIREPOURL := https://pypi.python.org/pypi/HiYaPyCo
23 pypiuploadtest: PYPIREPO := pypitest
24 pypiuploadtest: PYPIREPOURL := https://test.pypi.org/project/HiYaPyCo/
25
26 quicktest: pylint test examples
27 # FIXME: testinstallvirtualenv fails due to jinja2 2.8 error w/ python3.2 but works w/ python3.4 ... WTF
28 alltest: clean quicktest testreadme testinstall testinstallvirtualenv
29 @echo "$@ passed"
30
31 printversions:
32 @echo -e "HIYAPYCOVERSION:\t$(HIYAPYCOVERSION)"
33 @echo -e "PYVERSIONS:\t\t$(PYVERSIONS)"
34 @echo -e "PYVERSIONSPATHS:\t$(PYVERSIONSPATHS)"
35
36 pylint:
37 pylint --disable=missing-module-docstring,unused-import,consider-using-with,unspecified-encoding,consider-using-f-string setup.py
38 @# FIXME: logging-not-lazy global-statement invalid-name
39 @# py3 only: raise-missing-from
40 pylint --class-naming-style=any --disable=fixme,pointless-string-statement,missing-module-docstring,unnecessary-pass,logging-not-lazy,global-statement,invalid-name,raise-missing-from,consider-merging-isinstance,too-many-nested-blocks,consider-using-f-string,deprecated-module hiyapyco/__init__.py
41
42 testreadme:
43 # requires python3-restructuredtext-lint
44 rst-lint README.rst
45
46 test:
47 @RET=0; \
48 for p in $(PYVERSIONS); do \
49 echo "python version $$p"; \
50 for t in test/test_*.py; do \
51 $$p -t $$t -l $(TESTLOGLEVEL); \
52 RET=$$?; \
53 if [ $$RET -gt 0 ]; then break 2; fi; \
54 done; \
55 echo ""; \
56 done; \
57 exit $$RET
58
59 examples:
60 @RET=0; \
61 for p in $(PYVERSIONS); do \
62 echo "python version $$p"; \
63 for t in examples/*.py; do \
64 [ "$$t" = "examples/hiyapyco_example.py" ] && continue; \
65 [ "$$t" = "examples/issue73compareOrderedDict.py" ] && continue; \
66 echo "$$p -t $$t ..."; \
67 $$p -t $$t > /dev/null 2>&1; \
68 RET=$$?; \
69 if [ $$RET -gt 0 ]; then $$p -t $$t; break 2; fi; \
70 done; \
71 echo ""; \
72 done; \
73 exit $$RET
74
75 testinstall:
76 @set -e; \
77 for p in $(PYVERSIONS); do \
78 rm -rf /tmp/hiyapyco; \
79 echo ""; \
80 echo "$@ w/ python version $$p ..."; \
81 echo ""; \
82 $$p setup.py install --root=/tmp/hiyapyco; \
83 echo ""; \
84 echo "$@ w/ python version $$p : OK"; \
85 echo ""; \
86 done
87
88 testinstallvirtualenv:
89 @set -e; \
90 BASETMP=/tmp/hiyapyco; \
91 rm -rf $$BASETMP; \
92 for p in $(PYVERSIONSPATHS); do \
93 VENV=$$BASETMP/$$(basename $$p); \
94 mkdir -p $$VENV; \
95 echo "$@ w/ python version $$(basename $$p) in $$VENV ..."; \
96 virtualenv -p $$p $$VENV; \
97 source $$VENV/bin/activate; \
98 which python; \
99 python --version; \
100 python setup.py install; \
101 echo ""; \
102 echo " ... test install ..."; \
103 python -c 'import sys; from hiyapyco import __version__ as HIYAPYCOVERSION; print ("hiyapyco %s" % HIYAPYCOVERSION); print (sys.version)'; \
104 pip install -r test/requirements.txt; \
105 make test; \
106 make examples; \
107 deactivate; \
108 done
109
110 clean: distclean
111
112 distclean:
113 python setup.py clean
114 rm -rf release dist build HiYaPyCo.egg-info
115 find . -type f -name \*.pyc -exec rm -v {} \;
116
117 sdist:
118 python setup.py sdist
119 @echo "$@ done"
120
121 wheel:
122 # requires a 'sudo pip install wheel'
123 python setup.py bdist_wheel
124 @echo "$@ done"
125
126 twinecheckdist:
127 twine check dist/HiYaPyCo-*.tar.gz
128 @echo "$@ done"
129
130 pypi: sdist wheel twinecheckdist
131 @echo "$@ done"
132 pypiuploadtest: pypi pypiuploaddo
133 pypiupload: pypi pypiuploaddo
134 pypiuploaddo: pypi
135 # set use-agent in ~/.gnupg/gpg.conf to use the agent
136 rm -rf dist/HiYaPyCo-*.egg*
137 twine upload --verbose -s -i $(GPGKEY) -r $(PYPIREPO) dist/*
138 @echo "test the result at: $(PYPIREPOURL)"
139
140 gpg-agent:
141 @gpg-agent; \
142 RET=$$?; echo "gpg agent running: $$RET"; \
143 if [ $$RET -gt 0 ]; then \
144 gpg-agent; \
145 echo 'please run eval "eval $$(gpg-agent --daemon)"'; \
146 exit 1; \
147 fi
148 gpg-connect-agent 'keyinfo --list' /bye
149 dch-increment:
150 @# use this to increment the deb release number for a existing release
151 @DEBEMAIL=$$(git config --local --get user.email) \
152 DEBFULLNAME="Klaus Zerwes zero-sys.net" \
153 dch -i "new debian release"
154 @git diff debian/changelog
155 dch-version:
156 @# use this after updating hiyapyco/version.py
157 @if $$(dpkg --compare-versions $$(dpkg-parsechangelog | sed '/^Version: /!d; s/^Version: \([.0-9]*\).*/\1/g') lt $(HIYAPYCOVERSION)); then \
158 DEBEMAIL=$$(git config --local --get user.email) \
159 DEBFULLNAME="Klaus Zerwes zero-sys.net" \
160 dch -v $(HIYAPYCOVERSION)-1 -D stable "release version $(HIYAPYCOVERSION)"; \
161 git diff debian/changelog; \
162 else \
163 echo "nothing to do"; \
164 fi
165 debunsigned:
166 rm -rf release/deb/build
167 mkdir -p release/deb/build
168 tar cv -Sp --exclude=dist --exclude=build --exclude='*/.git*' -f - . | ( cd release/deb/build && tar x -Sp -f - )
169 cd release/deb/build && dpkg-buildpackage -b --no-sign
170 rm -rf release/deb/build
171 lintian release/deb/*.deb
172
173 deb: gpg-agent
174 rm -rf release/deb/build
175 mkdir -p release/deb/build
176 tar cv -Sp --exclude=dist --exclude=build --exclude='*/.git*' -f - . | ( cd release/deb/build && tar x -Sp -f - )
177 cd release/deb/build && dpkg-buildpackage -b -k$(GPGKEY) $(DPKGBUILDPKGSIGNARG)
178 gpg --verify release/deb/hiyapyco_*.changes
179 rm -rf release/deb/build
180 lintian release/deb/*.deb
181
182 debrepo: deb
183 cd release/deb && \
184 apt-ftparchive packages . > Packages && \
185 gzip -c Packages > Packages.gz && \
186 bzip2 -c Packages > Packages.bz2 && \
187 lzma -c Packages > Packages.lsma
188 echo "Suite: stable testing" >> release/deb/Release
189 echo "Origin: Klaus Zerwes zero-sys.net" >> release/deb/Release
190 echo "Label: hiyapyco" >> release/deb/Release
191 echo "Architectures: all" >> release/deb/Release
192 echo "Description: HiYaPyCo Debian Repository" >> release/deb/Release
193 cd release/deb && apt-ftparchive release . >> Release
194 cd release/deb && \
195 gpg --clearsign --default-key $(GPGKEY) --use-agent -o InRelease Release && \
196 gpg -abs --default-key $(GPGKEY) --use-agent -o Release.gpg Release
197 gpg --verify release/deb/Release.gpg release/deb/Release
198 gpg --check-sigs InRelease Release
199
200 rpm: gpg-agent
201 mkdir -p release/rpm/noarch
202 python setup.py bdist_rpm --binary-only \
203 --doc-files README.rst --requires python-yaml,python-jinja2 \
204 -d release/rpm/noarch
205 for f in release/rpm/noarch/*.rpm; do \
206 echo "rpmsign $f ..."; \
207 rm -f $$f.sig; \
208 rpmsign \
209 -D "%__gpg_sign_cmd %{__gpg} gpg --batch --no-armor --use-agent --no-secmem-warning -u '\%{_gpg_name}' -sbo \%{__signature_filename} \%{__plaintext_filename}" \
210 -D "%__gpg_check_password_cmd /bin/true" \
211 --resign --key-id=$(GPGKEY) $$f; \
212 rpm --checksig --verbose $$f | grep -i $(GPGKEY); \
213 echo "rpmsign $f done"; \
214 done
215
216 rpmrepo: rpm
217 cd release/rpm; \
218 rm -fv repodata/repomd.xml*; \
219 createrepo_c . ; \
220 gpg --default-key $(GPGKEY) --use-agent -a --detach-sign repodata/repomd.xml; \
221 gpg -a --export $(KEY) > repodata/repomd.xml.key
222
223 tag:
224 @git pull --rebase --ff-only
225 @if [ -n "$$(git status --porcelain)" ]; then \
226 echo "uncommited changes"; \
227 git status --porcelain; \
228 false; \
229 fi
230 @if [ -n "$$(git log --branches --source --not --remotes --no-walk --oneline | awk '{print $2}' | grep \"$$(git branch --show-current)\")" ]; then \
231 echo "unpushed changes"; \
232 git log --branches --source --not --remotes --no-walk --oneline; \
233 false; \
234 fi
235 git tag -s "release-$(HIYAPYCOVERSION)" -m "version $(HIYAPYCOVERSION) released on $$(date -R)"
236
237 pushtag:
238 git push origin "release-$(HIYAPYCOVERSION)"
239
240 repo: debrepo rpmrepo
241
242 upload: uploadrepo pypiupload
243
244 uploadrepo: repo
245 scp -r release/* repo.zero-sys.net:/srv/www/repo.zero-sys.net/hiyapyco/
246
247 testversion: testdebversion testsetupversion testchangelogversion
248 testsetupversion:
249 @if $$(dpkg --compare-versions $$(python setup.py -V) lt $(HIYAPYCOVERSION)); then \
250 echo "setup.py version must be incremented to HIYAPYCOVERSION $(HIYAPYCOVERSION)"; \
251 false; \
252 fi
253
254 testdebversion:
255 @if $$(dpkg --compare-versions $$(dpkg-parsechangelog | sed '/^Version: /!d; s/^Version: \([.0-9]*\).*/\1/g') lt $(HIYAPYCOVERSION)); then \
256 echo "debian version must be incremented to HIYAPYCOVERSION $(HIYAPYCOVERSION)"; \
257 echo "run make dch --distribution stable --newversion $(HIYAPYCOVERSION)"; \
258 false; \
259 fi
260
261 testchangelogversion:
262 @if $$(dpkg --compare-versions $$(sed -e '/^Changelog$$/,+3!d' README.rst | sed '4!d') lt $(HIYAPYCOVERSION)); then \
263 echo "please add $(HIYAPYCOVERSION) section to the Changelog in README.rst"; \
264 false; \
265 fi
266
267 releasetest: distclean alltest testversion repo pypi
268 @echo "$@ done"
269 @echo "you may like to run $(MAKE) pypiuploadtest after this ..."
270 release: distclean alltest testversion tag upload pushtag
271 @echo "done $@ for version $(HIYAPYCOVERSION)"
272
273 all: releasetest release
274 @echo "done $@ for version $(HIYAPYCOVERSION)"
275