Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable building sdist, wheel via python -m build #6

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

claui
Copy link
Contributor

@claui claui commented Mar 20, 2024

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 keep hancho.py in a separate location on their PATH separately from their own development tree, and have it updatable via pip.

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 let hancho.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 about pyproject.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:

python -m build

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 to pyproject.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.

claui added 2 commits March 20, 2024 12:45
This allows anyone to `python -m build` an sdist or wheel for Hancho.
In particular, if @aappleby decides to put hancho on PyPI, they 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 keep `hancho.py` in a
separate location on their `PATH` separately from their own development
tree, and have it updatable via `pip`.

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 let `hancho.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 about `pyproject.toml` or anything else if they prefer so.

Implementation note:

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 to
`pyproject.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.

One real-life example of a working system package using the Poetry
backend is the `hancho` AUR package. [1] [2] [3]

Addresses aappleby#1. [4]

[1]: https://aur.archlinux.org/packages/hancho

[2]: https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=hancho

[3]: https://aur.archlinux.org/cgit/aur.git/tree/pyproject.toml.template?h=hancho

[4]: aappleby#1
Publishing hancho on PyPI will display the
content of `README.md` directly on
https://pypi.org/project/hancho, which will break
relative links and result in a missing image.

Source the image from GitHub to make it work on
all hosts.
@claui claui mentioned this pull request Mar 20, 2024
@aappleby
Copy link
Owner

Nice! I was wondering how much work that would be - I'll merge it shortly.

@aappleby aappleby merged commit 99cc8a1 into aappleby:main Mar 22, 2024
@aappleby
Copy link
Owner

Merged.

@claui claui deleted the add-pep517-support branch March 22, 2024 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants