hatch-prebuilt
Build Python wheels that install prebuilt executables unchanged, with
hatchling. pip install or uv pip install puts the executable
straight into the environment's bin/ (Scripts\ on Windows), with no Python wrapper in
between, so starting it costs nothing extra.
The cpp-linter wheel repositories use it:
ccache-wheel (ccache-bin),
llvm-cov-wheel (llvm-cov) and
clangd-wheel (clangd-bin).
What it does
A wheel repository describes its tool in hatch_build.py: which platforms it has, and how to
download and verify the files of one version for one platform. hatch-prebuilt does the rest:
- picks the version (from a version file, or an environment variable so CI can build older versions) and the platform (from an environment variable, or the build machine);
- checks that every executable is a binary for that platform: ELF machine and static linking, Mach-O architecture or universal slices, PE machine;
- works out the wheel tag, including the minimum macOS version the binaries declare;
- stages the license files where
license-filesfinds them, and gives hatchling the executables as shared scripts and any other files (man pages, headers) as shared data.
It also has the download helpers the recipes share: retrying downloads, a download cache, SHA-512
pins, minisign signatures (hatch-prebuilt[minisign]) and archive extraction.
A recipe
# hatch_build.py
from pathlib import Path
from hatch_prebuilt import Platform, Recipe, Staged, cached_download, check_sha512
URL = "https://example.com/mytool-{version}-{platform}{exe}"
SHA512 = {...}
class MyTool(Recipe):
name = "mytool"
version_file = "mytool_version.txt"
platform_variable = "MYTOOL_PLATFORM"
platforms = (
Platform(
"linux-x86_64",
"manylinux_2_17_x86_64.musllinux_1_1_x86_64",
"elf-x86_64",
"linux",
"x86_64",
),
Platform("macos-arm64", "macosx_{macos}_arm64", "macho-arm64", "macos", "arm64"),
Platform("windows-x86_64", "win_amd64", "pe-x86_64", "windows", "x86_64"),
)
def stage(self, platform, version):
url = URL.format(version=version, platform=platform.name, exe=platform.exe)
binary = cached_download(url, self.cache / Path(url).name)
check_sha512(binary, SHA512[platform.name], url)
return Staged(scripts={f"mytool{platform.exe}": binary}, licenses={"LICENSE": ...})
RECIPE = MyTool(Path(__file__).parent)
get_metadata_hook, get_build_hook = RECIPE.hooks()
if __name__ == "__main__":
raise SystemExit(RECIPE.main())
# pyproject.toml
[build-system]
requires = ["hatchling>=1.27", "hatch-prebuilt>=0.1,<1"]
build-backend = "hatchling.build"
[project]
name = "mytool-bin"
dynamic = ["version"]
license-files = ["upstream/LICENSE"]
[tool.hatch.metadata.hooks.custom]
[tool.hatch.build.targets.wheel]
bypass-selection = true
[tool.hatch.build.targets.wheel.hooks.custom]
Then python hatch_build.py platforms lists the platforms, and
MYTOOL_PLATFORM=<platform> python -m build --wheel builds one wheel, for any platform, on
Linux or macOS (Windows cannot give the executables their executable bit). The shared
binary-wheels.yml
workflow builds and tests all of them, and
templates/binary-wheel/
is a complete wheel repository to start from.
Tools from the
clang-tools-static-binaries
releases need even less: hatch_prebuilt.static_binaries.StaticBinariesRecipe knows the
platforms, the file names and the SHA-512 pins in sources.json, so the recipe only names the
tools.
Contributing
See the contributing guide.
uv run --group test pytest runs the tests.
License
Metadata
Release files for hatch-prebuilt 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hatch_prebuilt-0.1.0.tar.gz | 20.0 kB | With provenance | Details for hatch_prebuilt-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hatch_prebuilt-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for hatch_prebuilt-0.1.0-py3-none-any.whl |
Total release size: 35.2 kB
Release files / hatch_prebuilt-0.1.0.tar.gz
| Download URL | hatch_prebuilt-0.1.0.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
21dab2dde8603684bd4c4d73f94fbf0cfd73abf86ca3973993192e5441084d94
|
|
BLAKE2b-256 checksum How to use checksums |
0c5e9030707d2dea225fa44f561e9804ab992a65658f48f062f6f2cd4c18444c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / hatch_prebuilt-0.1.0-py3-none-any.whl
| Download URL | hatch_prebuilt-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e784fe185fa44e2594f9b0d5c8cf61e7eb7cf95c534a12b7c23ea95360a43a49
|
|
BLAKE2b-256 checksum How to use checksums |
59dc1142608e78271619def6b052b30eedcf30053d2c3a2bde89697c37f1680d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for hatch-prebuilt 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hatch_prebuilt-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.