Skip to content

Commit

Permalink
use Makefile.pypi from other projects
Browse files Browse the repository at this point in the history
  • Loading branch information
parmentelat committed Jun 4, 2020
1 parent 0d66941 commit 0d22c72
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
21 changes: 2 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,5 @@
LIBRARY = nbhosting

VERSION = $(shell python3 django/setup.py --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))

# we don't push to pypi, just set a release tag
release:
@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)' django/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 upload -r pypi

version:
@echo $(VERSION)
pypi:
$(MAKE) -C django pypi

####################
RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,)
Expand Down
35 changes: 35 additions & 0 deletions Makefile.pypi
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions django/Makefile

0 comments on commit 0d22c72

Please sign in to comment.