Enable building sdist, wheel via python -m build
#6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows anyone to
python -m build
an sdist or wheel for Hancho.@aappleby In particular, if you ever decide to put hancho on PyPI, you should be able to use this config as-is.
Rationale
Making Hancho available on PyPI allows anyone to install and update Hancho via
pip install
or whatever dependency management system they like. This is mainly for people who prefer to keephancho.py
in a separate location on theirPATH
separately from their own development tree, and have it updatable viapip
.Having a PEP-517-conformant
pyproject.toml
also allows system package maintainers to package Hancho for their distribution with little modification.Design
To keep aligned to Hancho’s project mission, this particular
pyproject.toml
is specifically designed to lethancho.py
remain an independent standalone script in the project root.In other words, users will still be able to pick just the
hancho.py
file and copy it into their project development tree as-is, without caring aboutpyproject.toml
or anything else if they prefer so.How to use
To build an sdist and wheel, install PyPA’s build package first.
Then run:
To upload the resulting sdist and wheel to PyPI or TestPyPI, use their web front-end or Twine.
Or have a GitHub workflow publish Hancho on PyPI automatically every time you push a Git tag.
Implementation note
In case you wonder why I choose poetry-core as a build backend:
In contrast to other build backends like setuptools, which would have required
hancho.py
to go in a subdirectory that matches the package name, poetry-core supports building a package from a single-file*.py
module even if it lives in a project root directly, i.e. next topyproject.toml
.This is to make sure that
hancho.py
remains a portable, self-contained script that doesn’t require PyPI, pip, or anything else, and can be copied as-is anywhere you like.Example in the wild
One real-life example of a working system package using the Poetry backend is the
hancho
AUR package (PKGBUILD
,pyproject.toml
).Related issue
This PR addresses #1 if you choose so.