Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@ jobs:
{"env": "docs"},
{"env": "fix"},
{"env": "type"},
{"env": "pkg_meta"}
{"env": "pkg_meta"},
{"env": "example-cibuildwheel", "python": "3.15"},
{"env": "example-flit_core", "python": "3.15"},
{"env": "example-hatchling", "python": "3.15"},
{"env": "example-maturin", "python": "3.15"},
{"env": "example-meson_python", "python": "3.15"},
{"env": "example-pdm_backend", "python": "3.15"},
{"env": "example-poetry_core", "python": "3.15"},
{"env": "example-scikit_build_core", "python": "3.15"},
{"env": "example-setuptools", "python": "3.15"},
{"env": "example-uv_build", "python": "3.15"},
{"env": "example-zipapp", "python": "3.15"},
{"env": "example-delocate", "python": "3.15", "os": "macos-26"}
]
release:
name: 🏷️ Release dry run
Expand Down
2 changes: 1 addition & 1 deletion bench/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _stats_text(stats_file: Path) -> str:


def _hot_spots(name: str, stats_file: Path) -> str:
entries = pstats.Stats(str(stats_file)).stats # ty: ignore[unresolved-attribute] # the table pstats keeps is not in its stubs
entries = pstats.Stats(str(stats_file)).stats # ty: ignore[missing-attribute] # the table pstats keeps is not in its stubs
total = sum(entry[2] for entry in entries.values()) or 1.0
rows = [
(_label(function), entry[1], entry[0], entry[2], entry[3])
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.d/+maturin.doc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Give each build backend its own how-to page, under a new backends section, built around an example project whose build
and check the test suite runs, and add one for maturin projects: what maturin's SBOM and python-sbom's each hold, and
how to add python-sbom's when a build frontend, ``maturin build`` or maturin-action builds the wheel.
3 changes: 3 additions & 0 deletions docs/changelog.d/+other-sboms.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
A wheel's SBOM now links to every other file in its ``.dist-info/sboms`` directory, such as maturin's or
auditwheel's, by file name and SHA-256, and ``python-sbom validate`` also checks the ``.cyclonedx.json`` files maturin
writes.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def _inheritance_aliases() -> dict[str, str]:
"""
intersphinx_mapping: Final[dict[str, tuple[str, None]]] = {"python": ("https://docs.python.org/3.11", None)}
extlinks: Final[dict[str, tuple[str, str]]] = {
"example": ("https://github.com/tox-dev/python-sbom/tree/main/docs/examples/%s", "docs/examples/%s"),
"pr": ("https://github.com/tox-dev/python-sbom/pull/%s", "#%s"),
"user": ("https://github.com/%s", "@%s"),
}
Expand Down
5 changes: 5 additions & 0 deletions docs/examples/auditwheel/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project('greet', 'c', version: '1.0')

py = import('python').find_installation(pure: false)
py.extension_module('_greet', 'src/greet/_greet.c', install: true, subdir: 'greet', link_args: ['-l:libuuid.so.1'])
py.install_sources('src/greet/__init__.py', 'src/greet/cli.py', subdir: 'greet')
22 changes: 22 additions & 0 deletions docs/examples/auditwheel/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[build-system]
build-backend = "mesonpy"
requires = [ "meson>=1.6", "meson-python>=0.18", "ninja" ]

[project]
name = "greet"
version = "1.0"
description = "says hello"
license = "MIT"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
]
dependencies = [ "packaging>=24" ]

[tool.python-sbom]
supplier = { name = "You", url = [ "https://github.com/you" ] }
3 changes: 3 additions & 0 deletions docs/examples/auditwheel/session.console
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ cibuildwheel --only cp313-manylinux_x86_64 --output-dir wheelhouse
$ python-sbom embed wheelhouse/*.whl
wrote greet-1.0.dist-info/sboms/greet.cdx.json into greet-1.0-cp313-cp313-manylinux_2_28_x86_64.whl
1 change: 1 addition & 0 deletions docs/examples/auditwheel/src/greet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Say hello."""
16 changes: 16 additions & 0 deletions docs/examples/auditwheel/src/greet/_greet.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <Python.h>

/* from libuuid, which no manylinux policy allows a wheel to expect, so auditwheel copies it into the wheel */
void uuid_generate(unsigned char out[16]);

static PyObject *hello(PyObject *self, PyObject *args) {
unsigned char id[16];
uuid_generate(id);
return PyUnicode_FromFormat("hello %02x%02x", id[0], id[1]);
}

static PyMethodDef methods[] = {{"hello", hello, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL}};

static struct PyModuleDef module = {PyModuleDef_HEAD_INIT, "_greet", NULL, -1, methods};

PyMODINIT_FUNC PyInit__greet(void) { return PyModule_Create(&module); }
1 change: 1 addition & 0 deletions docs/examples/auditwheel/src/greet/_greet.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def hello() -> str: ...
9 changes: 9 additions & 0 deletions docs/examples/auditwheel/src/greet/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Print a greeting the C extension builds."""

from __future__ import annotations

from ._greet import hello


def main() -> None:
print(hello())
23 changes: 23 additions & 0 deletions docs/examples/flit-core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[build-system]
build-backend = "python_sbom.backend"
requires = [ "flit-core>=3.12", "python-sbom>=0.3" ]

[project]
name = "greet"
version = "1.0"
description = "says hello"
license = "MIT"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
]
dependencies = [ "packaging>=24" ]

[tool.python-sbom]
build-backend = "flit_core.buildapi"
supplier = { name = "You", url = [ "https://github.com/you" ] }
3 changes: 3 additions & 0 deletions docs/examples/flit-core/session.console
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ python -m build --wheel
$ python-sbom validate dist/
SBOM in greet-1.0-py3-none-any.whl is valid
1 change: 1 addition & 0 deletions docs/examples/flit-core/src/greet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Say hello."""
7 changes: 7 additions & 0 deletions docs/examples/flit-core/src/greet/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Print a greeting."""

from __future__ import annotations


def main() -> None:
print("hello")
3 changes: 3 additions & 0 deletions docs/examples/hatchling/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Copyright (c) 2026 You

MIT terms
27 changes: 27 additions & 0 deletions docs/examples/hatchling/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[build-system]
build-backend = "hatchling.build"
requires = [ "hatchling>=1.28", "python-sbom[hatch]>=0.3" ]

[project]
name = "greet"
version = "1.0"
description = "says hello"
license = "MIT"
license-files = [ "LICENSE" ]
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
]
dependencies = [ "packaging>=24" ]
urls.Source = "https://github.com/you/greet"

[tool.hatch]
build.hooks.python-sbom = {}

[tool.python-sbom]
supplier = { name = "You", url = [ "https://github.com/you" ] }
3 changes: 3 additions & 0 deletions docs/examples/hatchling/session.console
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ python -m build --wheel
$ python-sbom validate dist/
SBOM in greet-1.0-py3-none-any.whl is valid
1 change: 1 addition & 0 deletions docs/examples/hatchling/src/greet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Say hello."""
7 changes: 7 additions & 0 deletions docs/examples/hatchling/src/greet/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Print a greeting."""

from __future__ import annotations


def main() -> None:
print("hello")
4 changes: 4 additions & 0 deletions docs/examples/maturin/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
name = "greet"
version = "1.0.0"
edition = "2021"
26 changes: 26 additions & 0 deletions docs/examples/maturin/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[build-system]
build-backend = "python_sbom.backend"
requires = [ "maturin>=1.12,<2", "python-sbom>=0.3" ]

[project]
name = "greet"
version = "1.0"
description = "says hello"
license = "MIT"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
]
dependencies = [ "packaging>=24" ]

[tool.maturin]
bindings = "bin"

[tool.python-sbom]
build-backend = "maturin"
supplier = { name = "You", url = [ "https://github.com/you" ] }
5 changes: 5 additions & 0 deletions docs/examples/maturin/session-maturin-build.console
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$ maturin build --release --out dist
$ python-sbom embed dist/*.whl
wrote greet-1.0.dist-info/sboms/greet.cdx.json into greet-1.0-py3-none-manylinux_2_34_x86_64.whl
$ python-sbom validate dist/
SBOM in greet-1.0-py3-none-manylinux_2_34_x86_64.whl is valid
3 changes: 3 additions & 0 deletions docs/examples/maturin/session.console
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ python -m build --wheel
$ python-sbom validate dist/
SBOM in greet-1.0-py3-none-linux_x86_64.whl is valid
3 changes: 3 additions & 0 deletions docs/examples/maturin/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("hello");
}
5 changes: 5 additions & 0 deletions docs/examples/meson-python/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project('greet', 'c', version: '1.0')

py = import('python').find_installation(pure: false)
py.extension_module('_greet', 'src/greet/_greet.c', install: true, subdir: 'greet')
py.install_sources('src/greet/__init__.py', 'src/greet/cli.py', subdir: 'greet')
23 changes: 23 additions & 0 deletions docs/examples/meson-python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[build-system]
build-backend = "python_sbom.backend"
requires = [ "meson>=1.6", "meson-python>=0.18", "ninja", "python-sbom>=0.3" ]

[project]
name = "greet"
version = "1.0"
description = "says hello"
license = "MIT"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
]
dependencies = [ "packaging>=24" ]

[tool.python-sbom]
build-backend = "mesonpy"
supplier = { name = "You", url = [ "https://github.com/you" ] }
4 changes: 4 additions & 0 deletions docs/examples/meson-python/session-delocate.console
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$ python -m build --wheel
$ delocate-wheel --wheel-dir wheelhouse dist/*.whl
$ python-sbom embed wheelhouse/*.whl
wrote greet-1.0.dist-info/sboms/greet.cdx.json into greet-1.0-cp315-cp315-macosx_11_0_arm64.whl
3 changes: 3 additions & 0 deletions docs/examples/meson-python/session.console
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ python -m build --wheel
$ python-sbom validate dist/
SBOM in greet-1.0-cp315-cp315-linux_x86_64.whl is valid
1 change: 1 addition & 0 deletions docs/examples/meson-python/src/greet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Say hello."""
9 changes: 9 additions & 0 deletions docs/examples/meson-python/src/greet/_greet.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <Python.h>

static PyObject *hello(PyObject *self, PyObject *args) { return PyUnicode_FromString("hello"); }

static PyMethodDef methods[] = {{"hello", hello, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL}};

static struct PyModuleDef module = {PyModuleDef_HEAD_INIT, "_greet", NULL, -1, methods};

PyMODINIT_FUNC PyInit__greet(void) { return PyModule_Create(&module); }
1 change: 1 addition & 0 deletions docs/examples/meson-python/src/greet/_greet.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def hello() -> str: ...
9 changes: 9 additions & 0 deletions docs/examples/meson-python/src/greet/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Print a greeting the C extension builds."""

from __future__ import annotations

from ._greet import hello


def main() -> None:
print(hello())
22 changes: 22 additions & 0 deletions docs/examples/pdm-backend/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[build-system]
build-backend = "pdm.backend"
requires = [ "pdm-backend>=2.4", "python-sbom[pdm]>=0.3" ]

[project]
name = "greet"
version = "1.0"
description = "says hello"
license = "MIT"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
]
dependencies = [ "packaging>=24" ]

[tool.python-sbom]
supplier = { name = "You", url = [ "https://github.com/you" ] }
3 changes: 3 additions & 0 deletions docs/examples/pdm-backend/session.console
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ python -m build --wheel
$ python-sbom validate dist/
SBOM in greet-1.0-py3-none-any.whl is valid
1 change: 1 addition & 0 deletions docs/examples/pdm-backend/src/greet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Say hello."""
7 changes: 7 additions & 0 deletions docs/examples/pdm-backend/src/greet/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Print a greeting."""

from __future__ import annotations


def main() -> None:
print("hello")
23 changes: 23 additions & 0 deletions docs/examples/poetry-core/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[build-system]
build-backend = "python_sbom.backend"
requires = [ "poetry-core>=2", "python-sbom>=0.3" ]

[project]
name = "greet"
version = "1.0"
description = "says hello"
license = "MIT"
requires-python = ">=3.11"
classifiers = [
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
]
dependencies = [ "packaging>=24" ]

[tool.python-sbom]
build-backend = "poetry.core.masonry.api"
supplier = { name = "You", url = [ "https://github.com/you" ] }
3 changes: 3 additions & 0 deletions docs/examples/poetry-core/session.console
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ python -m build --wheel
$ python-sbom validate dist/
SBOM in greet-1.0-py3-none-any.whl is valid
1 change: 1 addition & 0 deletions docs/examples/poetry-core/src/greet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Say hello."""
7 changes: 7 additions & 0 deletions docs/examples/poetry-core/src/greet/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Print a greeting."""

from __future__ import annotations


def main() -> None:
print("hello")
6 changes: 6 additions & 0 deletions docs/examples/scikit-build-core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
cmake_minimum_required(VERSION 3.15...3.31)
project(${SKBUILD_PROJECT_NAME} LANGUAGES C)

find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
python_add_library(_greet MODULE src/greet/_greet.c WITH_SOABI)
install(TARGETS _greet DESTINATION greet)
Loading
Loading