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 <newren@gmail.com>
pull/43/head
Elijah Newren 4 years ago
parent 6f4fc07d53
commit 525ecc8f8e

@ -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

@ -1 +0,0 @@
../git-filter-repo

@ -1 +0,0 @@
../git_filter_repo.py

@ -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"

@ -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

@ -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__))

Loading…
Cancel
Save