Hatchling build hook plugin for generating Software Bill of Materials (SBOM)
Project description
hatch-sbom
A Hatchling build hook plugin to automatically generate a Software Bill of Materials (SBOM) during wheel creation.
Usage
To use this plugin, configure your pyproject.toml to require both hatchling (>=1.28.0) and hatch-sbom in your build-system.
For a requirements.txt SBOM:
[build-system]
requires = ["hatchling>=1.28.0", "hatch-sbom[cdx]"]
build-backend = "hatchling.build"
The base install is minimal. Install extras only for the backend used by your selected source:
requirements,poetry,pipenv, andenvironmentusecyclonedx-pyand needhatch-sbom[cdx].uvusesuv exportdirectly and needshatch-sbom[uv].pdmuses bothpdm exportandcyclonedx-py, so it needshatch-sbom[pdm,cdx].
Next, configure the build hook specifically for the wheel target:
[tool.hatch.build.targets.wheel.hooks.sbom]
source = "requirements"
path = "requirements.txt"
format = "json" # Optional, defaults to "json"
spec-version = "1.6" # Optional, defaults to "1.6"
Supported Sources
The source field determines how the SBOM is built.
| Source | Requires | Backend | Path behavior |
|---|---|---|---|
requirements |
hatch-sbom[cdx] |
cyclonedx-py requirements |
Optional; defaults to requirements.txt when present. |
poetry |
hatch-sbom[cdx] |
cyclonedx-py poetry |
Optional; defaults to the current directory. |
pipenv |
hatch-sbom[cdx] |
cyclonedx-py pipenv |
Optional; defaults to the current directory. |
environment |
hatch-sbom[cdx] |
cyclonedx-py environment |
Optional; defaults to the current directory. |
uv |
hatch-sbom[uv] |
uv export |
Optional; defaults to the current directory. Requires uv.lock. |
pdm |
hatch-sbom[pdm,cdx] |
pdm export, then cyclonedx-py requirements |
Optional; defaults to the current directory. Requires pdm.lock. |
The uv source only supports json format and CycloneDX 1.5.
Source-Specific Arguments
You can pass extra arguments to the underlying tool (e.g., uv export, pdm export, or cyclonedx-py <source>) by creating a nested table named after the source.
This is useful for passing flags like --without, --no-dev, etc.
For example, to omit the dev and test groups when using Poetry:
[tool.hatch.build.targets.wheel.hooks.sbom.poetry]
without = ["dev", "test"] # Appends `--without dev --without test`
To include all extras when using uv:
[tool.hatch.build.targets.wheel.hooks.sbom.uv]
all-extras = true # Appends `--all-extras`
You can use the extra-args key to pass an arbitrary list of raw arguments:
[tool.hatch.build.targets.wheel.hooks.sbom.pipenv]
extra-args = ["--mc-type", "firmware"]
The generated SBOM file (e.g., sbom.cdx.json) will be automatically placed in the .dist-info/sboms/ directory of the resulting wheel.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hatch_sbom-0.3.0.tar.gz.
File metadata
- Download URL: hatch_sbom-0.3.0.tar.gz
- Upload date:
- Size: 78.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
931320149777195bbdb604fb8fbf987131e1d6a42128c758b4e757dc3602449f
|
|
| MD5 |
8fd72d4dfb263c4ba658ec1ab68802c7
|
|
| BLAKE2b-256 |
407bfb4fdfbd56ec495e853740a8ed07613ba387185c5abb2993e91b5bdedc45
|
Provenance
The following attestation bundles were made for hatch_sbom-0.3.0.tar.gz:
Publisher:
cd-publish.yml on Ichunjo/hatch-sbom
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hatch_sbom-0.3.0.tar.gz -
Subject digest:
931320149777195bbdb604fb8fbf987131e1d6a42128c758b4e757dc3602449f - Sigstore transparency entry: 1397484446
- Sigstore integration time:
-
Permalink:
Ichunjo/hatch-sbom@eeaf496a1082361a2aa983fd8a6b14a091e6c7f8 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Ichunjo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd-publish.yml@eeaf496a1082361a2aa983fd8a6b14a091e6c7f8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hatch_sbom-0.3.0-py3-none-any.whl.
File metadata
- Download URL: hatch_sbom-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbc01dd927a7235086ebb96618bdf91e2ac777348bcd89d64e7f2cab3a26f271
|
|
| MD5 |
4b5d6e175c3988c7012318c0acdbbe02
|
|
| BLAKE2b-256 |
4dd43e64bbfa13ba04105719fbea41aee8a577c963151cdab916caf42e92b22e
|
Provenance
The following attestation bundles were made for hatch_sbom-0.3.0-py3-none-any.whl:
Publisher:
cd-publish.yml on Ichunjo/hatch-sbom
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hatch_sbom-0.3.0-py3-none-any.whl -
Subject digest:
bbc01dd927a7235086ebb96618bdf91e2ac777348bcd89d64e7f2cab3a26f271 - Sigstore transparency entry: 1397484470
- Sigstore integration time:
-
Permalink:
Ichunjo/hatch-sbom@eeaf496a1082361a2aa983fd8a6b14a091e6c7f8 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/Ichunjo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd-publish.yml@eeaf496a1082361a2aa983fd8a6b14a091e6c7f8 -
Trigger Event:
push
-
Statement type: