Skip to main content

py-generator-build-backend

A Python build backend designed to wrap Python package generators (such as openapi-python-client) into a PEP 517 compatible source tree.

Demo

Create a new directory with a pyproject.toml:

[project]
name = "tictactoe-client"
dynamic = [
    "version",
    "dependencies",
]

[build-system]
requires = [
    "py-generator-build-backend",
]
build-backend = "py_generator_build_backend"

[tools.py-generator-build-backend]
generator = "openapi-python-client generate --url https://raw.githubusercontent.com/OAI/learn.openapis.org/refs/heads/main/examples/v3.1/tictactoe.json --output-path $GENERATOR_OUT_PATH"

The tools.py-generator-build-backend.generator is the key to making this work: this command must produce a valid PEP 517 source tree in the (not-yet-existent) directory specified by the $GENERATOR_OUT_PATH environment variable. You can interpolate other environment variables in generator if you need to.

Note: you are responsible for making sure the command you want to run is available on the PATH.

Now try to build the package: python -m build .. This should fail to build, with instructions about the build requirements you need to add to your build-system.requires. Add them and confirm that you are now able to build the package.

Congratulations, you've got a Python package! See Packaging Python Projects for possible next steps.

Notes

For performance reasons, the output of the generator is cached in platformdirs.user_cache_dir. We compute the cache entry by hashing together the contents of the entire project directory, along with all environment variables. This does a pretty good job of capturing all the "inputs" that go into generating the package, but it's not perfect: the generator could be non-deterministic, or packages could be updated in the PATH. If you care about things like this, consider adopting a hermetic build tool such as nix.

(Ideally we'd have access to a scratch space that only lives as long as the build frontend is invoking this build backend, but as far as I can tell, there's no standardized mechanism for that.)

Development

Releasing

  • Edit version in pyproject.toml, and commit.
  • uv build
  • git tag v...
  • uv publish
  • git push --tags

Metadata

Release files for py-generator-build-backend 1.1.0

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

Source distribution (sdist)

Source distribution for py-generator-build-backend 1.1.0
File Size Uploaded Provenance Actions
py_generator_build_backend-1.1.0.tar.gz 8.0 kB Without provenance Details for py_generator_build_backend-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-generator-build-backend 1.1.0
File Interpreter ABI Platform Actions
py_generator_build_backend-1.1.0-py3-none-any.whl Python 3 none any Details for py_generator_build_backend-1.1.0-py3-none-any.whl

Total release size: 13.4 kB

Release files / py_generator_build_backend-1.1.0.tar.gz

Download URL py_generator_build_backend-1.1.0.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2bdc1bb3aa633f92a27d39e7bfe8abc029975d1a937bac8284daa1ee11bcde6c
BLAKE2b-256 checksum
How to use checksums
602ef317679652206b7fecf464d89b4f0f3c7f7546cb6793dc4fb2b83d32a44b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.19

Release files / py_generator_build_backend-1.1.0-py3-none-any.whl

Download URL py_generator_build_backend-1.1.0-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9da2cd867271837ba22b4e3fe719743b4f8e0ba832f75427079bdfdba8ebe1a
BLAKE2b-256 checksum
How to use checksums
ac45ecf0bb133d2d9edca9feefe0f3bcd647c88608fe97a6c134e33dcbe79672
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.7.19

Security for py-generator-build-backend 1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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