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 273 274 275
|
SHELL = /bin/bash
PYVERSIONS ?= $(shell py3versions -i)
PYVERSIONSPATHS = $(shell for PV in $(PYVERSIONS); do which $$PV; done)
TESTLOGLEVEL ?= WARN
.PHONY: test examples testinstall all
PYTHONPATH=$(shell pwd)
export PYTHONPATH
HIYAPYCOVERSION=$(shell PYTHONPATH=$(PYTHONPATH)/hiyapyco:$(PYTHONPATH) python -c 'from version import VERSION; print(VERSION)')
export GPGKEY=C9B1F13E67CAB37AE6D132134C2B4A1677DE7FB4
# FIXME: why this hack! w/ -p
DPKGBUILDPKGVERSION = $(shell dpkg-buildpackage --version | sed '1!d;s/^.* //g;s/\.$//g')
DPKGBUILDPKGSIGNARG = $(shell dpkg --compare-versions $DPKGBUILDPKGVERSION lt 1.17.26 && echo "-p'gpg --use-agent'")
pypiupload: PYPIREPO := pypi
pypiupload: PYPIREPOURL := https://pypi.python.org/pypi/HiYaPyCo
pypiuploadtest: PYPIREPO := pypitest
pypiuploadtest: PYPIREPOURL := https://test.pypi.org/project/HiYaPyCo/
quicktest: pylint test examples
# FIXME: testinstallvirtualenv fails due to jinja2 2.8 error w/ python3.2 but works w/ python3.4 ... WTF
alltest: clean quicktest testreadme testinstall testinstallvirtualenv
@echo "$@ passed"
printversions:
@echo -e "HIYAPYCOVERSION:\t$(HIYAPYCOVERSION)"
@echo -e "PYVERSIONS:\t\t$(PYVERSIONS)"
@echo -e "PYVERSIONSPATHS:\t$(PYVERSIONSPATHS)"
pylint:
pylint --disable=missing-module-docstring,unused-import,consider-using-with,unspecified-encoding,consider-using-f-string setup.py
@# FIXME: logging-not-lazy global-statement invalid-name
@# py3 only: raise-missing-from
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
testreadme:
# requires python3-restructuredtext-lint
rst-lint README.rst
test:
@RET=0; \
for p in $(PYVERSIONS); do \
echo "python version $$p"; \
for t in test/test_*.py; do \
$$p -t $$t -l $(TESTLOGLEVEL); \
RET=$$?; \
if [ $$RET -gt 0 ]; then break 2; fi; \
done; \
echo ""; \
done; \
exit $$RET
examples:
@RET=0; \
for p in $(PYVERSIONS); do \
echo "python version $$p"; \
for t in examples/*.py; do \
[ "$$t" = "examples/hiyapyco_example.py" ] && continue; \
[ "$$t" = "examples/issue73compareOrderedDict.py" ] && continue; \
echo "$$p -t $$t ..."; \
$$p -t $$t > /dev/null 2>&1; \
RET=$$?; \
if [ $$RET -gt 0 ]; then $$p -t $$t; break 2; fi; \
done; \
echo ""; \
done; \
exit $$RET
testinstall:
@set -e; \
for p in $(PYVERSIONS); do \
rm -rf /tmp/hiyapyco; \
echo ""; \
echo "$@ w/ python version $$p ..."; \
echo ""; \
$$p setup.py install --root=/tmp/hiyapyco; \
echo ""; \
echo "$@ w/ python version $$p : OK"; \
echo ""; \
done
testinstallvirtualenv:
@set -e; \
BASETMP=/tmp/hiyapyco; \
rm -rf $$BASETMP; \
for p in $(PYVERSIONSPATHS); do \
VENV=$$BASETMP/$$(basename $$p); \
mkdir -p $$VENV; \
echo "$@ w/ python version $$(basename $$p) in $$VENV ..."; \
virtualenv -p $$p $$VENV; \
source $$VENV/bin/activate; \
which python; \
python --version; \
python setup.py install; \
echo ""; \
echo " ... test install ..."; \
python -c 'import sys; from hiyapyco import __version__ as HIYAPYCOVERSION; print ("hiyapyco %s" % HIYAPYCOVERSION); print (sys.version)'; \
pip install -r test/requirements.txt; \
make test; \
make examples; \
deactivate; \
done
clean: distclean
distclean:
python setup.py clean
rm -rf release dist build HiYaPyCo.egg-info
find . -type f -name \*.pyc -exec rm -v {} \;
sdist:
python setup.py sdist
@echo "$@ done"
wheel:
# requires a 'sudo pip install wheel'
python setup.py bdist_wheel
@echo "$@ done"
twinecheckdist:
twine check dist/HiYaPyCo-*.tar.gz
@echo "$@ done"
pypi: sdist wheel twinecheckdist
@echo "$@ done"
pypiuploadtest: pypi pypiuploaddo
pypiupload: pypi pypiuploaddo
pypiuploaddo: pypi
# set use-agent in ~/.gnupg/gpg.conf to use the agent
rm -rf dist/HiYaPyCo-*.egg*
twine upload --verbose -s -i $(GPGKEY) -r $(PYPIREPO) dist/*
@echo "test the result at: $(PYPIREPOURL)"
gpg-agent:
@gpg-agent; \
RET=$$?; echo "gpg agent running: $$RET"; \
if [ $$RET -gt 0 ]; then \
gpg-agent; \
echo 'please run eval "eval $$(gpg-agent --daemon)"'; \
exit 1; \
fi
gpg-connect-agent 'keyinfo --list' /bye
dch-increment:
@# use this to increment the deb release number for a existing release
@DEBEMAIL=$$(git config --local --get user.email) \
DEBFULLNAME="Klaus Zerwes zero-sys.net" \
dch -i "new debian release"
@git diff debian/changelog
dch-version:
@# use this after updating hiyapyco/version.py
@if $$(dpkg --compare-versions $$(dpkg-parsechangelog | sed '/^Version: /!d; s/^Version: \([.0-9]*\).*/\1/g') lt $(HIYAPYCOVERSION)); then \
DEBEMAIL=$$(git config --local --get user.email) \
DEBFULLNAME="Klaus Zerwes zero-sys.net" \
dch -v $(HIYAPYCOVERSION)-1 -D stable "release version $(HIYAPYCOVERSION)"; \
git diff debian/changelog; \
else \
echo "nothing to do"; \
fi
debunsigned:
rm -rf release/deb/build
mkdir -p release/deb/build
tar cv -Sp --exclude=dist --exclude=build --exclude='*/.git*' -f - . | ( cd release/deb/build && tar x -Sp -f - )
cd release/deb/build && dpkg-buildpackage -b --no-sign
rm -rf release/deb/build
lintian release/deb/*.deb
deb: gpg-agent
rm -rf release/deb/build
mkdir -p release/deb/build
tar cv -Sp --exclude=dist --exclude=build --exclude='*/.git*' -f - . | ( cd release/deb/build && tar x -Sp -f - )
cd release/deb/build && dpkg-buildpackage -b -k$(GPGKEY) $(DPKGBUILDPKGSIGNARG)
gpg --verify release/deb/hiyapyco_*.changes
rm -rf release/deb/build
lintian release/deb/*.deb
debrepo: deb
cd release/deb && \
apt-ftparchive packages . > Packages && \
gzip -c Packages > Packages.gz && \
bzip2 -c Packages > Packages.bz2 && \
lzma -c Packages > Packages.lsma
echo "Suite: stable testing" >> release/deb/Release
echo "Origin: Klaus Zerwes zero-sys.net" >> release/deb/Release
echo "Label: hiyapyco" >> release/deb/Release
echo "Architectures: all" >> release/deb/Release
echo "Description: HiYaPyCo Debian Repository" >> release/deb/Release
cd release/deb && apt-ftparchive release . >> Release
cd release/deb && \
gpg --clearsign --default-key $(GPGKEY) --use-agent -o InRelease Release && \
gpg -abs --default-key $(GPGKEY) --use-agent -o Release.gpg Release
gpg --verify release/deb/Release.gpg release/deb/Release
gpg --check-sigs InRelease Release
rpm: gpg-agent
mkdir -p release/rpm/noarch
python setup.py bdist_rpm --binary-only \
--doc-files README.rst --requires python-yaml,python-jinja2 \
-d release/rpm/noarch
for f in release/rpm/noarch/*.rpm; do \
echo "rpmsign $f ..."; \
rm -f $$f.sig; \
rpmsign \
-D "%__gpg_sign_cmd %{__gpg} gpg --batch --no-armor --use-agent --no-secmem-warning -u '\%{_gpg_name}' -sbo \%{__signature_filename} \%{__plaintext_filename}" \
-D "%__gpg_check_password_cmd /bin/true" \
--resign --key-id=$(GPGKEY) $$f; \
rpm --checksig --verbose $$f | grep -i $(GPGKEY); \
echo "rpmsign $f done"; \
done
rpmrepo: rpm
cd release/rpm; \
rm -fv repodata/repomd.xml*; \
createrepo_c . ; \
gpg --default-key $(GPGKEY) --use-agent -a --detach-sign repodata/repomd.xml; \
gpg -a --export $(KEY) > repodata/repomd.xml.key
tag:
@git pull --rebase --ff-only
@if [ -n "$$(git status --porcelain)" ]; then \
echo "uncommited changes"; \
git status --porcelain; \
false; \
fi
@if [ -n "$$(git log --branches --source --not --remotes --no-walk --oneline | awk '{print $2}' | grep \"$$(git branch --show-current)\")" ]; then \
echo "unpushed changes"; \
git log --branches --source --not --remotes --no-walk --oneline; \
false; \
fi
git tag -s "release-$(HIYAPYCOVERSION)" -m "version $(HIYAPYCOVERSION) released on $$(date -R)"
pushtag:
git push origin "release-$(HIYAPYCOVERSION)"
repo: debrepo rpmrepo
upload: uploadrepo pypiupload
uploadrepo: repo
scp -r release/* repo.zero-sys.net:/srv/www/repo.zero-sys.net/hiyapyco/
testversion: testdebversion testsetupversion testchangelogversion
testsetupversion:
@if $$(dpkg --compare-versions $$(python setup.py -V) lt $(HIYAPYCOVERSION)); then \
echo "setup.py version must be incremented to HIYAPYCOVERSION $(HIYAPYCOVERSION)"; \
false; \
fi
testdebversion:
@if $$(dpkg --compare-versions $$(dpkg-parsechangelog | sed '/^Version: /!d; s/^Version: \([.0-9]*\).*/\1/g') lt $(HIYAPYCOVERSION)); then \
echo "debian version must be incremented to HIYAPYCOVERSION $(HIYAPYCOVERSION)"; \
echo "run make dch --distribution stable --newversion $(HIYAPYCOVERSION)"; \
false; \
fi
testchangelogversion:
@if $$(dpkg --compare-versions $$(sed -e '/^Changelog$$/,+3!d' README.rst | sed '4!d') lt $(HIYAPYCOVERSION)); then \
echo "please add $(HIYAPYCOVERSION) section to the Changelog in README.rst"; \
false; \
fi
releasetest: distclean alltest testversion repo pypi
@echo "$@ done"
@echo "you may like to run $(MAKE) pypiuploadtest after this ..."
release: distclean alltest testversion tag upload pushtag
@echo "done $@ for version $(HIYAPYCOVERSION)"
all: releasetest release
@echo "done $@ for version $(HIYAPYCOVERSION)"
|