Skip to content

Commit

Permalink
Add pyproject.toml to allow building sdist, wheel
Browse files Browse the repository at this point in the history
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
  • Loading branch information
claui committed Mar 20, 2024
1 parent 93441d9 commit bb22840
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ bin
obj
gen
build
dist
__pycache__
35 changes: 35 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[build-system]
requires = ["poetry-core>=1.9.0"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "hancho"
version = "0.0.5"
description = "A simple, pleasant build system"
license = "MIT"
authors = ["aappleby"]
readme = ["README.md", "docs/README.md"]
repository = "https://github.com/aappleby/hancho"
classifiers = [
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
"Topic :: Utilities",
]
include = [
{ path = "docs", format = "sdist" },
{ path = "tests", format = "sdist" },
{ path = "tutorial", format = "sdist" },
{ path = "examples", format = "sdist" },
]
exclude = ["**/.gitignore"]

[tool.poetry.dependencies]
python = "^3.10"

[tool.poetry.scripts]
hancho = "hancho:app.main"

[tool.poetry.urls]
"Additional documentation" = "https://github.com/aappleby/hancho/tree/main/docs#readme"
"Tutorial" = "https://github.com/aappleby/hancho/tree/main/tutorial#readme"
"Issue tracker" = "https://github.com/aappleby/hancho/issues"

0 comments on commit bb22840

Please sign in to comment.