Skip to content

About

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

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

python-sbom

PyPI Supported Python versions check Documentation Status Downloads OpenSSF Scorecard

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.

Install

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-sbom

To convert and validate SBOMs in CI, a separate tool environment is fine:

pipx install 'python-sbom[validate]'

Use

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/*.whl

Describe 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.

About

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

Resources

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages