SBOMs for Python distributions. python-sbom writes a CycloneDX SBOM into every wheel you build, where PEP 770 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.
A hatchling project names python-sbom[hatch] in its build requirements, as shown below. To embed an SBOM into a wheel
another backend built, install the command line into the environment that built the wheel, since the SBOM lists that
environment's packages as the build tools (or point --build-env at it):
python -m pip install python-sbomTo convert and validate SBOMs in CI, a separate tool environment is fine:
pipx install 'python-sbom[validate]'With hatchling, add the hook to the build requirements and enable it:
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling>=1.28", "python-sbom[hatch]>=0.1"]
[tool.hatch.build.hooks.python-sbom]With another build backend, such as meson-python, embed the SBOM after the build:
python-sbom embed dist/*.whlDescribe another zip archive the project publishes, such as a zipapp, with python-sbom archive. The
documentation covers the options, adding project knowledge through a content
provider, rendering an SBOM as SPDX and validating it.