SBOMs for Python distributions: write PEP 770 CycloneDX SBOMs into wheels.
Maintained. Last release 13 days ago, commits in 4 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install python-sbomREADME as published on PyPI with version 0.5.0.
python-sbom
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).
License
python-sbom's own code is under the MIT license. The wheel
and source distribution also ship the schema files python-sbom validate checks documents against, unmodified from
CycloneDX/specification, under the
Apache-2.0 license. The
package metadata covers both, so its license expression is MIT AND Apache-2.0.