From 93c567d88f551770e32c09c12117c50d6c223e14 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 13 May 2020 15:18:42 +0200 Subject: [PATCH] use sharable Makefile.pypi --- Makefile | 35 +---------------------------------- Makefile.pypi | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 34 deletions(-) create mode 100644 Makefile.pypi diff --git a/Makefile b/Makefile index 9f68071b..42187503 100644 --- a/Makefile +++ b/Makefile @@ -1,34 +1 @@ -########## for uploading onto pypi -# updated in May 2020 -# run pip install twine if needed -# I configured my login/password at pypi (both test and prod) -# using keyring (see https://pypi.org/project/twine/) - -LIBRARY = nbautoeval - -VERSION = $(shell python3 -c "from $(LIBRARY).version import __version__; print(__version__)") -VERSIONTAG = $(LIBRARY)-$(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: - @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/* - -# it can be convenient to define a test entry, say testpypi, in your .pypirc -# that points at the testpypi public site -# no upload to build.onelab.eu is done in this case -# try it out with -# pip install -i https://testpypi.python.org/pypi $(LIBRARY) -# dependencies need to be managed manually though -testpypi: - ./setup.py sdist bdist_wheel - twine upload --repository-url https://test.pypi.org/legacy/ dist/* - +include Makefile.pypi diff --git a/Makefile.pypi b/Makefile.pypi new file mode 100644 index 00000000..a848d810 --- /dev/null +++ b/Makefile.pypi @@ -0,0 +1,35 @@ +# 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: 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/* + +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