Skip to main content
Change of provenance

The repository or configuration that created this release differ from a previous release. View details.

hatch-prebuilt

PyPI ci part of cpp-linter

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.

A tool that finds its own files through the path of its executable, such as clang's builtin headers in ../lib/clang/<major>/include, sets package in its recipe instead. The wheel then keeps the executable and its files together in that Python package, and a small console script starts the executable (os.execv on Linux and macOS). That way the tool finds its files however it is installed, including uv tool install and pip install --user on Windows, which put the scripts away from the environment's other files. pyproject.toml then lists scripts in project.dynamic.

The cpp-linter wheel repositories use it: ccache-wheel (ccache-bin), clang-apply-replacements, clang-include-cleaner, llvm-cov-wheel (llvm-cov) and clangd-wheel (clangd-bin).

Tools from the static binaries: pyproject.toml only

For a tool from the clang-tools-static-binaries releases, pyproject.toml is the whole recipe. hatch-prebuilt already knows the platforms, the file names and the SHA-512 pins in sources.json:

# pyproject.toml
[build-system]
requires = ["hatchling>=1.27", "hatch-prebuilt>=0.3,<1"]
build-backend = "hatchling.build"

[project]
name = "clang-include-cleaner"
dynamic = ["version", "scripts"]
license-files = ["upstream/LICENSE.TXT"]

[tool.hatch.metadata.hooks.prebuilt]
recipe = "static-binaries"
tools = ["clang-include-cleaner"]
resource-headers = true  # clang's builtin headers, for clangd and clang-include-cleaner

[tool.hatch.build.targets.wheel]
bypass-selection = true

[tool.hatch.build.targets.wheel.hooks.prebuilt]
Option Default Meaning
recipe static-binaries Where the files come from
tools (required) The executables to package
name the first tool The name in messages
resource-headers false Add clang's builtin headers and keep the tools with them in a package
package the first tool, _ for - That package's name, when another project uses the default one
min-major 12 The oldest LLVM major version that update adds to sources.json

The version comes from llvm_version.txt, or LLVM_VERSION when it is set, and the platform from LLVM_PLATFORM, or the build machine:

python -m hatch_prebuilt update      # add new LLVM releases to sources.json
python -m hatch_prebuilt versions    # the versions in sources.json
python -m hatch_prebuilt platforms   # the platforms to build
python -m hatch_prebuilt info        # what CI needs, as JSON
LLVM_VERSION=22.1.8 LLVM_PLATFORM=windows-amd64 python -m build --wheel

Other tools: a recipe in hatch_build.py

A tool with its own upstream releases describes them 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-files finds 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.

# 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.3,<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 -m hatch_prebuilt platforms (or 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).

In CI

The shared binary-wheels.yml workflow builds and tests every wheel. The runbooks next to it in cpp-linter/wheels say how to start a new wheel repository and how releases work.

Contributing

See the contributing guide. uv run --directory hatch-prebuilt --group test pytest runs the tests.

License

MIT

Metadata

Release files for hatch-prebuilt 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Change of provenance

The repository or configuration that created these release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Source distribution (sdist)

Source distribution for hatch-prebuilt 0.3.0
File Size Uploaded Provenance Actions
hatch_prebuilt-0.3.0.tar.gz 24.9 kB With provenance Details for hatch_prebuilt-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hatch-prebuilt 0.3.0
File Interpreter ABI Platform Actions
hatch_prebuilt-0.3.0-py3-none-any.whl Python 3 none any Details for hatch_prebuilt-0.3.0-py3-none-any.whl

Total release size: 46.7 kB

Release files / hatch_prebuilt-0.3.0.tar.gz

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL hatch_prebuilt-0.3.0.tar.gz
Size 24.9 kB
Tags Source
SHA-256 checksum
How to use checksums
252e5b7b604492635e4f1dbdc926c87fdf7b7643c540234ca33497927d010eb5
BLAKE2b-256 checksum
How to use checksums
4ae7fbe27e47c7105ff6a7978ed2d9505a8cfec822d57ea1f70241c6e1d917e9
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 log

Release files / hatch_prebuilt-0.3.0-py3-none-any.whl

Change of provenance

This file belongs to a release with changed provenance: the repository or configuration that created the release files differ from that of a previous release.

We recommend inspecting the repository and configuration before proceeding. View details.

Download URL hatch_prebuilt-0.3.0-py3-none-any.whl
Size 21.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8580d14b369d23f394468346371afc09c473c072cc0fc6639ead1d7de9bcf492
BLAKE2b-256 checksum
How to use checksums
042ec114d623c4230ba726cad10316b7f7d2bbe2812e81e33aa57e6726d047ad
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 log

Security for hatch-prebuilt 0.3.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.

Change of provenance

The repository and configuration that created this release differ from a previous release.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Select from 2 files

Attestation for hatch_prebuilt-0.3.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 log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page