Skip to content

About

Embed CycloneDX SBOMs into Python distributions (PEP 770): a hatchling build hook plus a backend-agnostic CLI

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

python-sbom

python-sbom

PyPI Supported Python versions check Documentation Status Downloads OpenSSF Scorecard

Software bills of materials (SBOMs) for Python distributions. python-sbom writes a CycloneDX SBOM into every wheel you build, where PEP 770 (a Python Enhancement Proposal) tells installers to keep it. The SBOM records your project, the runtime dependencies it declares, any wheels it bundles, and the build toolchain, and a rebuild with the same inputs reproduces it byte for byte.

Use

python-sbom works with every build backend. Pick the integration for yours:

Backend Add to [build-system] requires Turn it on
hatchling python-sbom[hatch] [tool.hatch.build.hooks.python-sbom]
pdm-backend python-sbom[pdm] [tool.python-sbom]
setuptools python-sbom[setuptools] [tool.python-sbom]
any other, such as meson-python, maturin, scikit-build-core or flit-core python-sbom build-backend = "python_sbom.backend", and your backend in [tool.python-sbom]

With hatchling:

[build-system]
build-backend = "hatchling.build"
requires = ["hatchling>=1.28", "python-sbom[hatch]>=0.2"]

[tool.hatch.build.hooks.python-sbom]

With meson-python, or any backend without a plugin, python-sbom wraps it:

[build-system]
build-backend = "python_sbom.backend"
requires = ["meson-python>=0.18", "python-sbom>=0.2"]

[tool.python-sbom]
build-backend = "mesonpy"

For a wheel built outside the build interface, such as with maturin build, or renamed after it by auditwheel repair, embed the SBOM afterwards:

python-sbom embed dist/*.whl

To convert and validate SBOMs in continuous integration (CI), install the command line in a tool environment of its own with pipx or uv:

pipx install 'python-sbom[validate]'
python-sbom validate dist/

The documentation starts with a tutorial, then has a guide per backend, the options and commands, and how the SBOM is built. It also covers describing a zipapp, adding project knowledge through a content provider, and rendering an SBOM as SPDX (Software Package Data Exchange).

About

Embed CycloneDX SBOMs into Python distributions (PEP 770): a hatchling build hook plus a backend-agnostic CLI

Topics

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Used by

Contributors

Languages