[image]
# 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:
```toml
[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:
```toml
[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:
```console
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]:
```console
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