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 using cyclonedx-py.
Usage
To use this plugin, you must configure your pyproject.toml to require both hatchling (>=1.28.0) and hatch-sbom in your build-system:
[build-system]
requires = ["hatchling>=1.28.0", "hatch-sbom"]
build-backend = "hatchling.build"
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, mapping to the respective cyclonedx-py commands:
requirements: Build an SBOM from Pip requirements. Thepathoption is optional; if omitted, the plugin will automatically look forrequirements.txt.poetry: Build an SBOM from a Poetry project. Thepathoption is optional and defaults to the current directory.pipenv: Build an SBOM from a Pipenv manifest. Thepathoption is optional and defaults to the current directory.environment: Build an SBOM from a Python environment. Thepathoption is optional and defaults to the current directory.uv: Build an SBOM usinguv export. Requires auv.lockfile. Thepathoption is optional and defaults to the current directory. Only supportsjsonformat and1.5spec-version.pdm: Build an SBOM usingpdm exportandcyclonedx-py. Requires apdm.lockfile. Thepathoption is optional and defaults to the current directory.
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.1.2.tar.gz.
File metadata
- Download URL: hatch_sbom-0.1.2.tar.gz
- Upload date:
- Size: 77.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84d56498080594265406746abcb80a7da8ffbc0b673440002725161e35636362
|
|
| MD5 |
88d0bf1931bea45414dc69348ba2fbe4
|
|
| BLAKE2b-256 |
86eb462d9476e2fba7e67a3798110810afa43267e90607b9352333691297c187
|
Provenance
The following attestation bundles were made for hatch_sbom-0.1.2.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.1.2.tar.gz -
Subject digest:
84d56498080594265406746abcb80a7da8ffbc0b673440002725161e35636362 - Sigstore transparency entry: 1395495012
- Sigstore integration time:
-
Permalink:
Ichunjo/hatch-sbom@b1a703419589a36d81128cd66f484683a255eb72 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Ichunjo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd-publish.yml@b1a703419589a36d81128cd66f484683a255eb72 -
Trigger Event:
push
-
Statement type:
File details
Details for the file hatch_sbom-0.1.2-py3-none-any.whl.
File metadata
- Download URL: hatch_sbom-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.1 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 |
850f4d59697a74c1959ea38ade073fe8c1b76af36a81ae2d328dcb108ee74a4f
|
|
| MD5 |
c98edc6175022777320f6c74835c02a8
|
|
| BLAKE2b-256 |
5f66cea06a556c12ed01c9bdb380ea26fd8ecea828268e2d2b1e5a03150ecd06
|
Provenance
The following attestation bundles were made for hatch_sbom-0.1.2-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.1.2-py3-none-any.whl -
Subject digest:
850f4d59697a74c1959ea38ade073fe8c1b76af36a81ae2d328dcb108ee74a4f - Sigstore transparency entry: 1395495184
- Sigstore integration time:
-
Permalink:
Ichunjo/hatch-sbom@b1a703419589a36d81128cd66f484683a255eb72 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Ichunjo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd-publish.yml@b1a703419589a36d81128cd66f484683a255eb72 -
Trigger Event:
push
-
Statement type: