-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile.pypi
38 lines (30 loc) · 1.33 KB
/
Makefile.pypi
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
# derived from name in setup.py
PYPI_NAME = $(shell python setup.py --name)
VERSION = $(shell python setup.py --version)
########## for uploading onto pypi
# updated in May 2020 to use twine for uploads
# run pip install twine if needed
# to initialize twine credentials
# keyring set upload.pypi.org parmentelat
# keyring set test.pypi.org parmentelat
VERSIONTAG = $(PYPI_NAME)-$(VERSION)
GIT-TAG-ALREADY-SET = $(shell git tag | grep '^$(VERSIONTAG)$$')
# to check for uncommitted changes
GIT-CHANGES = $(shell echo $$(git diff HEAD | wc -l))
# run this only once the sources are in on the right tag
pypi: twine cleanpypi
@if [ $(GIT-CHANGES) != 0 ]; then echo "You have uncommitted changes - cannot publish"; false; fi
@if [ -n "$(GIT-TAG-ALREADY-SET)" ] ; then echo "tag $(VERSIONTAG) already set"; false; fi
@if ! grep -q ' $(VERSION)' CHANGELOG.md ; then echo no mention of $(VERSION) in CHANGELOG.md; false; fi
@echo "You are about to release $(VERSION) - OK (Ctrl-c if not) ? " ; read _
git tag $(VERSIONTAG)
./setup.py sdist bdist_wheel
twine upload dist/*
twine:
@type -p twine >& /dev/null || { echo ==== installing twine; pip install twine; }
testpypi: cleanpypi
./setup.py sdist bdist_wheel
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
cleanpypi:
rm -rf build dist
.PHONY: pypi testpypi cleanpypi twine