From 525ecc8f8eb0e98081c9911f2c456cfa47fa82fe Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 26 Dec 2019 10:43:24 -0800 Subject: [PATCH] release: tweak packaging scripts for uploading to PyPI Clean up the PyPI dist packages, remove unnecessary files, and streamline the release process: * Avoid adding extra unnecessary files to the repo; setup.py is code and can copy the necessary files into place. * Make sure README.md is included so we don't get an UNKNOWN Description field. * Add a long_description_content_type to avoid parsing errors on the README.md file and rejecting the upload. * Define the license and platform fields so they don't show up as UNKNOWN either. * Remove unnecessary pyproject.toml. This makes sense for most python projects, but since I already have a Makefile with installation rules (because I'm trying to be more compatible with git.git just in case we ever get merged into it), the pyproject.toml file is somewhat duplicative. Sure, the Makefile won't specify the exact versions needed but...meh. * Split the release target of the Makefile into github_release and pypi_release substeps, to allow them to be run semi-independently. Make the pypi_release run a few more steps for me. Signed-off-by: Elijah Newren --- Makefile | 26 +++++++++++++++++++------- release/git-filter-repo | 1 - release/git_filter_repo.py | 1 - release/pyproject.toml | 9 --------- release/setup.cfg | 3 +++ release/setup.py | 3 +++ 6 files changed, 25 insertions(+), 18 deletions(-) delete mode 120000 release/git-filter-repo delete mode 120000 release/git_filter_repo.py delete mode 100644 release/pyproject.toml diff --git a/Makefile b/Makefile index abd3cdd..3d8c442 100644 --- a/Makefile +++ b/Makefile @@ -78,10 +78,14 @@ update_docs: # Call like this: # make GITHUB_COM_TOKEN=$KEY TAGNAME=v2.23.0 release -release: export FILEBASE=git-filter-repo-$(shell echo $(TAGNAME) | tail -c +2) -release: export GIT_INDEX_FILE=$(shell mktemp) -release: export COMMIT=$(shell git rev-parse HEAD) -release: update_docs +release: github_release pypi_release + +# Call like this: +# make GITHUB_COM_TOKEN=$KEY TAGNAME=v2.23.0 github_release +github_release: export FILEBASE=git-filter-repo-$(shell echo $(TAGNAME) | tail -c +2) +github_release: export GIT_INDEX_FILE=$(shell mktemp) +github_release: export COMMIT=$(shell git rev-parse HEAD) +github_release: update_docs test -n "$(GITHUB_COM_TOKEN)" test -n "$(TAGNAME)" test -n "$$COMMIT" @@ -110,13 +114,21 @@ release: update_docs cat asset_id | xargs -I ASSET_ID curl -s -H "Authorization: token $(GITHUB_COM_TOKEN)" -H "Content-Type: application/octet-stream" --data-binary @$(FILEBASE).tar.xz https://uploads.github.com/repos/newren/git-filter-repo/releases/ASSET_ID/assets?name=$(FILEBASE).tar.xz # Remove temporary file(s) rm asset_id - # Upload to PyPI, automatically picking up the new tag - cd release && python3 setup.py sdist bdist_wheel - twine upload release/dist/* # Notify of completion @echo @echo === filter-repo $(TAGNAME) created and uploaded to GitHub === +pypi_release: # Has an implicit dependency on github_release because... + # Upload to PyPI, automatically picking tag created by github_release + cd release && python3 -m venv venv + cd release && venv/bin/pip3 install --upgrade setuptools pip + cd release && venv/bin/pip3 install twine wheel + cd release && venv/bin/python3 setup.py sdist bdist_wheel + cd release && venv/bin/twine upload dist/* + # Remove temporary file(s) + cd release && rm -f README.md git-filter-repo git_filter_repo.py + cd release && rm -rf .eggs/ build/ venv/ git_filter_repo.egg-info/ + # NOTE TO FUTURE SELF: If you accidentally push a bad release, you can remove # all but the git-filter-repo-$VERSION.tar.xz asset with # git push --delete origin $TAGNAME diff --git a/release/git-filter-repo b/release/git-filter-repo deleted file mode 120000 index ac3b52f..0000000 --- a/release/git-filter-repo +++ /dev/null @@ -1 +0,0 @@ -../git-filter-repo \ No newline at end of file diff --git a/release/git_filter_repo.py b/release/git_filter_repo.py deleted file mode 120000 index 451182e..0000000 --- a/release/git_filter_repo.py +++ /dev/null @@ -1 +0,0 @@ -../git_filter_repo.py \ No newline at end of file diff --git a/release/pyproject.toml b/release/pyproject.toml deleted file mode 100644 index 23bb041..0000000 --- a/release/pyproject.toml +++ /dev/null @@ -1,9 +0,0 @@ -[build-system] -requires = [ - # The minimum setuptools version is specific to the PEP 517 backend, - # and may be stricter than the version required in `setup.py` - "setuptools>=40.6.0", - "setuptools_scm", - "wheel", -] -build-backend = "setuptools.build_meta" diff --git a/release/setup.cfg b/release/setup.cfg index c6da423..078f3ff 100644 --- a/release/setup.cfg +++ b/release/setup.cfg @@ -6,6 +6,7 @@ project_urls = Issues = https://github.com/newren/git-filter-repo/issues/ description = Quickly rewrite git repository history long_description = file: README.md +long_description_content_type = text/markdown classifiers = Development Status :: 4 - Beta Operating System :: OS Independent @@ -18,6 +19,8 @@ classifiers = Programming Language :: Python :: 3 Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: PyPy +platforms = any +license = MIT [options] scripts = git-filter-repo diff --git a/release/setup.py b/release/setup.py index 557aa07..ce60b2c 100644 --- a/release/setup.py +++ b/release/setup.py @@ -1,2 +1,5 @@ from setuptools import setup +import os +for f in ['git-filter-repo', 'git_filter_repo.py', 'README.md']: + os.symlink("../"+f, f) setup(use_scm_version=dict(root="..", relative_to=__file__))