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, @aappleby should be able to use this config as-is if
they choose to publish Hancho on PyPI.

The original `hancho.py` remains standalone and independent, and can
still be copied into project development trees as-is. If @aappleby puts
hancho on PyPI, anyone will be able to install and update hancho via
`pip install` or whatever dependency management system they like.
It also helps system package maintainers to package Hancho for their
distribution with little modification.

As a PEP 517 build backend, I suggest poetry-core rather than setuptools
because poetry-core specifically supports packaging single-file `*.py`
modules that live in a project root directly, while the setuptools
backend would have required a subdirectory. This makes sure that
`hancho.py` remains a portable, self-contained script that doesn’t
require PyPI, pip, or anything else, and can be copied 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 fa647b6
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 fa647b6

Please sign in to comment.