From f81a15224113a6854a03f1196f91fbb2e52614cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 14:16:22 -0800 Subject: [PATCH 01/11] =?UTF-8?q?=E2=9C=A8=20feat(sbom):=20link=20and=20ch?= =?UTF-8?q?eck=20other=20tools'=20SBOMs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.d/+other-sboms.feature.rst | 3 +++ docs/how-to/built-elsewhere.rst | 3 ++- docs/how-to/other-backends.rst | 1 + docs/how-to/validate.rst | 3 ++- src/python_sbom/_collect/_wheel.py | 11 +++++++++- src/python_sbom/_model/_inputs.py | 7 ++++--- src/python_sbom/_model/_types.py | 2 ++ src/python_sbom/_model/_wheel.py | 16 ++++++++++++++- src/python_sbom/_validate/_artifact.py | 7 +++++-- tests/_generate/test_embed.py | 25 +++++++++++++++++++++++ tests/_validate/test_artifact.py | 18 ++++++++++++++++ tests/conftest.py | 3 +++ 12 files changed, 90 insertions(+), 9 deletions(-) create mode 100644 docs/changelog.d/+other-sboms.feature.rst diff --git a/docs/changelog.d/+other-sboms.feature.rst b/docs/changelog.d/+other-sboms.feature.rst new file mode 100644 index 0000000..14541e4 --- /dev/null +++ b/docs/changelog.d/+other-sboms.feature.rst @@ -0,0 +1,3 @@ +A wheel's SBOM now links to every other SBOM 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. diff --git a/docs/how-to/built-elsewhere.rst b/docs/how-to/built-elsewhere.rst index c246cda..e237d6c 100644 --- a/docs/how-to/built-elsewhere.rst +++ b/docs/how-to/built-elsewhere.rst @@ -52,7 +52,8 @@ Run ``embed`` on the repaired wheel, so the SBOM names the file you publish: $ auditwheel repair dist/*.whl --wheel-dir wheelhouse $ python-sbom embed wheelhouse/*.whl -auditwheel_'s own SBOM, ``auditwheel.cdx.json``, stays in the wheel next to python-sbom's. +auditwheel_'s own SBOM, ``auditwheel.cdx.json``, stays in the wheel next to python-sbom's, which links to it by its file +name and SHA-256. ************************** Name the source revision diff --git a/docs/how-to/other-backends.rst b/docs/how-to/other-backends.rst index c479f08..6ff0b0c 100644 --- a/docs/how-to/other-backends.rst +++ b/docs/how-to/other-backends.rst @@ -66,6 +66,7 @@ maturin's own SBOM `maturin writes a CycloneDX SBOM `_ of the Rust crates a wheel links, as ``.cyclonedx.json``. :term:`PEP 770` allows several SBOMs per wheel, so python-sbom's ``.cdx.json`` sits next to it: maturin's lists the crates, python-sbom's the wheel's files, metadata, build tools and source revision. +python-sbom's links to maturin's by its file name and SHA-256, so a reader of one finds the other. *********************************************** Pitfall: builds that skip the build interface diff --git a/docs/how-to/validate.rst b/docs/how-to/validate.rst index e41b556..d81fb0b 100644 --- a/docs/how-to/validate.rst +++ b/docs/how-to/validate.rst @@ -20,7 +20,8 @@ also catches a build that lost the plugin. Every SBOM gets the CycloneDX 1.6 schema check. For the SBOM python-sbom wrote, it also requires the ``urn:uuid`` serial number `actions/attest`_ needs to recognize the format, checks that every reference resolves, and validates the -:term:`SPDX` rendering. An SBOM another tool wrote, such as auditwheel_'s or maturin_'s, gets the schema check alone. +:term:`SPDX` rendering. An SBOM another tool wrote, such as auditwheel_'s ``auditwheel.cdx.json`` or maturin_'s +``.cyclonedx.json``, gets the schema check alone. ************************************** Limit the licenses of bundled wheels diff --git a/src/python_sbom/_collect/_wheel.py b/src/python_sbom/_collect/_wheel.py index 3a0fbd0..1fcd29f 100644 --- a/src/python_sbom/_collect/_wheel.py +++ b/src/python_sbom/_collect/_wheel.py @@ -4,6 +4,7 @@ from python_sbom._errors import SbomError from python_sbom._model._inputs import WheelTree +from python_sbom._model._names import sbom_file_name from python_sbom._wheel._zip import read_wheel_metadata from ._source import copyright_notice, file_sha256, hash_build_scripts, selected_wheels @@ -19,13 +20,21 @@ def read_wheel( artifact: ArtifactReader, root: Path, settings: Settings, build_scripts: Iterable[PurePosixPath] ) -> WheelTree: - _, metadata = read_wheel_metadata(artifact.archive, str(artifact.path)) + wheel, metadata = read_wheel_metadata(artifact.archive, str(artifact.path)) + sboms = f"{wheel.dist_info_dir}/sboms/" + ours = f"{sboms}{sbom_file_name(metadata.name)}" return WheelTree( name=artifact.path.name, metadata=metadata, copyright=copyright_notice(root, metadata.values("license_files")), bundled=artifact.bundled_wheels(_shipped_copies(root, settings, artifact)), build_scripts=hash_build_scripts(root, build_scripts), + # maturin, auditwheel and others write their own, which a reader of ours should be able to find + other_sboms={ + name.removeprefix(sboms): artifact.digest(name) + for name in sorted(artifact.members) + if name.startswith(sboms) and not name.endswith("/") and name != ours + }, ) diff --git a/src/python_sbom/_model/_inputs.py b/src/python_sbom/_model/_inputs.py index 3f9652c..bba88b4 100644 --- a/src/python_sbom/_model/_inputs.py +++ b/src/python_sbom/_model/_inputs.py @@ -119,14 +119,15 @@ class Artifact: @dataclass(frozen=True, slots=True, kw_only=True) class WheelTree: - # what a built wheel holds, read from the wheel without unpacking it: its file name, its core metadata and the - # wheels it bundles; and what the project adds: the copyright line of its license files and the scripts that built - # it + # what a built wheel holds, read from the wheel without unpacking it: its file name, its core metadata, the wheels + # it bundles and the SHA-256 of each SBOM another tool put next to ours, by its path under the sboms directory; and + # what the project adds: the copyright line of its license files and the scripts that built it name: str metadata: CoreMetadata copyright: str | None bundled: list[BundledWheel] build_scripts: list[BuildScript] + other_sboms: dict[str, str] __all__ = [ diff --git a/src/python_sbom/_model/_types.py b/src/python_sbom/_model/_types.py index c0f524c..242ea52 100644 --- a/src/python_sbom/_model/_types.py +++ b/src/python_sbom/_model/_types.py @@ -66,12 +66,14 @@ class ExternalReference(TypedDict): :ivar type: the CycloneDX reference type, such as ``vcs`` or ``website`` :ivar url: the link :ivar comment: what the link is, such as the Project-URL label it came from + :ivar hashes: digests of what the link points at """ type: str url: str comment: NotRequired[str] + hashes: NotRequired[list[Hash]] class LicenseInfo(TypedDict): diff --git a/src/python_sbom/_model/_wheel.py b/src/python_sbom/_model/_wheel.py index 9a46b18..ce24f81 100644 --- a/src/python_sbom/_model/_wheel.py +++ b/src/python_sbom/_model/_wheel.py @@ -1,7 +1,9 @@ from __future__ import annotations +from itertools import starmap from pathlib import PurePosixPath from typing import TYPE_CHECKING, Final +from urllib.parse import quote from packaging.requirements import Requirement @@ -16,7 +18,7 @@ from ._content import BundledWheelInfo from ._identity import ProjectIdentity from ._inputs import Settings, WheelTree - from ._types import Component + from ._types import Component, ExternalReference def wheel_artifact( @@ -33,6 +35,7 @@ def wheel_artifact( *root["externalReferences"], {"type": "distribution", "url": pypi_url(name, version)}, {"type": "attestation", "url": f"https://pypi.org/integrity/{name}/{version}/{tree.name}/provenance"}, + *starmap(_other_sbom, tree.other_sboms.items()), ] return Artifact( root=root, @@ -56,6 +59,17 @@ def wheel_artifact( ) +def _other_sbom(path: str, digest: str) -> ExternalReference: + # relative to this SBOM, which sits in the same directory; quoting keeps a colon in the name from reading as a + # scheme + return { + "type": "bom", + "url": quote(path), + "comment": "another SBOM of this wheel, which a different tool wrote", + "hashes": [{"alg": "SHA-256", "content": digest}], + } + + def _declared_dependency(text: str, requirement: Requirement, property_prefix: str) -> Component: component: Final[Component] = { "type": "library", diff --git a/src/python_sbom/_validate/_artifact.py b/src/python_sbom/_validate/_artifact.py index 02c514b..435583b 100644 --- a/src/python_sbom/_validate/_artifact.py +++ b/src/python_sbom/_validate/_artifact.py @@ -11,6 +11,9 @@ if TYPE_CHECKING: from pathlib import Path +# CycloneDX's recommended suffix, which python-sbom and auditwheel use, and the one maturin's cargo-cyclonedx uses +_CYCLONEDX: Final[tuple[str, ...]] = (".cdx.json", ".cyclonedx.json") + def validate(path: Path, allowed_licenses: frozenset[str] | None, max_components: int = MAX_COMPONENTS) -> list[str]: limit: Final[int] = byte_limit(max_components) @@ -43,9 +46,9 @@ def _is_sbom(name: str) -> bool: # every top-level .dist-info counts, so a decoy one sorting first cannot hide the SBOM of another match name.split("/"): case [file]: - return file.endswith(".cdx.json") + return file.endswith(_CYCLONEDX) case [dist_info, "sboms", file]: - return dist_info.endswith(".dist-info") and file.endswith(".cdx.json") + return dist_info.endswith(".dist-info") and file.endswith(_CYCLONEDX) case _: return False diff --git a/tests/_generate/test_embed.py b/tests/_generate/test_embed.py index 46b2d4b..bc52eb9 100644 --- a/tests/_generate/test_embed.py +++ b/tests/_generate/test_embed.py @@ -8,6 +8,7 @@ from python_sbom import BundledWheelInfo, ContentProvider, ProviderContext from python_sbom._generate._embed import embed_sbom +from python_sbom._validate._artifact import validate if TYPE_CHECKING: from pathlib import PurePosixPath @@ -56,6 +57,30 @@ def bundled_wheel(self, context: ProviderContext, wheel: PurePosixPath) -> Bundl return BundledWheelInfo(properties=[{"name": f"{context.identity.property_prefix}:table", "value": value}]) +def test_other_sboms_of_the_wheel_are_linked(tmp_path: Path, write_wheel: WriteWheel) -> None: + (root := tmp_path / "project").mkdir() + (root / "pyproject.toml").write_text("") + cargo = json.dumps({"bomFormat": "CycloneDX", "specVersion": "1.5", "version": 1}).encode() + spdx = b'{"spdxVersion": "SPDX-2.3"}' + wheel = write_wheel( + tmp_path / "dist" / "pkg-1.0-py3-none-any.whl", + { + "pkg-1.0.dist-info/METADATA": b"Name: pkg\nVersion: 1.0\n", + "pkg-1.0.dist-info/sboms/pkg.cyclonedx.json": cargo, + "pkg-1.0.dist-info/sboms/vendor/c:d.spdx.json": spdx, + }, + ) + # the second run replaces the SBOM the first wrote, which links to neither itself nor its earlier copy + for _ in range(2): + written = embed_sbom(wheel, root, provider=None, commit=None, build_env=[str(root)]) + references = json.loads(zipfile.ZipFile(wheel).read(written))["metadata"]["component"]["externalReferences"] + assert [(ref["url"], ref["hashes"]) for ref in references if ref["type"] == "bom"] == [ + ("pkg.cyclonedx.json", [{"alg": "SHA-256", "content": hashlib.sha256(cargo).hexdigest()}]), + ("vendor/c%3Ad.spdx.json", [{"alg": "SHA-256", "content": hashlib.sha256(spdx).hexdigest()}]), + ] + assert validate(wheel, None) == [] + + def test_identical_bundled_copies_keep_their_own_paths(tmp_path: Path, write_wheel: WriteWheel) -> None: (root := tmp_path / "project").mkdir() (root / "pyproject.toml").write_text("[tool.python-sbom]\nbundled-wheels = ['src/*/wheels/*.whl']\n") diff --git a/tests/_validate/test_artifact.py b/tests/_validate/test_artifact.py index 55c7948..fc7e570 100644 --- a/tests/_validate/test_artifact.py +++ b/tests/_validate/test_artifact.py @@ -47,6 +47,24 @@ def test_every_sbom_is_checked(tmp_path: Path, write_wheel: WriteWheel, describe ] +def test_cargo_cyclonedx_sbom_is_checked(tmp_path: Path, write_wheel: WriteWheel) -> None: + # maturin names the SBOM of a wheel's Rust crates the way cargo-cyclonedx does + repeated = { + "bomFormat": "CycloneDX", + "specVersion": "1.5", + "version": 1, + "components": [ + {"type": "library", "name": "a", "bom-ref": "a"}, + {"type": "library", "name": "b", "bom-ref": "a"}, + ], + } + wheel = write_wheel( + tmp_path / "example-1.0-py3-none-any.whl", + {**_METADATA, "example-1.0.dist-info/sboms/example.cyclonedx.json": json.dumps(repeated).encode()}, + ) + assert validate(wheel, None) == ["example-1.0.dist-info/sboms/example.cyclonedx.json: bom-ref values repeat: a"] + + def test_sbom_of_every_dist_info_is_checked(tmp_path: Path, write_wheel: WriteWheel, describe: Describe) -> None: # a decoy .dist-info sorting first must not hide the SBOM of the wheel's own one broken = json.loads(dumps(describe())) diff --git a/tests/conftest.py b/tests/conftest.py index e04ffc9..ca70785 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,6 +55,7 @@ def __call__( # ruff: ignore[too-many-arguments] # each a part of the wheel a t bundled: list[BundledWheel] | None = None, build_scripts: list[BuildScript] | None = None, content: ContentProvider | None = None, + other_sboms: dict[str, str] | None = None, ) -> Document: ... @@ -160,6 +161,7 @@ def describe( # ruff: ignore[too-many-arguments] # each a part of the wheel a t bundled: list[BundledWheel] | None = None, build_scripts: list[BuildScript] | None = None, content: ContentProvider | None = None, + other_sboms: dict[str, str] | None = None, ) -> Document: tree = WheelTree( name="example-1.0-py3-none-any.whl", @@ -167,6 +169,7 @@ def describe( # ruff: ignore[too-many-arguments] # each a part of the wheel a t copyright=copyright_line, bundled=bundled or [], build_scripts=build_scripts or [], + other_sboms=other_sboms or {}, ) project = project_identity(tree.metadata, settings) content = content or ContentProvider() From d9336c3578239bf2c2669a71038c24d54869b3aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 14:20:23 -0800 Subject: [PATCH 02/11] =?UTF-8?q?=F0=9F=93=9D=20docs(maturin):=20add=20a?= =?UTF-8?q?=20how-to=20for=20maturin=20projects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.d/+maturin.doc.rst | 2 + docs/how-to/index.rst | 3 +- docs/how-to/maturin.rst | 130 ++++++++++++++++++++++++++++++ docs/how-to/other-backends.rst | 10 +-- docs/tutorials/first-sbom.rst | 2 +- 5 files changed, 136 insertions(+), 11 deletions(-) create mode 100644 docs/changelog.d/+maturin.doc.rst create mode 100644 docs/how-to/maturin.rst diff --git a/docs/changelog.d/+maturin.doc.rst b/docs/changelog.d/+maturin.doc.rst new file mode 100644 index 0000000..9fb3146 --- /dev/null +++ b/docs/changelog.d/+maturin.doc.rst @@ -0,0 +1,2 @@ +Add a how-to for maturin projects: what maturin's SBOM and python-sbom's each hold, and how to set both up for +wheels a build frontend builds and for ones ``maturin build`` or maturin-action builds. diff --git a/docs/how-to/index.rst b/docs/how-to/index.rst index 11d90d8..2c92619 100644 --- a/docs/how-to/index.rst +++ b/docs/how-to/index.rst @@ -3,7 +3,7 @@ ############### Each guide solves one task and assumes you know what python-sbom does, as the :doc:`/tutorials/index` show. The first -four set it up for a :term:`build backend`; the rest describe other artifacts, add what a project knows, and check the +five set it up for a :term:`build backend`; the rest describe other artifacts, add what a project knows, and check the result. The :doc:`/reference/index` lists every option and command, and :doc:`/concepts/index` explains the design. .. toctree:: @@ -13,6 +13,7 @@ result. The :doc:`/reference/index` lists every option and command, and :doc:`/c pdm-backend setuptools other-backends + maturin built-elsewhere archive content-provider diff --git a/docs/how-to/maturin.rst b/docs/how-to/maturin.rst new file mode 100644 index 0000000..885c9be --- /dev/null +++ b/docs/how-to/maturin.rst @@ -0,0 +1,130 @@ +################################## + Add an SBOM to a maturin project +################################## + +maturin_ has written an :term:`SBOM` of a :term:`wheel`'s Rust crates since 1.12. python-sbom adds a second one with +what maturin's leaves out: the Python package, its declared dependencies, the build tools and the source revision. It +links to maturin's by file name and SHA-256, so a scanner that reads it also finds the crates. This guide sets that up +for each way a maturin project builds its wheels. + +********************** + What each SBOM holds +********************** + +Both sit in the wheel's ``.dist-info/sboms`` directory, as :term:`PEP 770` allows: + +.. list-table:: + :header-rows: 1 + + - - + - maturin's ``.cyclonedx.json`` + - python-sbom's ``.cdx.json`` + - - Written by + - `cargo-cyclonedx `_, inside maturin + - python-sbom, after the wheel is written + - - Identifies the wheel as + - the Rust crate, ``pkg:cargo/@`` + - the Python package, ``pkg:pypi/@`` + - - Components + - the crates the extension or binary depends on, transitively, with the graph between them + - the runtime dependencies the core metadata declares + - - Also records + - + - supplier, authors and license; the build tools and interpreter; the :term:`source revision`; a link to every + other SBOM in the directory, with its SHA-256 + +Keep maturin's: python-sbom does not list Rust crates, so turning it off with ``[tool.maturin.sbom] rust = false`` +loses them. When maturin's repair copies shared libraries into the wheel, it adds a third SBOM, ``auditwheel.cdx.json``, +which python-sbom links the same way. + +******************************** + Wheels a build frontend builds +******************************** + +pip_, uv_, ``python -m build`` and cibuildwheel_ build through the standard build interface. Make the +:term:`wrapper backend` the project's backend, keep maturin in the build requirements, and name it in +``[tool.python-sbom]``: + +.. code-block:: toml + + [build-system] + build-backend = 'python_sbom.backend' + requires = ['maturin>=1.12,<2', 'python-sbom>=0.3'] + + [tool.python-sbom] + build-backend = 'maturin' + supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } + +Every hook goes to maturin unchanged, so ``[tool.maturin]`` and ``--config-settings`` behave as before. Once maturin has +written the wheel, with its own SBOM inside, the wrapper adds python-sbom's. It runs in the build's isolated +environment, so the SBOM lists the maturin version the frontend installed. + +.. code-block:: console + + $ uv build --wheel + $ unzip -Z1 dist/*.whl '*/sboms/*' + matex-1.0.dist-info/sboms/matex.cyclonedx.json + matex-1.0.dist-info/sboms/matex.cdx.json + +*************************************************** + Wheels ``maturin build`` or maturin-action builds +*************************************************** + +``maturin build`` and maturin-action_ call maturin's own command line, so the wrapper never runs. Describe those wheels +afterwards with ``python-sbom embed``, run from the project root so it finds ``[tool.python-sbom]``: + +.. code-block:: console + + $ maturin build --release --out dist + $ python-sbom embed dist/*.whl + wrote matex-1.0.dist-info/sboms/matex.cdx.json into matex-1.0-py3-none-manylinux_2_34_x86_64.whl + +``embed`` lists the packages of the environment it runs in as the build tools. maturin-action builds with a maturin +binary of its own, so install the same maturin version next to python-sbom, and the SBOM records the version that built +the wheel: + +.. code-block:: yaml + + - uses: PyO3/maturin-action@v1 + with: + maturin-version: 1.15.0 + args: --release --out dist + - name: Write the SBOM into the wheels + run: | + python -m venv build-env + build-env/bin/python -m pip install maturin==1.15.0 python-sbom==0.3.0 + build-env/bin/python-sbom embed dist/*.whl + +On Linux, maturin-action builds inside a manylinux container and hands the ``dist`` directory back to the runner's user, +so ``embed`` can rewrite the wheels there. :doc:`/how-to/built-elsewhere` covers ``--build-env`` and the source +revision of a wheel built from an :term:`sdist`. + +********** + Check it +********** + +``python-sbom validate`` checks maturin's ``.cyclonedx.json`` file as well as the ``.cdx.json`` ones: + +.. code-block:: console + + $ python-sbom validate dist/ + SBOM in matex-1.0-py3-none-manylinux_2_34_x86_64.whl is valid + +python-sbom's own SBOM gets the full check; maturin's and auditwheel's get the CycloneDX schema check alone, as +:doc:`/how-to/validate` describes. + +************************************************ + Pitfall: a build backend in the project's tree +************************************************ + +A project whose ``[build-system]`` loads a backend from its own tree through ``backend-path``, for example one that +calls maturin and then post-processes the wheel, cannot use the wrapper: a frontend loads only a backend found on that +path. Run ``python-sbom embed`` on the finished wheels instead, as for ``maturin build``. + +*********************************** + Pitfall: a repair outside maturin +*********************************** + +maturin applies its manylinux repair while it writes the wheel, so the file name is final. A later ``delocate`` or +``auditwheel repair`` renames the wheel, and the SBOM written before it names a file that is never published. Run +``python-sbom embed`` on the repaired wheel. diff --git a/docs/how-to/other-backends.rst b/docs/how-to/other-backends.rst index 6ff0b0c..0d046ed 100644 --- a/docs/how-to/other-backends.rst +++ b/docs/how-to/other-backends.rst @@ -42,7 +42,7 @@ Use the module name from your current ``[build-system] build-backend``: - Its sdist step needs a git_ or Mercurial checkout, as without the wrapper. - - maturin_ - ``maturin`` - - maturin writes its own SBOM of the Rust crates next to python-sbom's; see below. + - maturin writes its own SBOM of the Rust crates next to python-sbom's; :doc:`/how-to/maturin` covers both. - - scikit-build-core_ - ``scikit_build_core.build`` - A project built with hatchling_ and scikit-build-core's hatch plugin uses :doc:`/how-to/hatchling` instead. @@ -60,14 +60,6 @@ Use the module name from your current ``[build-system] build-backend``: - ``pdm.backend``, ``setuptools.build_meta`` - Use :doc:`/how-to/pdm-backend` or :doc:`/how-to/setuptools` instead; wrap them only when the plugin cannot act. -maturin's own SBOM -================== - -`maturin writes a CycloneDX SBOM `_ of the Rust crates a wheel links, as -``.cyclonedx.json``. :term:`PEP 770` allows several SBOMs per wheel, so python-sbom's ``.cdx.json`` sits -next to it: maturin's lists the crates, python-sbom's the wheel's files, metadata, build tools and source revision. -python-sbom's links to maturin's by its file name and SHA-256, so a reader of one finds the other. - *********************************************** Pitfall: builds that skip the build interface *********************************************** diff --git a/docs/tutorials/first-sbom.rst b/docs/tutorials/first-sbom.rst index 286fc25..895c60e 100644 --- a/docs/tutorials/first-sbom.rst +++ b/docs/tutorials/first-sbom.rst @@ -132,6 +132,6 @@ That is the check a CI job runs before publishing; :doc:`/how-to/validate` shows ************ - Your project uses another :term:`build backend`? Pick its guide: :doc:`/how-to/pdm-backend`, :doc:`/how-to/setuptools` - or :doc:`/how-to/other-backends`. + or :doc:`/how-to/other-backends`; a Rust extension built with maturin: :doc:`/how-to/maturin`. - Your project bundles wheels or knows more than its metadata says: :doc:`/how-to/content-provider`. - Every option python-sbom reads: :doc:`/reference/configuration`. From a1ccfe40bcc0fb33bce771534c24ef713bac32b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 14:20:23 -0800 Subject: [PATCH 03/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(sbom):=20ti?= =?UTF-8?q?ghten=20other-SBOM=20code=20and=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/python_sbom/_validate/_artifact.py | 9 +++---- tests/_generate/test_embed.py | 35 +++++++++++++++++--------- tests/conftest.py | 4 +-- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/python_sbom/_validate/_artifact.py b/src/python_sbom/_validate/_artifact.py index 435583b..6605d2e 100644 --- a/src/python_sbom/_validate/_artifact.py +++ b/src/python_sbom/_validate/_artifact.py @@ -11,9 +11,6 @@ if TYPE_CHECKING: from pathlib import Path -# CycloneDX's recommended suffix, which python-sbom and auditwheel use, and the one maturin's cargo-cyclonedx uses -_CYCLONEDX: Final[tuple[str, ...]] = (".cdx.json", ".cyclonedx.json") - def validate(path: Path, allowed_licenses: frozenset[str] | None, max_components: int = MAX_COMPONENTS) -> list[str]: limit: Final[int] = byte_limit(max_components) @@ -43,12 +40,14 @@ def _read(source: IO[bytes], limit: int) -> bytes: def _is_sbom(name: str) -> bool: + # CycloneDX's recommended suffix, which python-sbom and auditwheel use, and the one maturin's cargo-cyclonedx uses + cyclonedx: Final[tuple[str, ...]] = (".cdx.json", ".cyclonedx.json") # every top-level .dist-info counts, so a decoy one sorting first cannot hide the SBOM of another match name.split("/"): case [file]: - return file.endswith(_CYCLONEDX) + return file.endswith(cyclonedx) case [dist_info, "sboms", file]: - return dist_info.endswith(".dist-info") and file.endswith(_CYCLONEDX) + return dist_info.endswith(".dist-info") and file.endswith(cyclonedx) case _: return False diff --git a/tests/_generate/test_embed.py b/tests/_generate/test_embed.py index bc52eb9..e60a822 100644 --- a/tests/_generate/test_embed.py +++ b/tests/_generate/test_embed.py @@ -6,6 +6,8 @@ from pathlib import Path from typing import TYPE_CHECKING, Final +import pytest + from python_sbom import BundledWheelInfo, ContentProvider, ProviderContext from python_sbom._generate._embed import embed_sbom from python_sbom._validate._artifact import validate @@ -13,7 +15,6 @@ if TYPE_CHECKING: from pathlib import PurePosixPath - import pytest from conftest import Install, WriteWheel from pytest_mock import MockerFixture @@ -57,28 +58,38 @@ def bundled_wheel(self, context: ProviderContext, wheel: PurePosixPath) -> Bundl return BundledWheelInfo(properties=[{"name": f"{context.identity.property_prefix}:table", "value": value}]) -def test_other_sboms_of_the_wheel_are_linked(tmp_path: Path, write_wheel: WriteWheel) -> None: +_CARGO: Final[bytes] = json.dumps({"bomFormat": "CycloneDX", "specVersion": "1.5", "version": 1}).encode() +_SPDX: Final[bytes] = b'{"spdxVersion": "SPDX-2.3"}' + + +@pytest.fixture +def linked(tmp_path: Path, write_wheel: WriteWheel) -> tuple[Path, str]: (root := tmp_path / "project").mkdir() (root / "pyproject.toml").write_text("") - cargo = json.dumps({"bomFormat": "CycloneDX", "specVersion": "1.5", "version": 1}).encode() - spdx = b'{"spdxVersion": "SPDX-2.3"}' wheel = write_wheel( tmp_path / "dist" / "pkg-1.0-py3-none-any.whl", { "pkg-1.0.dist-info/METADATA": b"Name: pkg\nVersion: 1.0\n", - "pkg-1.0.dist-info/sboms/pkg.cyclonedx.json": cargo, - "pkg-1.0.dist-info/sboms/vendor/c:d.spdx.json": spdx, + "pkg-1.0.dist-info/sboms/pkg.cyclonedx.json": _CARGO, + "pkg-1.0.dist-info/sboms/vendor/c:d.spdx.json": _SPDX, }, ) - # the second run replaces the SBOM the first wrote, which links to neither itself nor its earlier copy - for _ in range(2): - written = embed_sbom(wheel, root, provider=None, commit=None, build_env=[str(root)]) + # the second run replaces the SBOM the first wrote, and links to neither + embed_sbom(wheel, root, provider=None, commit=None, build_env=[str(root)]) + return wheel, embed_sbom(wheel, root, provider=None, commit=None, build_env=[str(root)]) + + +def test_other_sboms_of_the_wheel_are_linked(linked: tuple[Path, str]) -> None: + wheel, written = linked references = json.loads(zipfile.ZipFile(wheel).read(written))["metadata"]["component"]["externalReferences"] assert [(ref["url"], ref["hashes"]) for ref in references if ref["type"] == "bom"] == [ - ("pkg.cyclonedx.json", [{"alg": "SHA-256", "content": hashlib.sha256(cargo).hexdigest()}]), - ("vendor/c%3Ad.spdx.json", [{"alg": "SHA-256", "content": hashlib.sha256(spdx).hexdigest()}]), + ("pkg.cyclonedx.json", [{"alg": "SHA-256", "content": hashlib.sha256(_CARGO).hexdigest()}]), + ("vendor/c%3Ad.spdx.json", [{"alg": "SHA-256", "content": hashlib.sha256(_SPDX).hexdigest()}]), ] - assert validate(wheel, None) == [] + + +def test_linked_sbom_validates(linked: tuple[Path, str]) -> None: + assert validate(linked[0], None) == [] def test_identical_bundled_copies_keep_their_own_paths(tmp_path: Path, write_wheel: WriteWheel) -> None: diff --git a/tests/conftest.py b/tests/conftest.py index ca70785..618e42c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -55,7 +55,6 @@ def __call__( # ruff: ignore[too-many-arguments] # each a part of the wheel a t bundled: list[BundledWheel] | None = None, build_scripts: list[BuildScript] | None = None, content: ContentProvider | None = None, - other_sboms: dict[str, str] | None = None, ) -> Document: ... @@ -161,7 +160,6 @@ def describe( # ruff: ignore[too-many-arguments] # each a part of the wheel a t bundled: list[BundledWheel] | None = None, build_scripts: list[BuildScript] | None = None, content: ContentProvider | None = None, - other_sboms: dict[str, str] | None = None, ) -> Document: tree = WheelTree( name="example-1.0-py3-none-any.whl", @@ -169,7 +167,7 @@ def describe( # ruff: ignore[too-many-arguments] # each a part of the wheel a t copyright=copyright_line, bundled=bundled or [], build_scripts=build_scripts or [], - other_sboms=other_sboms or {}, + other_sboms={}, ) project = project_identity(tree.metadata, settings) content = content or ContentProvider() From 91a1e63b5265898d98a4d56a9d901f54c969558d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 14:23:23 -0800 Subject: [PATCH 04/11] =?UTF-8?q?=F0=9F=93=9D=20docs(maturin):=20tighten?= =?UTF-8?q?=20wording=20after=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/changelog.d/+maturin.doc.rst | 4 ++-- docs/changelog.d/+other-sboms.feature.rst | 2 +- docs/how-to/maturin.rst | 17 ++++++++--------- src/python_sbom/_collect/_wheel.py | 2 +- src/python_sbom/_model/_inputs.py | 2 +- src/python_sbom/_model/_wheel.py | 2 +- tests/_generate/test_embed.py | 2 +- 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/docs/changelog.d/+maturin.doc.rst b/docs/changelog.d/+maturin.doc.rst index 9fb3146..5dec393 100644 --- a/docs/changelog.d/+maturin.doc.rst +++ b/docs/changelog.d/+maturin.doc.rst @@ -1,2 +1,2 @@ -Add a how-to for maturin projects: what maturin's SBOM and python-sbom's each hold, and how to set both up for -wheels a build frontend builds and for ones ``maturin build`` or maturin-action builds. +Add a how-to 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. diff --git a/docs/changelog.d/+other-sboms.feature.rst b/docs/changelog.d/+other-sboms.feature.rst index 14541e4..ae22328 100644 --- a/docs/changelog.d/+other-sboms.feature.rst +++ b/docs/changelog.d/+other-sboms.feature.rst @@ -1,3 +1,3 @@ -A wheel's SBOM now links to every other SBOM in its ``.dist-info/sboms`` directory, such as maturin's or +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. diff --git a/docs/how-to/maturin.rst b/docs/how-to/maturin.rst index 885c9be..a59b52d 100644 --- a/docs/how-to/maturin.rst +++ b/docs/how-to/maturin.rst @@ -4,8 +4,7 @@ maturin_ has written an :term:`SBOM` of a :term:`wheel`'s Rust crates since 1.12. python-sbom adds a second one with what maturin's leaves out: the Python package, its declared dependencies, the build tools and the source revision. It -links to maturin's by file name and SHA-256, so a scanner that reads it also finds the crates. This guide sets that up -for each way a maturin project builds its wheels. +links to maturin's by file name and SHA-256, so a scanner that reads it can find the crates. ********************** What each SBOM holds @@ -30,11 +29,11 @@ Both sit in the wheel's ``.dist-info/sboms`` directory, as :term:`PEP 770` allow - the runtime dependencies the core metadata declares - - Also records - - - supplier, authors and license; the build tools and interpreter; the :term:`source revision`; a link to every - other SBOM in the directory, with its SHA-256 + - supplier, authors and license; the build tools and interpreter; the :term:`source revision`; a link to each + other file in the directory, with its SHA-256 -Keep maturin's: python-sbom does not list Rust crates, so turning it off with ``[tool.maturin.sbom] rust = false`` -loses them. When maturin's repair copies shared libraries into the wheel, it adds a third SBOM, ``auditwheel.cdx.json``, +Leave maturin's SBOM on. python-sbom does not list Rust crates, so ``[tool.maturin.sbom] rust = false`` drops the only +list of them from the wheel. When maturin's repair copies shared libraries into the wheel, it adds a third SBOM, ``auditwheel.cdx.json``, which python-sbom links the same way. ******************************** @@ -55,9 +54,9 @@ pip_, uv_, ``python -m build`` and cibuildwheel_ build through the standard buil build-backend = 'maturin' supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } -Every hook goes to maturin unchanged, so ``[tool.maturin]`` and ``--config-settings`` behave as before. Once maturin has -written the wheel, with its own SBOM inside, the wrapper adds python-sbom's. It runs in the build's isolated -environment, so the SBOM lists the maturin version the frontend installed. +The wrapper passes every hook to maturin unchanged, so ``[tool.maturin]`` and ``--config-settings`` behave as before. +Once maturin has written the wheel, with its own SBOM inside, the wrapper adds python-sbom's from within the build's +isolated environment, so the SBOM lists the maturin version the frontend installed. .. code-block:: console diff --git a/src/python_sbom/_collect/_wheel.py b/src/python_sbom/_collect/_wheel.py index 1fcd29f..e1b1db8 100644 --- a/src/python_sbom/_collect/_wheel.py +++ b/src/python_sbom/_collect/_wheel.py @@ -29,7 +29,7 @@ def read_wheel( copyright=copyright_notice(root, metadata.values("license_files")), bundled=artifact.bundled_wheels(_shipped_copies(root, settings, artifact)), build_scripts=hash_build_scripts(root, build_scripts), - # maturin, auditwheel and others write their own, which a reader of ours should be able to find + # maturin and auditwheel write SBOMs of their own here; ours links to them so a reader can find them other_sboms={ name.removeprefix(sboms): artifact.digest(name) for name in sorted(artifact.members) diff --git a/src/python_sbom/_model/_inputs.py b/src/python_sbom/_model/_inputs.py index bba88b4..cda922d 100644 --- a/src/python_sbom/_model/_inputs.py +++ b/src/python_sbom/_model/_inputs.py @@ -120,7 +120,7 @@ class Artifact: @dataclass(frozen=True, slots=True, kw_only=True) class WheelTree: # what a built wheel holds, read from the wheel without unpacking it: its file name, its core metadata, the wheels - # it bundles and the SHA-256 of each SBOM another tool put next to ours, by its path under the sboms directory; and + # it bundles and the SHA-256 of each other file in its sboms directory, by its path there; and # what the project adds: the copyright line of its license files and the scripts that built it name: str metadata: CoreMetadata diff --git a/src/python_sbom/_model/_wheel.py b/src/python_sbom/_model/_wheel.py index ce24f81..5eb2d2c 100644 --- a/src/python_sbom/_model/_wheel.py +++ b/src/python_sbom/_model/_wheel.py @@ -65,7 +65,7 @@ def _other_sbom(path: str, digest: str) -> ExternalReference: return { "type": "bom", "url": quote(path), - "comment": "another SBOM of this wheel, which a different tool wrote", + "comment": "another file in this wheel's sboms directory", "hashes": [{"alg": "SHA-256", "content": digest}], } diff --git a/tests/_generate/test_embed.py b/tests/_generate/test_embed.py index e60a822..0ce9531 100644 --- a/tests/_generate/test_embed.py +++ b/tests/_generate/test_embed.py @@ -74,7 +74,7 @@ def linked(tmp_path: Path, write_wheel: WriteWheel) -> tuple[Path, str]: "pkg-1.0.dist-info/sboms/vendor/c:d.spdx.json": _SPDX, }, ) - # the second run replaces the SBOM the first wrote, and links to neither + # a second embed replaces the first one's SBOM and links to neither that copy nor itself embed_sbom(wheel, root, provider=None, commit=None, build_env=[str(root)]) return wheel, embed_sbom(wheel, root, provider=None, commit=None, build_env=[str(root)]) From 3a78b6586eb42263106a2307ae73b38a43e6e14e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 14:58:52 -0800 Subject: [PATCH 05/11] =?UTF-8?q?=E2=9C=85=20test(examples):=20build=20eac?= =?UTF-8?q?h=20backend's=20docs=20example?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every backend gets an example project under docs/examples and a tox environment of its own, so tox r -e maturin builds and checks just that project and tox r -m examples runs all of them. Each test replays the session the docs show and compares python-sbom's output with it, so the docs fail CI when they drift. CI runs every example on Linux and delocate on macOS. --- .github/workflows/check.yaml | 14 +- docs/examples/auditwheel/meson.build | 5 + docs/examples/auditwheel/pyproject.toml | 22 + docs/examples/auditwheel/session.console | 3 + .../examples/auditwheel/src/greet/__init__.py | 1 + docs/examples/auditwheel/src/greet/_greet.c | 16 + docs/examples/auditwheel/src/greet/_greet.pyi | 1 + docs/examples/auditwheel/src/greet/cli.py | 11 + docs/examples/flit-core/pyproject.toml | 23 + docs/examples/flit-core/session.console | 3 + docs/examples/flit-core/src/greet/__init__.py | 1 + docs/examples/flit-core/src/greet/cli.py | 9 + docs/examples/hatchling/LICENSE | 3 + docs/examples/hatchling/pyproject.toml | 27 + docs/examples/hatchling/session.console | 3 + docs/examples/hatchling/src/greet/__init__.py | 1 + docs/examples/hatchling/src/greet/cli.py | 9 + docs/examples/maturin/Cargo.toml | 4 + docs/examples/maturin/pyproject.toml | 26 + .../maturin/session-maturin-build.console | 5 + docs/examples/maturin/session.console | 3 + docs/examples/maturin/src/main.rs | 3 + docs/examples/meson-python/meson.build | 5 + docs/examples/meson-python/pyproject.toml | 23 + .../meson-python/session-delocate.console | 4 + docs/examples/meson-python/session.console | 3 + .../meson-python/src/greet/__init__.py | 1 + docs/examples/meson-python/src/greet/_greet.c | 9 + .../meson-python/src/greet/_greet.pyi | 1 + docs/examples/meson-python/src/greet/cli.py | 11 + docs/examples/pdm-backend/pyproject.toml | 22 + docs/examples/pdm-backend/session.console | 3 + .../pdm-backend/src/greet/__init__.py | 1 + docs/examples/pdm-backend/src/greet/cli.py | 9 + docs/examples/poetry-core/pyproject.toml | 23 + docs/examples/poetry-core/session.console | 3 + .../poetry-core/src/greet/__init__.py | 1 + docs/examples/poetry-core/src/greet/cli.py | 9 + .../examples/scikit-build-core/CMakeLists.txt | 6 + .../examples/scikit-build-core/pyproject.toml | 26 + .../scikit-build-core/session.console | 3 + .../scikit-build-core/src/greet/__init__.py | 1 + .../scikit-build-core/src/greet/_greet.c | 9 + .../scikit-build-core/src/greet/_greet.pyi | 1 + .../scikit-build-core/src/greet/cli.py | 11 + docs/examples/setuptools/pyproject.toml | 22 + docs/examples/setuptools/session.console | 3 + .../examples/setuptools/src/greet/__init__.py | 1 + docs/examples/setuptools/src/greet/cli.py | 9 + docs/examples/uv-build/pyproject.toml | 23 + docs/examples/uv-build/session.console | 3 + docs/examples/uv-build/src/greet/__init__.py | 1 + docs/examples/uv-build/src/greet/cli.py | 9 + docs/examples/zipapp/pyproject.toml | 25 + docs/examples/zipapp/session.console | 8 + docs/examples/zipapp/src/greet/__init__.py | 1 + docs/examples/zipapp/src/greet/cli.py | 9 + docs/how-to/{ => backends}/hatchling.rst | 0 docs/how-to/{ => backends}/maturin.rst | 0 docs/how-to/{ => backends}/other-backends.rst | 0 docs/how-to/{ => backends}/pdm-backend.rst | 0 docs/how-to/{ => backends}/setuptools.rst | 0 pylock.toml | 568 +++++++++++++++++- pyproject.toml | 27 + .../cibuildwheel/test_cibuildwheel.py | 49 ++ tests/examples/conftest.py | 79 +++ tests/examples/delocate/test_delocate.py | 22 + tests/examples/flit-core/test_flit_core.py | 22 + tests/examples/hatchling/test_hatchling.py | 22 + tests/examples/maturin/test_maturin.py | 34 ++ tests/examples/maturin/test_maturin_build.py | 34 ++ .../meson-python/test_meson_python.py | 22 + .../examples/pdm-backend/test_pdm_backend.py | 22 + .../examples/poetry-core/test_poetry_core.py | 22 + .../test_scikit_build_core.py | 22 + tests/examples/setuptools/test_setuptools.py | 22 + tests/examples/uv-build/test_uv_build.py | 22 + tests/examples/zipapp/test_zipapp.py | 27 + tox.toml | 235 ++++++++ 79 files changed, 1720 insertions(+), 23 deletions(-) create mode 100644 docs/examples/auditwheel/meson.build create mode 100644 docs/examples/auditwheel/pyproject.toml create mode 100644 docs/examples/auditwheel/session.console create mode 100644 docs/examples/auditwheel/src/greet/__init__.py create mode 100644 docs/examples/auditwheel/src/greet/_greet.c create mode 100644 docs/examples/auditwheel/src/greet/_greet.pyi create mode 100644 docs/examples/auditwheel/src/greet/cli.py create mode 100644 docs/examples/flit-core/pyproject.toml create mode 100644 docs/examples/flit-core/session.console create mode 100644 docs/examples/flit-core/src/greet/__init__.py create mode 100644 docs/examples/flit-core/src/greet/cli.py create mode 100644 docs/examples/hatchling/LICENSE create mode 100644 docs/examples/hatchling/pyproject.toml create mode 100644 docs/examples/hatchling/session.console create mode 100644 docs/examples/hatchling/src/greet/__init__.py create mode 100644 docs/examples/hatchling/src/greet/cli.py create mode 100644 docs/examples/maturin/Cargo.toml create mode 100644 docs/examples/maturin/pyproject.toml create mode 100644 docs/examples/maturin/session-maturin-build.console create mode 100644 docs/examples/maturin/session.console create mode 100644 docs/examples/maturin/src/main.rs create mode 100644 docs/examples/meson-python/meson.build create mode 100644 docs/examples/meson-python/pyproject.toml create mode 100644 docs/examples/meson-python/session-delocate.console create mode 100644 docs/examples/meson-python/session.console create mode 100644 docs/examples/meson-python/src/greet/__init__.py create mode 100644 docs/examples/meson-python/src/greet/_greet.c create mode 100644 docs/examples/meson-python/src/greet/_greet.pyi create mode 100644 docs/examples/meson-python/src/greet/cli.py create mode 100644 docs/examples/pdm-backend/pyproject.toml create mode 100644 docs/examples/pdm-backend/session.console create mode 100644 docs/examples/pdm-backend/src/greet/__init__.py create mode 100644 docs/examples/pdm-backend/src/greet/cli.py create mode 100644 docs/examples/poetry-core/pyproject.toml create mode 100644 docs/examples/poetry-core/session.console create mode 100644 docs/examples/poetry-core/src/greet/__init__.py create mode 100644 docs/examples/poetry-core/src/greet/cli.py create mode 100644 docs/examples/scikit-build-core/CMakeLists.txt create mode 100644 docs/examples/scikit-build-core/pyproject.toml create mode 100644 docs/examples/scikit-build-core/session.console create mode 100644 docs/examples/scikit-build-core/src/greet/__init__.py create mode 100644 docs/examples/scikit-build-core/src/greet/_greet.c create mode 100644 docs/examples/scikit-build-core/src/greet/_greet.pyi create mode 100644 docs/examples/scikit-build-core/src/greet/cli.py create mode 100644 docs/examples/setuptools/pyproject.toml create mode 100644 docs/examples/setuptools/session.console create mode 100644 docs/examples/setuptools/src/greet/__init__.py create mode 100644 docs/examples/setuptools/src/greet/cli.py create mode 100644 docs/examples/uv-build/pyproject.toml create mode 100644 docs/examples/uv-build/session.console create mode 100644 docs/examples/uv-build/src/greet/__init__.py create mode 100644 docs/examples/uv-build/src/greet/cli.py create mode 100644 docs/examples/zipapp/pyproject.toml create mode 100644 docs/examples/zipapp/session.console create mode 100644 docs/examples/zipapp/src/greet/__init__.py create mode 100644 docs/examples/zipapp/src/greet/cli.py rename docs/how-to/{ => backends}/hatchling.rst (100%) rename docs/how-to/{ => backends}/maturin.rst (100%) rename docs/how-to/{ => backends}/other-backends.rst (100%) rename docs/how-to/{ => backends}/pdm-backend.rst (100%) rename docs/how-to/{ => backends}/setuptools.rst (100%) create mode 100644 tests/examples/cibuildwheel/test_cibuildwheel.py create mode 100644 tests/examples/conftest.py create mode 100644 tests/examples/delocate/test_delocate.py create mode 100644 tests/examples/flit-core/test_flit_core.py create mode 100644 tests/examples/hatchling/test_hatchling.py create mode 100644 tests/examples/maturin/test_maturin.py create mode 100644 tests/examples/maturin/test_maturin_build.py create mode 100644 tests/examples/meson-python/test_meson_python.py create mode 100644 tests/examples/pdm-backend/test_pdm_backend.py create mode 100644 tests/examples/poetry-core/test_poetry_core.py create mode 100644 tests/examples/scikit-build-core/test_scikit_build_core.py create mode 100644 tests/examples/setuptools/test_setuptools.py create mode 100644 tests/examples/uv-build/test_uv_build.py create mode 100644 tests/examples/zipapp/test_zipapp.py diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index a0af25d..0db8f07 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -34,7 +34,19 @@ jobs: {"env": "docs"}, {"env": "fix"}, {"env": "type"}, - {"env": "pkg_meta"} + {"env": "pkg_meta"}, + {"env": "cibuildwheel", "python": "3.15"}, + {"env": "flit-core", "python": "3.15"}, + {"env": "hatchling", "python": "3.15"}, + {"env": "maturin", "python": "3.15"}, + {"env": "meson-python", "python": "3.15"}, + {"env": "pdm-backend", "python": "3.15"}, + {"env": "poetry-core", "python": "3.15"}, + {"env": "scikit-build-core", "python": "3.15"}, + {"env": "setuptools", "python": "3.15"}, + {"env": "uv-build", "python": "3.15"}, + {"env": "zipapp", "python": "3.15"}, + {"env": "delocate", "python": "3.15", "os": "macos-26"} ] release: name: 🏷️ Release dry run diff --git a/docs/examples/auditwheel/meson.build b/docs/examples/auditwheel/meson.build new file mode 100644 index 0000000..ef11990 --- /dev/null +++ b/docs/examples/auditwheel/meson.build @@ -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') diff --git a/docs/examples/auditwheel/pyproject.toml b/docs/examples/auditwheel/pyproject.toml new file mode 100644 index 0000000..6dc2715 --- /dev/null +++ b/docs/examples/auditwheel/pyproject.toml @@ -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" ] } diff --git a/docs/examples/auditwheel/session.console b/docs/examples/auditwheel/session.console new file mode 100644 index 0000000..b073746 --- /dev/null +++ b/docs/examples/auditwheel/session.console @@ -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 diff --git a/docs/examples/auditwheel/src/greet/__init__.py b/docs/examples/auditwheel/src/greet/__init__.py new file mode 100644 index 0000000..6cbf606 --- /dev/null +++ b/docs/examples/auditwheel/src/greet/__init__.py @@ -0,0 +1 @@ +"""Say hello.""" diff --git a/docs/examples/auditwheel/src/greet/_greet.c b/docs/examples/auditwheel/src/greet/_greet.c new file mode 100644 index 0000000..e25bd94 --- /dev/null +++ b/docs/examples/auditwheel/src/greet/_greet.c @@ -0,0 +1,16 @@ +#include + +/* 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); } diff --git a/docs/examples/auditwheel/src/greet/_greet.pyi b/docs/examples/auditwheel/src/greet/_greet.pyi new file mode 100644 index 0000000..85b2180 --- /dev/null +++ b/docs/examples/auditwheel/src/greet/_greet.pyi @@ -0,0 +1 @@ +def hello() -> str: ... diff --git a/docs/examples/auditwheel/src/greet/cli.py b/docs/examples/auditwheel/src/greet/cli.py new file mode 100644 index 0000000..c000008 --- /dev/null +++ b/docs/examples/auditwheel/src/greet/cli.py @@ -0,0 +1,11 @@ +"""Print a greeting the C extension builds.""" + +from __future__ import annotations + +import sys + +from ._greet import hello + + +def main() -> None: + sys.stdout.write(f"{hello()}\n") diff --git a/docs/examples/flit-core/pyproject.toml b/docs/examples/flit-core/pyproject.toml new file mode 100644 index 0000000..10c1403 --- /dev/null +++ b/docs/examples/flit-core/pyproject.toml @@ -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" ] } diff --git a/docs/examples/flit-core/session.console b/docs/examples/flit-core/session.console new file mode 100644 index 0000000..1bd468a --- /dev/null +++ b/docs/examples/flit-core/session.console @@ -0,0 +1,3 @@ +$ python -m build --wheel +$ python-sbom validate dist/ +SBOM in greet-1.0-py3-none-any.whl is valid diff --git a/docs/examples/flit-core/src/greet/__init__.py b/docs/examples/flit-core/src/greet/__init__.py new file mode 100644 index 0000000..6cbf606 --- /dev/null +++ b/docs/examples/flit-core/src/greet/__init__.py @@ -0,0 +1 @@ +"""Say hello.""" diff --git a/docs/examples/flit-core/src/greet/cli.py b/docs/examples/flit-core/src/greet/cli.py new file mode 100644 index 0000000..1d21367 --- /dev/null +++ b/docs/examples/flit-core/src/greet/cli.py @@ -0,0 +1,9 @@ +"""Print a greeting.""" + +from __future__ import annotations + +import sys + + +def main() -> None: + sys.stdout.write("hello\n") diff --git a/docs/examples/hatchling/LICENSE b/docs/examples/hatchling/LICENSE new file mode 100644 index 0000000..4b248d8 --- /dev/null +++ b/docs/examples/hatchling/LICENSE @@ -0,0 +1,3 @@ +Copyright (c) 2026 You + +MIT terms diff --git a/docs/examples/hatchling/pyproject.toml b/docs/examples/hatchling/pyproject.toml new file mode 100644 index 0000000..1fdd95e --- /dev/null +++ b/docs/examples/hatchling/pyproject.toml @@ -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" ] } diff --git a/docs/examples/hatchling/session.console b/docs/examples/hatchling/session.console new file mode 100644 index 0000000..1bd468a --- /dev/null +++ b/docs/examples/hatchling/session.console @@ -0,0 +1,3 @@ +$ python -m build --wheel +$ python-sbom validate dist/ +SBOM in greet-1.0-py3-none-any.whl is valid diff --git a/docs/examples/hatchling/src/greet/__init__.py b/docs/examples/hatchling/src/greet/__init__.py new file mode 100644 index 0000000..6cbf606 --- /dev/null +++ b/docs/examples/hatchling/src/greet/__init__.py @@ -0,0 +1 @@ +"""Say hello.""" diff --git a/docs/examples/hatchling/src/greet/cli.py b/docs/examples/hatchling/src/greet/cli.py new file mode 100644 index 0000000..1d21367 --- /dev/null +++ b/docs/examples/hatchling/src/greet/cli.py @@ -0,0 +1,9 @@ +"""Print a greeting.""" + +from __future__ import annotations + +import sys + + +def main() -> None: + sys.stdout.write("hello\n") diff --git a/docs/examples/maturin/Cargo.toml b/docs/examples/maturin/Cargo.toml new file mode 100644 index 0000000..1720f13 --- /dev/null +++ b/docs/examples/maturin/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "greet" +version = "1.0.0" +edition = "2021" diff --git a/docs/examples/maturin/pyproject.toml b/docs/examples/maturin/pyproject.toml new file mode 100644 index 0000000..4327336 --- /dev/null +++ b/docs/examples/maturin/pyproject.toml @@ -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" ] } diff --git a/docs/examples/maturin/session-maturin-build.console b/docs/examples/maturin/session-maturin-build.console new file mode 100644 index 0000000..d561490 --- /dev/null +++ b/docs/examples/maturin/session-maturin-build.console @@ -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 diff --git a/docs/examples/maturin/session.console b/docs/examples/maturin/session.console new file mode 100644 index 0000000..21ea495 --- /dev/null +++ b/docs/examples/maturin/session.console @@ -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 diff --git a/docs/examples/maturin/src/main.rs b/docs/examples/maturin/src/main.rs new file mode 100644 index 0000000..7527576 --- /dev/null +++ b/docs/examples/maturin/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("hello"); +} diff --git a/docs/examples/meson-python/meson.build b/docs/examples/meson-python/meson.build new file mode 100644 index 0000000..d727388 --- /dev/null +++ b/docs/examples/meson-python/meson.build @@ -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') diff --git a/docs/examples/meson-python/pyproject.toml b/docs/examples/meson-python/pyproject.toml new file mode 100644 index 0000000..c18770c --- /dev/null +++ b/docs/examples/meson-python/pyproject.toml @@ -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" ] } diff --git a/docs/examples/meson-python/session-delocate.console b/docs/examples/meson-python/session-delocate.console new file mode 100644 index 0000000..02477d3 --- /dev/null +++ b/docs/examples/meson-python/session-delocate.console @@ -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 diff --git a/docs/examples/meson-python/session.console b/docs/examples/meson-python/session.console new file mode 100644 index 0000000..b8f5bcd --- /dev/null +++ b/docs/examples/meson-python/session.console @@ -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 diff --git a/docs/examples/meson-python/src/greet/__init__.py b/docs/examples/meson-python/src/greet/__init__.py new file mode 100644 index 0000000..6cbf606 --- /dev/null +++ b/docs/examples/meson-python/src/greet/__init__.py @@ -0,0 +1 @@ +"""Say hello.""" diff --git a/docs/examples/meson-python/src/greet/_greet.c b/docs/examples/meson-python/src/greet/_greet.c new file mode 100644 index 0000000..b409ce9 --- /dev/null +++ b/docs/examples/meson-python/src/greet/_greet.c @@ -0,0 +1,9 @@ +#include + +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); } diff --git a/docs/examples/meson-python/src/greet/_greet.pyi b/docs/examples/meson-python/src/greet/_greet.pyi new file mode 100644 index 0000000..85b2180 --- /dev/null +++ b/docs/examples/meson-python/src/greet/_greet.pyi @@ -0,0 +1 @@ +def hello() -> str: ... diff --git a/docs/examples/meson-python/src/greet/cli.py b/docs/examples/meson-python/src/greet/cli.py new file mode 100644 index 0000000..c000008 --- /dev/null +++ b/docs/examples/meson-python/src/greet/cli.py @@ -0,0 +1,11 @@ +"""Print a greeting the C extension builds.""" + +from __future__ import annotations + +import sys + +from ._greet import hello + + +def main() -> None: + sys.stdout.write(f"{hello()}\n") diff --git a/docs/examples/pdm-backend/pyproject.toml b/docs/examples/pdm-backend/pyproject.toml new file mode 100644 index 0000000..48968ba --- /dev/null +++ b/docs/examples/pdm-backend/pyproject.toml @@ -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" ] } diff --git a/docs/examples/pdm-backend/session.console b/docs/examples/pdm-backend/session.console new file mode 100644 index 0000000..1bd468a --- /dev/null +++ b/docs/examples/pdm-backend/session.console @@ -0,0 +1,3 @@ +$ python -m build --wheel +$ python-sbom validate dist/ +SBOM in greet-1.0-py3-none-any.whl is valid diff --git a/docs/examples/pdm-backend/src/greet/__init__.py b/docs/examples/pdm-backend/src/greet/__init__.py new file mode 100644 index 0000000..6cbf606 --- /dev/null +++ b/docs/examples/pdm-backend/src/greet/__init__.py @@ -0,0 +1 @@ +"""Say hello.""" diff --git a/docs/examples/pdm-backend/src/greet/cli.py b/docs/examples/pdm-backend/src/greet/cli.py new file mode 100644 index 0000000..1d21367 --- /dev/null +++ b/docs/examples/pdm-backend/src/greet/cli.py @@ -0,0 +1,9 @@ +"""Print a greeting.""" + +from __future__ import annotations + +import sys + + +def main() -> None: + sys.stdout.write("hello\n") diff --git a/docs/examples/poetry-core/pyproject.toml b/docs/examples/poetry-core/pyproject.toml new file mode 100644 index 0000000..cb3e006 --- /dev/null +++ b/docs/examples/poetry-core/pyproject.toml @@ -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" ] } diff --git a/docs/examples/poetry-core/session.console b/docs/examples/poetry-core/session.console new file mode 100644 index 0000000..1bd468a --- /dev/null +++ b/docs/examples/poetry-core/session.console @@ -0,0 +1,3 @@ +$ python -m build --wheel +$ python-sbom validate dist/ +SBOM in greet-1.0-py3-none-any.whl is valid diff --git a/docs/examples/poetry-core/src/greet/__init__.py b/docs/examples/poetry-core/src/greet/__init__.py new file mode 100644 index 0000000..6cbf606 --- /dev/null +++ b/docs/examples/poetry-core/src/greet/__init__.py @@ -0,0 +1 @@ +"""Say hello.""" diff --git a/docs/examples/poetry-core/src/greet/cli.py b/docs/examples/poetry-core/src/greet/cli.py new file mode 100644 index 0000000..1d21367 --- /dev/null +++ b/docs/examples/poetry-core/src/greet/cli.py @@ -0,0 +1,9 @@ +"""Print a greeting.""" + +from __future__ import annotations + +import sys + + +def main() -> None: + sys.stdout.write("hello\n") diff --git a/docs/examples/scikit-build-core/CMakeLists.txt b/docs/examples/scikit-build-core/CMakeLists.txt new file mode 100644 index 0000000..506d764 --- /dev/null +++ b/docs/examples/scikit-build-core/CMakeLists.txt @@ -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) diff --git a/docs/examples/scikit-build-core/pyproject.toml b/docs/examples/scikit-build-core/pyproject.toml new file mode 100644 index 0000000..1955935 --- /dev/null +++ b/docs/examples/scikit-build-core/pyproject.toml @@ -0,0 +1,26 @@ +[build-system] +build-backend = "python_sbom.backend" +requires = [ "python-sbom>=0.3", "scikit-build-core>=0.11" ] + +[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.scikit-build] +wheel.packages = [ "src/greet" ] + +[tool.python-sbom] +build-backend = "scikit_build_core.build" +supplier = { name = "You", url = [ "https://github.com/you" ] } diff --git a/docs/examples/scikit-build-core/session.console b/docs/examples/scikit-build-core/session.console new file mode 100644 index 0000000..b8f5bcd --- /dev/null +++ b/docs/examples/scikit-build-core/session.console @@ -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 diff --git a/docs/examples/scikit-build-core/src/greet/__init__.py b/docs/examples/scikit-build-core/src/greet/__init__.py new file mode 100644 index 0000000..6cbf606 --- /dev/null +++ b/docs/examples/scikit-build-core/src/greet/__init__.py @@ -0,0 +1 @@ +"""Say hello.""" diff --git a/docs/examples/scikit-build-core/src/greet/_greet.c b/docs/examples/scikit-build-core/src/greet/_greet.c new file mode 100644 index 0000000..b409ce9 --- /dev/null +++ b/docs/examples/scikit-build-core/src/greet/_greet.c @@ -0,0 +1,9 @@ +#include + +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); } diff --git a/docs/examples/scikit-build-core/src/greet/_greet.pyi b/docs/examples/scikit-build-core/src/greet/_greet.pyi new file mode 100644 index 0000000..85b2180 --- /dev/null +++ b/docs/examples/scikit-build-core/src/greet/_greet.pyi @@ -0,0 +1 @@ +def hello() -> str: ... diff --git a/docs/examples/scikit-build-core/src/greet/cli.py b/docs/examples/scikit-build-core/src/greet/cli.py new file mode 100644 index 0000000..c000008 --- /dev/null +++ b/docs/examples/scikit-build-core/src/greet/cli.py @@ -0,0 +1,11 @@ +"""Print a greeting the C extension builds.""" + +from __future__ import annotations + +import sys + +from ._greet import hello + + +def main() -> None: + sys.stdout.write(f"{hello()}\n") diff --git a/docs/examples/setuptools/pyproject.toml b/docs/examples/setuptools/pyproject.toml new file mode 100644 index 0000000..316b538 --- /dev/null +++ b/docs/examples/setuptools/pyproject.toml @@ -0,0 +1,22 @@ +[build-system] +build-backend = "setuptools.build_meta" +requires = [ "python-sbom[setuptools]>=0.3", "setuptools>=77" ] + +[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" ] } diff --git a/docs/examples/setuptools/session.console b/docs/examples/setuptools/session.console new file mode 100644 index 0000000..1bd468a --- /dev/null +++ b/docs/examples/setuptools/session.console @@ -0,0 +1,3 @@ +$ python -m build --wheel +$ python-sbom validate dist/ +SBOM in greet-1.0-py3-none-any.whl is valid diff --git a/docs/examples/setuptools/src/greet/__init__.py b/docs/examples/setuptools/src/greet/__init__.py new file mode 100644 index 0000000..6cbf606 --- /dev/null +++ b/docs/examples/setuptools/src/greet/__init__.py @@ -0,0 +1 @@ +"""Say hello.""" diff --git a/docs/examples/setuptools/src/greet/cli.py b/docs/examples/setuptools/src/greet/cli.py new file mode 100644 index 0000000..1d21367 --- /dev/null +++ b/docs/examples/setuptools/src/greet/cli.py @@ -0,0 +1,9 @@ +"""Print a greeting.""" + +from __future__ import annotations + +import sys + + +def main() -> None: + sys.stdout.write("hello\n") diff --git a/docs/examples/uv-build/pyproject.toml b/docs/examples/uv-build/pyproject.toml new file mode 100644 index 0000000..70bb21a --- /dev/null +++ b/docs/examples/uv-build/pyproject.toml @@ -0,0 +1,23 @@ +[build-system] +build-backend = "python_sbom.backend" +requires = [ "python-sbom>=0.3", "uv-build>=0.9" ] + +[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 = "uv_build" +supplier = { name = "You", url = [ "https://github.com/you" ] } diff --git a/docs/examples/uv-build/session.console b/docs/examples/uv-build/session.console new file mode 100644 index 0000000..1bd468a --- /dev/null +++ b/docs/examples/uv-build/session.console @@ -0,0 +1,3 @@ +$ python -m build --wheel +$ python-sbom validate dist/ +SBOM in greet-1.0-py3-none-any.whl is valid diff --git a/docs/examples/uv-build/src/greet/__init__.py b/docs/examples/uv-build/src/greet/__init__.py new file mode 100644 index 0000000..6cbf606 --- /dev/null +++ b/docs/examples/uv-build/src/greet/__init__.py @@ -0,0 +1 @@ +"""Say hello.""" diff --git a/docs/examples/uv-build/src/greet/cli.py b/docs/examples/uv-build/src/greet/cli.py new file mode 100644 index 0000000..1d21367 --- /dev/null +++ b/docs/examples/uv-build/src/greet/cli.py @@ -0,0 +1,9 @@ +"""Print a greeting.""" + +from __future__ import annotations + +import sys + + +def main() -> None: + sys.stdout.write("hello\n") diff --git a/docs/examples/zipapp/pyproject.toml b/docs/examples/zipapp/pyproject.toml new file mode 100644 index 0000000..65d5a4d --- /dev/null +++ b/docs/examples/zipapp/pyproject.toml @@ -0,0 +1,25 @@ +[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" +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.hatch] +build.hooks.python-sbom = {} + +[tool.python-sbom] +supplier = { name = "You", url = [ "https://github.com/you" ] } diff --git a/docs/examples/zipapp/session.console b/docs/examples/zipapp/session.console new file mode 100644 index 0000000..5aaa78e --- /dev/null +++ b/docs/examples/zipapp/session.console @@ -0,0 +1,8 @@ +$ python -m build --wheel +$ python -m zipfile -e dist/greet-1.0-py3-none-any.whl app +$ python -m zipapp app --main greet.cli:main --output greet.pyz +$ python-sbom archive greet.pyz --embed +wrote greet.pyz.cdx.json +wrote greet.pyz.cdx.json into greet.pyz +$ python-sbom validate greet.pyz +SBOM in greet.pyz is valid diff --git a/docs/examples/zipapp/src/greet/__init__.py b/docs/examples/zipapp/src/greet/__init__.py new file mode 100644 index 0000000..6cbf606 --- /dev/null +++ b/docs/examples/zipapp/src/greet/__init__.py @@ -0,0 +1 @@ +"""Say hello.""" diff --git a/docs/examples/zipapp/src/greet/cli.py b/docs/examples/zipapp/src/greet/cli.py new file mode 100644 index 0000000..1d21367 --- /dev/null +++ b/docs/examples/zipapp/src/greet/cli.py @@ -0,0 +1,9 @@ +"""Print a greeting.""" + +from __future__ import annotations + +import sys + + +def main() -> None: + sys.stdout.write("hello\n") diff --git a/docs/how-to/hatchling.rst b/docs/how-to/backends/hatchling.rst similarity index 100% rename from docs/how-to/hatchling.rst rename to docs/how-to/backends/hatchling.rst diff --git a/docs/how-to/maturin.rst b/docs/how-to/backends/maturin.rst similarity index 100% rename from docs/how-to/maturin.rst rename to docs/how-to/backends/maturin.rst diff --git a/docs/how-to/other-backends.rst b/docs/how-to/backends/other-backends.rst similarity index 100% rename from docs/how-to/other-backends.rst rename to docs/how-to/backends/other-backends.rst diff --git a/docs/how-to/pdm-backend.rst b/docs/how-to/backends/pdm-backend.rst similarity index 100% rename from docs/how-to/pdm-backend.rst rename to docs/how-to/backends/pdm-backend.rst diff --git a/docs/how-to/setuptools.rst b/docs/how-to/backends/setuptools.rst similarity index 100% rename from docs/how-to/setuptools.rst rename to docs/how-to/backends/setuptools.rst diff --git a/pylock.toml b/pylock.toml index 63b8aa8..a45edcf 100644 --- a/pylock.toml +++ b/pylock.toml @@ -12,16 +12,29 @@ extras = [ dependency-groups = [ "bench", "build", + "cibuildwheel", + "delocate", "dev", "docs", + "example", + "flit-core", + "hatchling", "lint", + "maturin", + "meson-python", + "pdm-backend", "pkg-meta", + "poetry-core", "project-runtime", "release-news", "release-notes", "release-prepare", + "scikit-build-core", + "setuptools", "test", "type", + "uv-build", + "zipapp", ] default-groups = [ "project-runtime", @@ -81,6 +94,30 @@ size = 13929 [packages.wheels.hashes] sha256 = "fc6786402dc3fcb2de3cabd5fe455a2db534b371124f1f21de8731783dec828b" +[[packages]] +name = "altgraph" +version = "0.17.5" +marker = "\"delocate\" in dependency_groups" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "altgraph-0.17.5.tar.gz" +upload-time = 2025-11-21T20:35:50.583042+00:00 +url = "https://files.pythonhosted.org/packages/7e/f8/97fdf103f38fed6792a1601dbc16cc8aac56e7459a9fff08c812d8ae177a/altgraph-0.17.5.tar.gz" +size = 48428 + +[packages.sdist.hashes] +sha256 = "c87b395dd12fabde9c99573a9749d67da8d29ef9de0125c7f536699b4a9bc9e7" + +[[packages.wheels]] +name = "altgraph-0.17.5-py2.py3-none-any.whl" +upload-time = 2025-11-21T20:35:49.444851+00:00 +url = "https://files.pythonhosted.org/packages/a9/ba/000a1996d4308bc65120167c21241a3b205464a2e0b58deda26ae8ac21d1/altgraph-0.17.5-py2.py3-none-any.whl" +size = 21228 + +[packages.wheels.hashes] +sha256 = "f3a22400bce1b0c701683820ac4f3b159cd301acab067c51c653e06961600597" + [[packages]] name = "annotated-types" version = "0.8.0" @@ -156,6 +193,31 @@ size = 10196845 [packages.wheels.hashes] sha256 = "e2b422b277c2b9a9630c1d7903c2a00d0830c409c59ac8cae9081c92f1aeba35" +[[packages]] +name = "bashlex" +version = "0.18" +marker = "\"cibuildwheel\" in dependency_groups" +requires-python = "!=3.0,!=3.1,!=3.2,!=3.3,!=3.4,>=2.7" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "bashlex-0.18.tar.gz" +upload-time = 2023-01-18T15:21:26.402367+00:00 +url = "https://files.pythonhosted.org/packages/76/60/aae0bb54f9af5e0128ba90eb83d8d0d506ee8f0475c4fdda3deeda20b1d2/bashlex-0.18.tar.gz" +size = 68742 + +[packages.sdist.hashes] +sha256 = "5bb03a01c6d5676338c36fd1028009c8ad07e7d61d8a1ce3f513b7fff52796ee" + +[[packages.wheels]] +name = "bashlex-0.18-py2.py3-none-any.whl" +upload-time = 2023-01-18T15:21:24.167105+00:00 +url = "https://files.pythonhosted.org/packages/f4/be/6985abb1011fda8a523cfe21ed9629e397d6e06fb5bae99750402b25c95b/bashlex-0.18-py2.py3-none-any.whl" +size = 69539 + +[packages.wheels.hashes] +sha256 = "91d73a23a3e51711919c1c899083890cdecffc91d8c088942725ac13e9dcfffa" + [[packages]] name = "beartype" version = "0.23.1" @@ -234,10 +296,64 @@ size = 26577 [packages.wheels.hashes] sha256 = "ef28a70bd43115208441b53a045d1549e2f0ec6e3d08a9d142cbc41c1938e8d9" +[[packages]] +name = "bracex" +version = "3.2" +marker = "\"cibuildwheel\" in dependency_groups" +requires-python = ">=3.11" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "bracex-3.2.tar.gz" +upload-time = 2026-10-22T00:28:49.508990+00:00 +url = "https://files.pythonhosted.org/packages/fb/37/adf8dd2cde958c2d086bdd87fc36b532fd824bf38f10be6348d65da0c8f9/bracex-3.2.tar.gz" +size = 29771 + +[packages.sdist.hashes] +sha256 = "0a3d40bfae4caae4d3bfd0ea715874799fab711c38fd4012cc35343e815405cd" + +[[packages.wheels]] +name = "bracex-3.2-py3-none-any.whl" +upload-time = 2026-10-22T00:28:48.233434+00:00 +url = "https://files.pythonhosted.org/packages/42/65/8030b03de8137d1aab7dd6ecfecdba2fc22fc849fa35959b024f62293a99/bracex-3.2-py3-none-any.whl" +size = 12019 + +[packages.wheels.hashes] +sha256 = "8f3e908a452f66707e1d6d91b3d7d7d4c649d248df18537c0dc710aeb9c30d87" + +[[packages]] +name = "build" +version = "1.6.1" +marker = "\"cibuildwheel\" in dependency_groups or \"delocate\" in dependency_groups or \"example\" in dependency_groups or \"flit-core\" in dependency_groups or \"hatchling\" in dependency_groups or \"maturin\" in dependency_groups or \"meson-python\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"poetry-core\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"setuptools\" in dependency_groups or \"uv-build\" in dependency_groups or \"zipapp\" in dependency_groups" +requires-python = ">=3.10" +dependencies = [ + { name = "packaging" }, + { name = "pyproject-hooks" }, +] +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "build-1.6.1.tar.gz" +upload-time = 2026-09-10T07:56:00.417084+00:00 +url = "https://files.pythonhosted.org/packages/bd/67/4898a44ea4f3f8e213b0954ec0aa0a16971d62a6212d6ea3931e97115b99/build-1.6.1.tar.gz" +size = 113427 + +[packages.sdist.hashes] +sha256 = "51cc11666391ab6f092070437ac747002ff46f3e4113a3622177ee6b488bfc53" + +[[packages.wheels]] +name = "build-1.6.1-py3-none-any.whl" +upload-time = 2026-09-10T07:55:59.148398+00:00 +url = "https://files.pythonhosted.org/packages/ad/9b/9fb3585dabcd73a1b2a6267f63f62649347c9e6d072c9fde365b105abb2c/build-1.6.1-py3-none-any.whl" +size = 31179 + +[packages.wheels.hashes] +sha256 = "ecd351a4be9d35a9eaaba244a7687143c9c7d4aea6ac964e7e7ddab20cbcf4e7" + [[packages]] name = "certifi" version = "2026.10.23" -marker = "\"dev\" in dependency_groups or \"docs\" in dependency_groups or \"pkg-meta\" in dependency_groups or \"type\" in dependency_groups" +marker = "\"cibuildwheel\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"pkg-meta\" in dependency_groups or \"type\" in dependency_groups" requires-python = ">=3.7" index = "https://pypi.org/simple/" @@ -387,6 +503,42 @@ size = 27541 [packages.wheels.hashes] sha256 = "5ae39c8c434b972f0740d04610759168590713175aab584b012b1b84f6771874" +[[packages]] +name = "cibuildwheel" +version = "4.3.5" +marker = "\"cibuildwheel\" in dependency_groups" +requires-python = ">=3.11" +dependencies = [ + { name = "bashlex" }, + { name = "bracex" }, + { name = "build" }, + { name = "certifi" }, + { name = "dependency-groups" }, + { name = "filelock" }, + { name = "humanize" }, + { name = "packaging" }, + { name = "platformdirs" }, +] +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "cibuildwheel-4.3.5.tar.gz" +upload-time = 2026-10-27T19:01:55.682659+00:00 +url = "https://files.pythonhosted.org/packages/97/08/284f916363482d28ba98cf4517283f89ec5c3bd8acfa43b1049b9a5ed486/cibuildwheel-4.3.5.tar.gz" +size = 464371 + +[packages.sdist.hashes] +sha256 = "43c30292b9ec8d08a8eb3873436e64d4d1434c5dcbc855fb0afbfc69732048f1" + +[[packages.wheels]] +name = "cibuildwheel-4.3.5-py3-none-any.whl" +upload-time = 2026-10-27T19:01:53.729105+00:00 +url = "https://files.pythonhosted.org/packages/c9/ad/ebdaf81b0f29b86906a6c4ad0253796204853111fdd3a1d041d7b1bf92d0/cibuildwheel-4.3.5-py3-none-any.whl" +size = 170368 + +[packages.wheels.hashes] +sha256 = "2297362cb7a0a12cd681788197811e1f3d700bd31f6decaab051837c90d4e3ba" + [[packages]] name = "click" version = "8.5.0" @@ -412,10 +564,35 @@ size = 125251 [packages.wheels.hashes] sha256 = "255bc9599cf7748b4b1a446ccc735421bd08a2ae529a8b88597d3de5664ee360" +[[packages]] +name = "cmake" +version = "4.4.4" +marker = "\"scikit-build-core\" in dependency_groups" +requires-python = ">=3.8" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "cmake-4.4.4.tar.gz" +upload-time = 2026-10-04T09:10:05.134128+00:00 +url = "https://files.pythonhosted.org/packages/14/2a/88d51f5fc74358edb89afedeb8154db0d9c0bbd256747bf28de472e4fa5c/cmake-4.4.4.tar.gz" +size = 13287563 + +[packages.sdist.hashes] +sha256 = "f337d18e33b116cabae9a7a8ff423fc0bc3f389da0acefeb724e1397128dcc34" + +[[packages.wheels]] +name = "cmake-4.4.4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl" +upload-time = 2026-10-04T09:09:24.551288+00:00 +url = "https://files.pythonhosted.org/packages/7e/d5/664ea06d01864f25d6067f09fa218404e4d588edd5e495135ac91429fecb/cmake-4.4.4-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl" +size = 30245729 + +[packages.wheels.hashes] +sha256 = "f773a0544c66370408f451acd487c2c643b0dfebb48c5d64f3638bc1bb820238" + [[packages]] name = "covdefaults" version = "2.3.0" -marker = "\"bench\" in dependency_groups or \"dev\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups" +marker = "\"bench\" in dependency_groups or \"cibuildwheel\" in dependency_groups or \"delocate\" in dependency_groups or \"dev\" in dependency_groups or \"example\" in dependency_groups or \"flit-core\" in dependency_groups or \"hatchling\" in dependency_groups or \"maturin\" in dependency_groups or \"meson-python\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"poetry-core\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"setuptools\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"uv-build\" in dependency_groups or \"zipapp\" in dependency_groups" requires-python = ">=3.7" dependencies = [ { name = "coverage" }, @@ -443,7 +620,7 @@ sha256 = "2832961f6ffcfe4b57c338bc3418a3526f495c26fb9c54565409c5532f7c41be" [[packages]] name = "coverage" version = "7.17.0" -marker = "\"bench\" in dependency_groups or \"dev\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups" +marker = "\"bench\" in dependency_groups or \"cibuildwheel\" in dependency_groups or \"delocate\" in dependency_groups or \"dev\" in dependency_groups or \"example\" in dependency_groups or \"flit-core\" in dependency_groups or \"hatchling\" in dependency_groups or \"maturin\" in dependency_groups or \"meson-python\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"poetry-core\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"setuptools\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"uv-build\" in dependency_groups or \"zipapp\" in dependency_groups" requires-python = ">=3.11" index = "https://pypi.org/simple/" @@ -574,6 +751,64 @@ size = 4780973 [packages.wheels.hashes] sha256 = "1981f1db4630889b9ef7803fadef12b056f428cb6b85c27ba57b774793b6093c" +[[packages]] +name = "delocate" +version = "0.13.0" +marker = "\"delocate\" in dependency_groups" +requires-python = ">=3.9" +dependencies = [ + { name = "macholib" }, + { name = "packaging" }, + { name = "typing-extensions" }, +] +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "delocate-0.13.0.tar.gz" +upload-time = 2025-01-30T06:43:43.632641+00:00 +url = "https://files.pythonhosted.org/packages/2d/21/f1679803b2582632e7b9fdd83e675d5fc661513433c0f661938414978bc7/delocate-0.13.0.tar.gz" +size = 240774 + +[packages.sdist.hashes] +sha256 = "a93e67a9f56ee01a3f7096a042231d4ac37fecac873cd5ea34ea2b4f43a8fa13" + +[[packages.wheels]] +name = "delocate-0.13.0-py3-none-any.whl" +upload-time = 2025-01-30T06:43:41.113220+00:00 +url = "https://files.pythonhosted.org/packages/2b/dd/437e601fa9d2b6bf8507256daf52196a226c3b340261f4cde8fac8e853ea/delocate-0.13.0-py3-none-any.whl" +size = 238040 + +[packages.wheels.hashes] +sha256 = "11f7596f88984c33f76b27fe2eea7637d1ce369a9e0b6737bbc706b6426e862c" + +[[packages]] +name = "dependency-groups" +version = "1.3.2" +marker = "\"cibuildwheel\" in dependency_groups" +requires-python = ">=3.9" +dependencies = [ + { name = "packaging" }, +] +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "dependency_groups-1.3.2.tar.gz" +upload-time = 2026-08-22T02:43:30.137764+00:00 +url = "https://files.pythonhosted.org/packages/b5/16/65e61d8e837e0d70a99a0d4dd76e2af53357c3a03ed1db8ad9b5786d7f25/dependency_groups-1.3.2.tar.gz" +size = 13309 + +[packages.sdist.hashes] +sha256 = "c81831f43828dbc3987ee247eb198241a0152b8e7ceab10977cc3808eb388ac7" + +[[packages.wheels]] +name = "dependency_groups-1.3.2-py3-none-any.whl" +upload-time = 2026-08-22T02:43:28.853754+00:00 +url = "https://files.pythonhosted.org/packages/a1/e4/da5f2f176050efcfb9222a76a3e81c41f69f775be8e563b76ca4292a134f/dependency_groups-1.3.2-py3-none-any.whl" +size = 9802 + +[packages.wheels.hashes] +sha256 = "8c337f7b92445823b0d0ea507f611390c58dcd2112be00aebcd738a2ca7a1c64" + [[packages]] name = "distlib" version = "0.4.4" @@ -626,7 +861,7 @@ sha256 = "25d013af9bf23bc1c7b2b093dff4208166c53a94786c9e447808335ef1185fea" [[packages]] name = "filelock" version = "4.2.5" -marker = "\"dev\" in dependency_groups or \"lint\" in dependency_groups" +marker = "\"cibuildwheel\" in dependency_groups or \"dev\" in dependency_groups or \"lint\" in dependency_groups" requires-python = ">=3.11" index = "https://pypi.org/simple/" @@ -651,7 +886,7 @@ sha256 = "46ce42d27e5cdde09ee7197349663e97cb106679bd9e75db3a09679fbc7aa1a8" [[packages]] name = "flit-core" version = "4.2.0" -marker = "\"bench\" in dependency_groups or \"dev\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups" +marker = "\"bench\" in dependency_groups or \"dev\" in dependency_groups or \"flit-core\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups" requires-python = ">=3.8" index = "https://pypi.org/simple/" @@ -765,7 +1000,7 @@ sha256 = "b49677dbdc597460cc22d01b27ab3696f5e16a21ecf2700fb01bc28e1f2a04a7" [[packages]] name = "hatchling" version = "1.33.0" -marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"hatch\" in extras" +marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"hatchling\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"zipapp\" in dependency_groups or \"hatch\" in extras" requires-python = ">=3.10" dependencies = [ { name = "packaging" }, @@ -794,6 +1029,31 @@ size = 78750 [packages.wheels.hashes] sha256 = "415290b84f464d2884303fca8974d38e7b85579069fab02a15db0828fbb1446d" +[[packages]] +name = "humanize" +version = "4.16.0" +marker = "\"cibuildwheel\" in dependency_groups" +requires-python = ">=3.10" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "humanize-4.16.0.tar.gz" +upload-time = 2026-06-30T16:17:29.859993+00:00 +url = "https://files.pythonhosted.org/packages/0a/ea/13a1ef3c12d12662905801495283530251918b70d62d368f1d2e0272c70d/humanize-4.16.0.tar.gz" +size = 89515 + +[packages.sdist.hashes] +sha256 = "7dc2244a2f84a4bfb1d36c37bac80cd78e35cdc5c119206d87b018e1445f3a3f" + +[[packages.wheels]] +name = "humanize-4.16.0-py3-none-any.whl" +upload-time = 2026-06-30T16:17:28.360556+00:00 +url = "https://files.pythonhosted.org/packages/b0/aa/0b7365d30fed43e7a3449aba1fe20a0a7174d9cf13e282af4e69ac825441/humanize-4.16.0-py3-none-any.whl" +size = 137209 + +[packages.wheels.hashes] +sha256 = "353eb2f34c09d098b2880eee8bef21832eae6d174f48c5762fff7e5fcb74d01d" + [[packages]] name = "id" version = "1.6.1" @@ -900,7 +1160,7 @@ sha256 = "ea0c9a0384df69ed86a943a15cde37d0360b82491b3910dc2215e202e62b5b02" [[packages]] name = "iniconfig" version = "2.3.1" -marker = "\"bench\" in dependency_groups or \"dev\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups" +marker = "\"bench\" in dependency_groups or \"cibuildwheel\" in dependency_groups or \"delocate\" in dependency_groups or \"dev\" in dependency_groups or \"example\" in dependency_groups or \"flit-core\" in dependency_groups or \"hatchling\" in dependency_groups or \"maturin\" in dependency_groups or \"meson-python\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"poetry-core\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"setuptools\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"uv-build\" in dependency_groups or \"zipapp\" in dependency_groups" requires-python = ">=3.10" index = "https://pypi.org/simple/" @@ -1166,6 +1426,33 @@ size = 120615 [packages.wheels.hashes] sha256 = "421788fdcadb41f049d2dc934ce666626265aeccefddd25e162a26f23bcbf8a4" +[[packages]] +name = "macholib" +version = "1.16.4" +marker = "\"delocate\" in dependency_groups" +dependencies = [ + { name = "altgraph" }, +] +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "macholib-1.16.4.tar.gz" +upload-time = 2025-11-22T08:28:38.373493+00:00 +url = "https://files.pythonhosted.org/packages/10/2f/97589876ea967487978071c9042518d28b958d87b17dceb7cdc1d881f963/macholib-1.16.4.tar.gz" +size = 59427 + +[packages.sdist.hashes] +sha256 = "f408c93ab2e995cd2c46e34fe328b130404be143469e41bc366c807448979362" + +[[packages.wheels]] +name = "macholib-1.16.4-py2.py3-none-any.whl" +upload-time = 2025-11-22T08:28:36.939302+00:00 +url = "https://files.pythonhosted.org/packages/c7/d1/a9f36f8ecdf0fb7c9b1e78c8d7af12b8c8754e74851ac7b94a8305540fc7/macholib-1.16.4-py2.py3-none-any.whl" +size = 38117 + +[packages.wheels.hashes] +sha256 = "da1a3fa8266e30f0ce7e97c6a54eefaae8edd1e5f86f3eb8b95457cae90265ea" + [[packages]] name = "markdown-it-py" version = "4.2.0" @@ -1219,6 +1506,31 @@ size = 23111 [packages.wheels.hashes] sha256 = "925f929d6b59a8b3f8b8c6ac363cd0af7eecc81efb3071770b3c6717c450a369" +[[packages]] +name = "maturin" +version = "1.16.0" +marker = "\"maturin\" in dependency_groups" +requires-python = ">=3.7" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "maturin-1.16.0.tar.gz" +upload-time = 2026-10-29T14:09:43.096461+00:00 +url = "https://files.pythonhosted.org/packages/bd/71/eb078174335ff30bde1be2ad54fb6256db4b160eb3efa81163fa30f8c814/maturin-1.16.0.tar.gz" +size = 396641 + +[packages.sdist.hashes] +sha256 = "13e69ca12542999d8c5467131de72a49bb76e4c284b9a45c5783df7c0fcb3a8a" + +[[packages.wheels]] +name = "maturin-1.16.0-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.musllinux_1_1_x86_64.whl" +upload-time = 2026-10-29T14:09:16.110052+00:00 +url = "https://files.pythonhosted.org/packages/0a/dc/e77f490557cb5e045a75c3d18a7965425ac576235c970dfff4d903eb2c74/maturin-1.16.0-py3-none-manylinux2010_x86_64.manylinux_2_12_x86_64.musllinux_1_1_x86_64.whl" +size = 10763361 + +[packages.wheels.hashes] +sha256 = "837db2f4d93d4899c3ac393fb3cc9eebf35b6002336e5d574f4a4fb6c49fe283" + [[packages]] name = "mdformat" version = "1.0.0" @@ -1331,6 +1643,61 @@ size = 9979 [packages.wheels.hashes] sha256 = "84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8" +[[packages]] +name = "meson" +version = "1.12.1" +marker = "\"delocate\" in dependency_groups or \"meson-python\" in dependency_groups" +requires-python = ">=3.10" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "meson-1.12.1.tar.gz" +upload-time = 2026-09-22T22:58:28.875366+00:00 +url = "https://files.pythonhosted.org/packages/f9/c9/8c9983f4f3d9c4e22fd76bcf8cd053e4472aefae45fd044669b6daa34b53/meson-1.12.1.tar.gz" +size = 2524665 + +[packages.sdist.hashes] +sha256 = "ab0a6ca09f8ef70c564c8241fb5a23957886a0b53fb58412b5e07eaf07dba743" + +[[packages.wheels]] +name = "meson-1.12.1-py3-none-any.whl" +upload-time = 2026-09-22T22:58:26.047814+00:00 +url = "https://files.pythonhosted.org/packages/57/99/36cd25f9598eef70db97577440a70a360af505f6f01c2338a18d1556079c/meson-1.12.1-py3-none-any.whl" +size = 1108668 + +[packages.wheels.hashes] +sha256 = "930bc7542cbd9f57009e182fd014eba48cf1a0180a7b9006d2d32d8f168d8b02" + +[[packages]] +name = "meson-python" +version = "0.22.1" +marker = "\"delocate\" in dependency_groups or \"meson-python\" in dependency_groups" +requires-python = ">=3.10" +dependencies = [ + { name = "meson" }, + { name = "packaging" }, + { name = "pyproject-metadata" }, +] +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "meson_python-0.22.1.tar.gz" +upload-time = 2026-10-01T23:17:15.251548+00:00 +url = "https://files.pythonhosted.org/packages/b4/40/343ae23722d5d66a7b94b752d1b194202640995296379333b274b1860871/meson_python-0.22.1.tar.gz" +size = 121887 + +[packages.sdist.hashes] +sha256 = "52c88628b0e5671592dc2306613fb5f6f3615fd24def059b9894f143b7f9a139" + +[[packages.wheels]] +name = "meson_python-0.22.1-py3-none-any.whl" +upload-time = 2026-10-01T23:17:13.760319+00:00 +url = "https://files.pythonhosted.org/packages/96/62/0c1cf20fe158b0e623e78acbf5fb6de5f1410a408f65f727e4090497627b/meson_python-0.22.1-py3-none-any.whl" +size = 31271 + +[packages.wheels.hashes] +sha256 = "258fde948cf45aab5df23fcc9e17a9050ee73d4e1002fe6cf86519f61c414778" + [[packages]] name = "more-itertools" version = "11.2.1" @@ -1381,6 +1748,31 @@ size = 832161 [packages.wheels.hashes] sha256 = "70f5ac8626e899a4bab0ef74ca2f5bd602f49c7b739e6e5026b4afc6d63dac42" +[[packages]] +name = "ninja" +version = "1.13.2" +marker = "\"delocate\" in dependency_groups or \"meson-python\" in dependency_groups or \"scikit-build-core\" in dependency_groups" +requires-python = ">=3.8" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "ninja-1.13.2.tar.gz" +upload-time = 2026-08-30T15:49:51.897613+00:00 +url = "https://files.pythonhosted.org/packages/ac/92/410b7917d16ab54c04b05cc32b9284803671d91cf79d33be6009c28d4ea8/ninja-1.13.2.tar.gz" +size = 243739 + +[packages.sdist.hashes] +sha256 = "525bfa3fc88aa30a4467df270fd5be6f9fcae8061d54d4df74ea1dc5abd5a975" + +[[packages.wheels]] +name = "ninja-1.13.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl" +upload-time = 2026-08-30T15:49:34.530024+00:00 +url = "https://files.pythonhosted.org/packages/6e/53/ebfed7b689c338dd8ebeec9c0730c8d56821292f14e2536e5f3ef1a05744/ninja-1.13.2-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl" +size = 183365 + +[packages.wheels.hashes] +sha256 = "65a24341b5ac09fcadcc37082660be40a94174e51a937fabf6e2cae26225fa2c" + [[packages]] name = "nodeenv" version = "1.11.1" @@ -1434,7 +1826,7 @@ sha256 = "31a85c2717bc41dd818f3c62908685ff9eebcb68588213745b14a6ee9e7df7c9" [[packages]] name = "packaging" version = "26.3" -marker = "\"hatch\" in extras or \"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"lint\" in dependency_groups or \"pkg-meta\" in dependency_groups or \"project-runtime\" in dependency_groups or \"release-news\" in dependency_groups or \"release-notes\" in dependency_groups or \"release-prepare\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups" +marker = "\"hatch\" in extras or \"bench\" in dependency_groups or \"build\" in dependency_groups or \"cibuildwheel\" in dependency_groups or \"delocate\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"example\" in dependency_groups or \"flit-core\" in dependency_groups or \"hatchling\" in dependency_groups or \"lint\" in dependency_groups or \"maturin\" in dependency_groups or \"meson-python\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"pkg-meta\" in dependency_groups or \"poetry-core\" in dependency_groups or \"project-runtime\" in dependency_groups or \"release-news\" in dependency_groups or \"release-notes\" in dependency_groups or \"release-prepare\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"setuptools\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"uv-build\" in dependency_groups or \"zipapp\" in dependency_groups" requires-python = ">=3.9" index = "https://pypi.org/simple/" @@ -1459,7 +1851,7 @@ sha256 = "d7193f7c8e4e93f444fde0262bf90af30e16fa0ad0ad44cb553c87339b23cd1c" [[packages]] name = "pathspec" version = "1.1.1" -marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"hatch\" in extras" +marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"hatchling\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"zipapp\" in dependency_groups or \"hatch\" in extras" requires-python = ">=3.9" index = "https://pypi.org/simple/" @@ -1484,7 +1876,7 @@ sha256 = "a00ce642f577bf7f473932318056212bc4f8bfdf53128c78bbd5af0b9b20b189" [[packages]] name = "pdm-backend" version = "2.5.0" -marker = "\"bench\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"pdm\" in extras" +marker = "\"bench\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"pdm\" in extras" requires-python = ">=3.9" index = "https://pypi.org/simple/" @@ -1509,7 +1901,7 @@ sha256 = "5b8746b567a16a1fd506ce66ee28e89d46374526f52238aa1b96cc2c08245c63" [[packages]] name = "platformdirs" version = "4.14.0" -marker = "\"dev\" in dependency_groups or \"lint\" in dependency_groups" +marker = "\"cibuildwheel\" in dependency_groups or \"dev\" in dependency_groups or \"lint\" in dependency_groups" requires-python = ">=3.11" index = "https://pypi.org/simple/" @@ -1534,7 +1926,7 @@ sha256 = "1dadfc59a8a5d7565b3d9270ae8fa71c065595352c4277b41c11ee6c222c4b91" [[packages]] name = "pluggy" version = "1.7.0" -marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"hatch\" in extras" +marker = "\"hatch\" in extras or \"bench\" in dependency_groups or \"build\" in dependency_groups or \"cibuildwheel\" in dependency_groups or \"delocate\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"example\" in dependency_groups or \"flit-core\" in dependency_groups or \"hatchling\" in dependency_groups or \"maturin\" in dependency_groups or \"meson-python\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"poetry-core\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"setuptools\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"uv-build\" in dependency_groups or \"zipapp\" in dependency_groups" requires-python = ">=3.10" index = "https://pypi.org/simple/" @@ -1580,6 +1972,31 @@ size = 49567 [packages.wheels.hashes] sha256 = "096f9b8350b65ebd2fd1346b12452efe5b9607f7482813ffca50c22722a807ce" +[[packages]] +name = "poetry-core" +version = "2.5.0" +marker = "\"poetry-core\" in dependency_groups" +requires-python = "<4.0,>=3.10" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "poetry_core-2.5.0.tar.gz" +upload-time = 2026-09-19T17:47:10.230654+00:00 +url = "https://files.pythonhosted.org/packages/42/b5/50f1fda26c4fe5b1d6ce5cdf0391bdfa1ca12fdcb8ad68344d5cf678fc90/poetry_core-2.5.0.tar.gz" +size = 455721 + +[packages.sdist.hashes] +sha256 = "81d04c9253b19d0604718268d781867c8f7b2128e5b25bbf1e84141eec6b89c4" + +[[packages.wheels]] +name = "poetry_core-2.5.0-py3-none-any.whl" +upload-time = 2026-09-19T17:47:08.728607+00:00 +url = "https://files.pythonhosted.org/packages/b7/25/7ed0a2ea4fe12f7fd0394387b5debbcd6fdbd06e5ac9daab96ba11471da8/poetry_core-2.5.0-py3-none-any.whl" +size = 413562 + +[packages.wheels.hashes] +sha256 = "98ee465b66f7e14bb9fbe68fb5e00d0cff184f036993ec94610ae4b5612f3add" + [[packages]] name = "pre-commit" version = "4.7.0" @@ -1778,7 +2195,7 @@ sha256 = "5299296ff5cafcb69851fd652de8f9268a0bb036bcbedbfcaa94cf743baf3986" [[packages]] name = "pygments" version = "2.21.0" -marker = "\"bench\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"pkg-meta\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups" +marker = "\"bench\" in dependency_groups or \"cibuildwheel\" in dependency_groups or \"delocate\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"example\" in dependency_groups or \"flit-core\" in dependency_groups or \"hatchling\" in dependency_groups or \"maturin\" in dependency_groups or \"meson-python\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"pkg-meta\" in dependency_groups or \"poetry-core\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"setuptools\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"uv-build\" in dependency_groups or \"zipapp\" in dependency_groups" requires-python = ">=3.9" index = "https://pypi.org/simple/" @@ -1853,10 +2270,63 @@ size = 144430 [packages.wheels.hashes] sha256 = "79196bc4a11e3c926dd4c6b14c80136c6b37f884fe913cbc57037f37636e9841" +[[packages]] +name = "pyproject-hooks" +version = "1.3.3" +marker = "\"cibuildwheel\" in dependency_groups or \"delocate\" in dependency_groups or \"example\" in dependency_groups or \"flit-core\" in dependency_groups or \"hatchling\" in dependency_groups or \"maturin\" in dependency_groups or \"meson-python\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"poetry-core\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"setuptools\" in dependency_groups or \"uv-build\" in dependency_groups or \"zipapp\" in dependency_groups" +requires-python = ">=3.8" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "pyproject_hooks-1.3.3.tar.gz" +upload-time = 2026-09-16T08:58:03.999217+00:00 +url = "https://files.pythonhosted.org/packages/6d/5d/f2ddeef4a855a102aaae5e97826a0260007522ab504421b75addfdb1517c/pyproject_hooks-1.3.3.tar.gz" +size = 21013 + +[packages.sdist.hashes] +sha256 = "defda19b854fa0d3bd4f76ea4ddcba8abd7dcfcdd585a6690ade050744fc5f43" + +[[packages.wheels]] +name = "pyproject_hooks-1.3.3-py3-none-any.whl" +upload-time = 2026-09-16T08:58:02.960279+00:00 +url = "https://files.pythonhosted.org/packages/85/11/044d1ae1b4ec0d7af88ee5bc91e081be1022533032b906a7bdabdbb60977/pyproject_hooks-1.3.3-py3-none-any.whl" +size = 10724 + +[packages.wheels.hashes] +sha256 = "5fc53fdac9f7bd63fbcdc868fb5f90b4784d78a53a3d3388cd738b807441a20b" + +[[packages]] +name = "pyproject-metadata" +version = "0.12.1" +marker = "\"delocate\" in dependency_groups or \"meson-python\" in dependency_groups" +requires-python = ">=3.8" +dependencies = [ + { name = "packaging" }, +] +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "pyproject_metadata-0.12.1.tar.gz" +upload-time = 2026-07-04T02:19:32.029773+00:00 +url = "https://files.pythonhosted.org/packages/4f/76/1cae539918a7b1746d624c2f01560b793c22cd8c081157505bb9bbf0e34d/pyproject_metadata-0.12.1.tar.gz" +size = 48457 + +[packages.sdist.hashes] +sha256 = "8809a4df6fe08279b39a8890669506ed3158e0617855ac9aff098fcbe772ae4c" + +[[packages.wheels]] +name = "pyproject_metadata-0.12.1-py3-none-any.whl" +upload-time = 2026-07-04T02:19:30.657500+00:00 +url = "https://files.pythonhosted.org/packages/b9/8e/d883718e872abc214ba053f60f7e6edc2abd5ffbd1544beb01a9c92ddd3c/pyproject_metadata-0.12.1-py3-none-any.whl" +size = 23452 + +[packages.wheels.hashes] +sha256 = "f7162d580a96386a8eb096da06215f981f547d1490f03055ef99e323bc2da427" + [[packages]] name = "pytest" version = "9.2.0" -marker = "\"bench\" in dependency_groups or \"dev\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups" +marker = "\"bench\" in dependency_groups or \"cibuildwheel\" in dependency_groups or \"delocate\" in dependency_groups or \"dev\" in dependency_groups or \"example\" in dependency_groups or \"flit-core\" in dependency_groups or \"hatchling\" in dependency_groups or \"maturin\" in dependency_groups or \"meson-python\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"poetry-core\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"setuptools\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"uv-build\" in dependency_groups or \"zipapp\" in dependency_groups" requires-python = ">=3.10" dependencies = [ { name = "iniconfig" }, @@ -1887,7 +2357,7 @@ sha256 = "07acdcf88ec174f907dc01af70bf52d49b014bbab03faeeade31c96b18c2e588" [[packages]] name = "pytest-cov" version = "7.1.0" -marker = "\"bench\" in dependency_groups or \"dev\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups" +marker = "\"bench\" in dependency_groups or \"cibuildwheel\" in dependency_groups or \"delocate\" in dependency_groups or \"dev\" in dependency_groups or \"example\" in dependency_groups or \"flit-core\" in dependency_groups or \"hatchling\" in dependency_groups or \"maturin\" in dependency_groups or \"meson-python\" in dependency_groups or \"pdm-backend\" in dependency_groups or \"poetry-core\" in dependency_groups or \"scikit-build-core\" in dependency_groups or \"setuptools\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"uv-build\" in dependency_groups or \"zipapp\" in dependency_groups" requires-python = ">=3.9" dependencies = [ { name = "coverage" }, @@ -2215,6 +2685,35 @@ size = 7676 [packages.wheels.hashes] sha256 = "647ba99caddc2cc1e55a51e4360689115551bf4476d90e8162cf8c345fe233c7" +[[packages]] +name = "scikit-build-core" +version = "1.1.1" +marker = "\"scikit-build-core\" in dependency_groups" +requires-python = ">=3.9" +dependencies = [ + { name = "packaging" }, + { name = "pathspec" }, +] +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "scikit_build_core-1.1.1.tar.gz" +upload-time = 2026-10-02T19:18:37.596431+00:00 +url = "https://files.pythonhosted.org/packages/b2/1a/8c00b19c0a1e7acf890676af2efa430339d38e59fa9437f2aab8517af3f4/scikit_build_core-1.1.1.tar.gz" +size = 516192 + +[packages.sdist.hashes] +sha256 = "e347a59193c878ac56a363e57506938652a6dd8c965790cb1cbc6bc7e8d5abad" + +[[packages.wheels]] +name = "scikit_build_core-1.1.1-py3-none-any.whl" +upload-time = 2026-10-02T19:18:36.087754+00:00 +url = "https://files.pythonhosted.org/packages/01/1b/83913d6d5c6a7f8ad5bf5d67b2d57ab09475f1bb9dd0c7a3f44067d59b90/scikit_build_core-1.1.1-py3-none-any.whl" +size = 293450 + +[packages.wheels.hashes] +sha256 = "6f6d6cf600e2e9639fd258ecd11cfc19bd189354b968916a519c6793e7e26237" + [[packages]] name = "secretstorage" version = "3.5.0" @@ -2272,7 +2771,7 @@ sha256 = "de78a3b8e0feda74cabc54aab2da702113e33ac9d9eb9d2389bcf1f58b7d9177" [[packages]] name = "setuptools" version = "84.2.1" -marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"setuptools\" in extras" +marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"setuptools\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"setuptools\" in extras" requires-python = ">=3.10" index = "https://pypi.org/simple/" @@ -2804,7 +3303,7 @@ sha256 = "6e2cb0eef194e10c27ec0023bfeb25badbbb5868244cf5bc5bdc04e4464bf331" [[packages]] name = "tomlkit" version = "0.15.2" -marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"hatch\" in extras" +marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"hatchling\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"zipapp\" in dependency_groups or \"hatch\" in extras" requires-python = ">=3.9" index = "https://pypi.org/simple/" @@ -2858,7 +3357,7 @@ sha256 = "ae4d223e6aadaff98d29b7f09e58d9c9ccf4cd3b455a2d2e0486d432cd8bf660" [[packages]] name = "trove-classifiers" version = "2026.9.21.13" -marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"hatch\" in extras" +marker = "\"bench\" in dependency_groups or \"build\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"hatchling\" in dependency_groups or \"test\" in dependency_groups or \"type\" in dependency_groups or \"zipapp\" in dependency_groups or \"hatch\" in extras" index = "https://pypi.org/simple/" [packages.sdist] @@ -2943,7 +3442,7 @@ sha256 = "6d47be2db5db80cd70c582b240a71dd8e9be215ce9288298c863c7c3611ef02b" [[packages]] name = "typing-extensions" version = "4.16.0" -marker = "\"dev\" in dependency_groups or \"docs\" in dependency_groups or \"pkg-meta\" in dependency_groups or \"type\" in dependency_groups" +marker = "\"delocate\" in dependency_groups or \"dev\" in dependency_groups or \"docs\" in dependency_groups or \"pkg-meta\" in dependency_groups or \"type\" in dependency_groups" requires-python = ">=3.9" index = "https://pypi.org/simple/" @@ -3068,6 +3567,31 @@ size = 17333810 [packages.wheels.hashes] sha256 = "22759b8895e1103578de6fb4cd27e94b4399d021023378d29f01333717751fba" +[[packages]] +name = "uv-build" +version = "0.13.6" +marker = "\"uv-build\" in dependency_groups" +requires-python = ">=3.8" +index = "https://pypi.org/simple/" + +[packages.sdist] +name = "uv_build-0.13.6.tar.gz" +upload-time = 2026-10-27T00:45:23.129719+00:00 +url = "https://files.pythonhosted.org/packages/8f/98/8b9e028aa5d00f4c6f48183f3a2d9d343cd3adeb21bbd6dcc24916cd1538/uv_build-0.13.6.tar.gz" +size = 470673 + +[packages.sdist.hashes] +sha256 = "8a03355d73117d136dbf6a34e20429755598a73d752dc6ae3aa5894942b6fd4b" + +[[packages.wheels]] +name = "uv_build-0.13.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" +upload-time = 2026-10-27T00:45:09.462059+00:00 +url = "https://files.pythonhosted.org/packages/de/43/b2fb76e750ad2b0e3d229f96e066c62bd237db4f85f542b15476345ab82d/uv_build-0.13.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" +size = 1336304 + +[packages.wheels.hashes] +sha256 = "b23bbf1393acb47c1bd434f79daa91c158a14a504894485b5a9948f68d63170b" + [[packages]] name = "vcs-versioning" version = "2.6.0" @@ -3256,6 +3780,6 @@ platforms = [ [tool.nab.validation] version = 1 -all-inputs-sha256 = "4dafd95d61798da174d4b26af09530beecfc187b4e057d2b1b5341bf64a2c284" -selection-inputs-sha256 = "33c6780a0dd69f7f771ac2b8d2e37670c4eb5032e8bfaf5ea560df206ba95955" -contents-sha256 = "6dea5954bbdb8926ab3752c0a47e66dc572d3176889d239108a220092b0a4bc1" +all-inputs-sha256 = "8aa355f4b82a36557184f7ad1d7371fa543d87d6c74d90f845353792ed9270c2" +selection-inputs-sha256 = "805268f7d0f2a4ebfdd771a30b5a8805b5b635d5a8154627aef8fbb43fe52ac9" +contents-sha256 = "b7167570fd0c38375480f42b84d1200c4c3d70c3ee6d66872f38bfd35e8c9a5e" diff --git a/pyproject.toml b/pyproject.toml index a507532..a820327 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -139,8 +139,28 @@ build = [ "packageurl-python>=0.11.1", "zipremove>=0.10", ] +cibuildwheel = [ { include-group = "example" }, "cibuildwheel>=4.3.5" ] +delocate = [ + { include-group = "example" }, + "delocate>=0.13", + "meson>=1.12.1", + "meson-python>=0.22.1", + "ninja>=1.13.2", +] +example = [ + "build>=1.6.1", + "covdefaults>=2.3", + "pytest>=9.1.1", + "pytest-cov>=7.1", +] +flit-core = [ { include-group = "example" }, "flit-core>=3.12" ] +hatchling = [ { include-group = "example" }, "hatchling>=1.28" ] lint = [ "pre-commit-uv>=4.3" ] +maturin = [ { include-group = "example" }, "maturin>=1.15,<2" ] +meson-python = [ { include-group = "example" }, "meson>=1.12.1", "meson-python>=0.22.1", "ninja>=1.13.2" ] +pdm-backend = [ { include-group = "example" }, "pdm-backend>=2.4" ] pkg-meta = [ "check-wheel-contents>=0.6.3", "twine>=7", "uv>=0.12.22" ] +poetry-core = [ { include-group = "example" }, "poetry-core>=2.5" ] release-news = [ "release-creator>=4.4", "towncrier>=26.9", @@ -153,6 +173,10 @@ release-prepare = [ "release-creator>=4.4", "towncrier>=26.9", ] +scikit-build-core = [ { include-group = "example" }, "cmake>=4.4.4", "ninja>=1.13.2", "scikit-build-core>=1.1" ] +setuptools = [ { include-group = "example" }, "setuptools>=77" ] +uv-build = [ { include-group = "example" }, "uv-build>=0.13.6" ] +zipapp = [ { include-group = "example" }, "hatchling>=1.28" ] [tool.hatch] version.source = "vcs" @@ -200,6 +224,9 @@ lint.per-file-ignores."bench/**/*.py" = [ "subprocess-without-shell-equals-true", # Commands are fixed argument lists the harness builds "suspicious-subprocess-import", # Fixtures and cold cases run git, uv and Python processes ] +lint.per-file-ignores."docs/examples/**/*.py" = [ + "implicit-namespace-package", # Each example is a project of its own, with a src layout +] lint.per-file-ignores."tests/**/*.py" = [ "assert", # Tests use assertions "D", # Test names document behavior diff --git a/tests/examples/cibuildwheel/test_cibuildwheel.py b/tests/examples/cibuildwheel/test_cibuildwheel.py new file mode 100644 index 0000000..c264296 --- /dev/null +++ b/tests/examples/cibuildwheel/test_cibuildwheel.py @@ -0,0 +1,49 @@ +from __future__ import annotations + +import hashlib +import subprocess +import sys +import zipfile +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("auditwheel", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "wheelhouse").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] + + +def test_auditwheel_sbom_is_linked(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "wheelhouse").glob("*.whl") + linked = zipfile.ZipFile(wheel).read("greet-1.0.dist-info/sboms/auditwheel.cdx.json") + assert [ + (ref["url"], ref["hashes"]) + for ref in read_sbom(wheel)["metadata"]["component"]["externalReferences"] + if ref["type"] == "bom" + ] == [("auditwheel.cdx.json", [{"alg": "SHA-256", "content": hashlib.sha256(linked).hexdigest()}])] + + +def test_auditwheel_sbom_repeats_a_bom_ref(played: Played) -> None: + # auditwheel lists the wheel both as the document's subject and among its components, under one bom-ref + (wheel,) = (played.directory / "wheelhouse").glob("*.whl") + result = subprocess.run( + [sys.executable, "-m", "python_sbom", "validate", str(wheel)], capture_output=True, text=True, check=False + ) + problem = f"auditwheel.cdx.json: bom-ref values repeat: pkg:pypi/greet@1.0?file_name={wheel.name}" + assert (result.returncode, result.stderr) == ( + 1, + f"SBOM invalid: {wheel.name}: greet-1.0.dist-info/sboms/{problem}\n", + ) diff --git a/tests/examples/conftest.py b/tests/examples/conftest.py new file mode 100644 index 0000000..1a5e102 --- /dev/null +++ b/tests/examples/conftest.py @@ -0,0 +1,79 @@ +from __future__ import annotations + +import json +import re +import shlex +import shutil +import subprocess +import sys +import sysconfig +import zipfile +from dataclasses import dataclass +from pathlib import Path +from typing import TYPE_CHECKING, Final, Protocol + +import pytest + +if TYPE_CHECKING: + from python_sbom._model._types import Document + +_EXAMPLES: Final[Path] = Path(__file__).parents[2] / "docs" / "examples" +# a wheel's interpreter, ABI and platform tags depend on where the example runs, while the docs show one platform's +_TAGS: Final[re.Pattern[str]] = re.compile(r"-[^-\s/]+-[^-\s/]+-[^-\s/]+\.whl\b") +# a frontend's isolated environment would install python-sbom from PyPI; the environment the test runs in holds the +# checkout's +_ADDED: Final[dict[tuple[str, ...], list[str]]] = { + ("python", "-m", "build"): ["--no-isolation", "--skip-dependency-check"] +} + + +@dataclass(frozen=True, slots=True, kw_only=True) +class Played: + # an example project of the docs, copied and taken through one of its documented sessions: each command with the + # lines the docs show under it, and with the lines it printed + directory: Path + expected: list[tuple[str, list[str]]] + output: list[tuple[str, list[str]]] + + +class ReadSbom(Protocol): + def __call__(self, wheel: Path) -> Document: ... + + +@pytest.fixture(scope="module") +def played(request: pytest.FixtureRequest, tmp_path_factory: pytest.TempPathFactory) -> Played: + example, session = request.param + directory = tmp_path_factory.mktemp(example) / "greet" + shutil.copytree(_EXAMPLES / example, directory) + expected: Final[list[tuple[str, list[str]]]] = [] + output: Final[list[tuple[str, list[str]]]] = [] + for block in re.split(r"^\$ ", (_EXAMPLES / example / session).read_text(encoding="utf-8"), flags=re.MULTILINE)[1:]: + command, *lines = block.splitlines() + expected.append((command, [_TAGS.sub("-TAGS.whl", line) for line in lines])) + output.append((command, [_TAGS.sub("-TAGS.whl", line) for line in _run(command, directory)])) + return Played(directory=directory, expected=expected, output=output) + + +def _run(command: str, directory: Path) -> list[str]: + name, *typed = shlex.split(command) + # the shell expands the globs a reader types + arguments: Final[list[str]] = [] + for argument in typed: + arguments.extend( + sorted(path.relative_to(directory).as_posix() for path in directory.glob(argument)) or [argument] + ) + arguments.extend(_ADDED.get((name, *arguments[:2]), [])) + executable = sys.executable if name == "python" else shutil.which(name, path=sysconfig.get_path("scripts")) + assert executable is not None, f"{name} is not installed next to {sys.executable}" + result = subprocess.run([executable, *arguments], cwd=directory, capture_output=True, text=True, check=False) + assert result.returncode == 0, f"{command} failed:\n{result.stdout}{result.stderr}" + # the docs show what python-sbom prints and leave out what the build tools around it print + return result.stdout.splitlines() if name == "python-sbom" else [] + + +@pytest.fixture +def read_sbom() -> ReadSbom: + def read(wheel: Path) -> Document: + return json.loads(zipfile.ZipFile(wheel).read("greet-1.0.dist-info/sboms/greet.cdx.json")) + + return read diff --git a/tests/examples/delocate/test_delocate.py b/tests/examples/delocate/test_delocate.py new file mode 100644 index 0000000..6a76805 --- /dev/null +++ b/tests/examples/delocate/test_delocate.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("meson-python", "session-delocate.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "wheelhouse").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] diff --git a/tests/examples/flit-core/test_flit_core.py b/tests/examples/flit-core/test_flit_core.py new file mode 100644 index 0000000..4ed2840 --- /dev/null +++ b/tests/examples/flit-core/test_flit_core.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("flit-core", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] diff --git a/tests/examples/hatchling/test_hatchling.py b/tests/examples/hatchling/test_hatchling.py new file mode 100644 index 0000000..371c6b5 --- /dev/null +++ b/tests/examples/hatchling/test_hatchling.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("hatchling", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] diff --git a/tests/examples/maturin/test_maturin.py b/tests/examples/maturin/test_maturin.py new file mode 100644 index 0000000..367e3fa --- /dev/null +++ b/tests/examples/maturin/test_maturin.py @@ -0,0 +1,34 @@ +from __future__ import annotations + +import hashlib +import zipfile +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("maturin", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] + + +def test_maturin_sbom_is_linked(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + linked = zipfile.ZipFile(wheel).read("greet-1.0.dist-info/sboms/greet.cyclonedx.json") + assert [ + (ref["url"], ref["hashes"]) + for ref in read_sbom(wheel)["metadata"]["component"]["externalReferences"] + if ref["type"] == "bom" + ] == [("greet.cyclonedx.json", [{"alg": "SHA-256", "content": hashlib.sha256(linked).hexdigest()}])] diff --git a/tests/examples/maturin/test_maturin_build.py b/tests/examples/maturin/test_maturin_build.py new file mode 100644 index 0000000..d8819a7 --- /dev/null +++ b/tests/examples/maturin/test_maturin_build.py @@ -0,0 +1,34 @@ +from __future__ import annotations + +import hashlib +import zipfile +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("maturin", "session-maturin-build.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] + + +def test_maturin_sbom_is_linked(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + linked = zipfile.ZipFile(wheel).read("greet-1.0.dist-info/sboms/greet.cyclonedx.json") + assert [ + (ref["url"], ref["hashes"]) + for ref in read_sbom(wheel)["metadata"]["component"]["externalReferences"] + if ref["type"] == "bom" + ] == [("greet.cyclonedx.json", [{"alg": "SHA-256", "content": hashlib.sha256(linked).hexdigest()}])] diff --git a/tests/examples/meson-python/test_meson_python.py b/tests/examples/meson-python/test_meson_python.py new file mode 100644 index 0000000..96f984e --- /dev/null +++ b/tests/examples/meson-python/test_meson_python.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("meson-python", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] diff --git a/tests/examples/pdm-backend/test_pdm_backend.py b/tests/examples/pdm-backend/test_pdm_backend.py new file mode 100644 index 0000000..f0fb69b --- /dev/null +++ b/tests/examples/pdm-backend/test_pdm_backend.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("pdm-backend", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] diff --git a/tests/examples/poetry-core/test_poetry_core.py b/tests/examples/poetry-core/test_poetry_core.py new file mode 100644 index 0000000..3d1fda6 --- /dev/null +++ b/tests/examples/poetry-core/test_poetry_core.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("poetry-core", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] diff --git a/tests/examples/scikit-build-core/test_scikit_build_core.py b/tests/examples/scikit-build-core/test_scikit_build_core.py new file mode 100644 index 0000000..a9c9745 --- /dev/null +++ b/tests/examples/scikit-build-core/test_scikit_build_core.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("scikit-build-core", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] diff --git a/tests/examples/setuptools/test_setuptools.py b/tests/examples/setuptools/test_setuptools.py new file mode 100644 index 0000000..241d254 --- /dev/null +++ b/tests/examples/setuptools/test_setuptools.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("setuptools", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] diff --git a/tests/examples/uv-build/test_uv_build.py b/tests/examples/uv-build/test_uv_build.py new file mode 100644 index 0000000..076b52d --- /dev/null +++ b/tests/examples/uv-build/test_uv_build.py @@ -0,0 +1,22 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("uv-build", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_sbom_names_the_wheel_it_sits_in(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] diff --git a/tests/examples/zipapp/test_zipapp.py b/tests/examples/zipapp/test_zipapp.py new file mode 100644 index 0000000..051e37b --- /dev/null +++ b/tests/examples/zipapp/test_zipapp.py @@ -0,0 +1,27 @@ +from __future__ import annotations + +import zipfile +from typing import TYPE_CHECKING, Final + +import pytest + +if TYPE_CHECKING: + from conftest import Played, ReadSbom + +pytestmark: Final[pytest.MarkDecorator] = pytest.mark.parametrize( + "played", [("zipapp", "session.console")], indirect=True, scope="module" +) + + +def test_documented_session(played: Played) -> None: + assert played.output == played.expected + + +def test_wheel_in_the_archive_names_itself(played: Played, read_sbom: ReadSbom) -> None: + (wheel,) = (played.directory / "dist").glob("*.whl") + references = read_sbom(wheel)["metadata"]["component"]["externalReferences"] + assert [ref["url"].rsplit("/", 2)[1] for ref in references if ref["type"] == "attestation"] == [wheel.name] + + +def test_archive_carries_its_sbom_at_the_top(played: Played) -> None: + assert "greet.pyz.cdx.json" in zipfile.ZipFile(played.directory / "greet.pyz").namelist() diff --git a/tox.toml b/tox.toml index cbe54a9..cc872e0 100644 --- a/tox.toml +++ b/tox.toml @@ -1,5 +1,21 @@ requires = [ "tox>=4.64.7", "tox-uv>=1.36.1" ] env_list = [ "3.15", "3.14", "3.13", "3.12", "3.11", "3.14t", "3.15t", "docs", "fix", "pkg_meta", "type" ] +labels.examples = [ + "cibuildwheel", + "delocate", + "flit-core", + "hatchling", + "maturin", + "meson-python", + "pdm-backend", + "poetry-core", + "scikit-build-core", + "setuptools", + "uv-build", + "zipapp", +] +labels.lint = [ "fix", "pkg_meta", "type" ] +labels.test = [ "3.15", "3.14", "3.13", "3.12", "3.11", "3.14t", "3.15t" ] skip_missing_interpreters = true [env_run_base] @@ -28,6 +44,9 @@ commands = [ "--cov-report", "html:{env_tmp_dir}{/}htmlcov", "tests", + # each example builds with a backend of its own, which only its example environment installs + "--ignore", + "{tox_root}{/}tests{/}examples", ], extend = true }, ], ] @@ -153,6 +172,42 @@ extras = [ "hatch", "validate" ] set_env.PYTHONPATH = "{tox_root}" commands = [ [ "python", "-m", "bench", { replace = "posargs", extend = true } ] ] +[env.cibuildwheel] +description = "build the cibuildwheel example of the docs and check its documented session" +dependency_groups = [ "cibuildwheel" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}cibuildwheel", + { replace = "posargs", extend = true }, + ], +] + +[env.delocate] +description = "build the delocate example of the docs and check its documented session" +dependency_groups = [ "delocate" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}delocate", + { replace = "posargs", extend = true }, + ], +] + [env.dev] description = "dev environment with all deps at {envdir}" package = "editable" @@ -161,3 +216,183 @@ commands = [ [ "uv", "pip", "tree" ], [ "python", "-c", "import sys; print(sys.executable)" ], ] + +[env.flit-core] +description = "build the flit-core example of the docs and check its documented session" +dependency_groups = [ "flit-core" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}flit-core", + { replace = "posargs", extend = true }, + ], +] + +[env.hatchling] +description = "build the hatchling example of the docs and check its documented session" +dependency_groups = [ "hatchling" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}hatchling", + { replace = "posargs", extend = true }, + ], +] + +[env.maturin] +description = "build the maturin example of the docs and check its documented session" +dependency_groups = [ "maturin" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}maturin", + { replace = "posargs", extend = true }, + ], +] + +[env.meson-python] +description = "build the meson-python example of the docs and check its documented session" +dependency_groups = [ "meson-python" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}meson-python", + { replace = "posargs", extend = true }, + ], +] + +[env.pdm-backend] +description = "build the pdm-backend example of the docs and check its documented session" +dependency_groups = [ "pdm-backend" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}pdm-backend", + { replace = "posargs", extend = true }, + ], +] + +[env.poetry-core] +description = "build the poetry-core example of the docs and check its documented session" +dependency_groups = [ "poetry-core" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}poetry-core", + { replace = "posargs", extend = true }, + ], +] + +[env.scikit-build-core] +description = "build the scikit-build-core example of the docs and check its documented session" +dependency_groups = [ "scikit-build-core" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}scikit-build-core", + { replace = "posargs", extend = true }, + ], +] + +[env.setuptools] +description = "build the setuptools example of the docs and check its documented session" +dependency_groups = [ "setuptools" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}setuptools", + { replace = "posargs", extend = true }, + ], +] + +[env.uv-build] +description = "build the uv-build example of the docs and check its documented session" +dependency_groups = [ "uv-build" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}uv-build", + { replace = "posargs", extend = true }, + ], +] + +[env.zipapp] +description = "build the zipapp example of the docs and check its documented session" +dependency_groups = [ "zipapp" ] +extras = [ "validate" ] +commands = [ + [ + "pytest", + "--cov", + "{tox_root}{/}tests{/}examples", + "--cov-config", + "{tox_root}{/}pyproject.toml", + "--cov-report", + "term-missing:skip-covered", + "{tox_root}{/}tests{/}examples{/}zipapp", + { replace = "posargs", extend = true }, + ], +] From 7c7266a356a028faec4c06b0ed51068e60672197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 14:58:52 -0800 Subject: [PATCH 06/11] =?UTF-8?q?=F0=9F=93=9D=20docs(how-to):=20give=20eac?= =?UTF-8?q?h=20backend=20its=20own=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The backend guides move under how-to/backends, one page per backend, and every page includes its configuration and session from the example projects instead of inline copies. The validate guide now says which checks an SBOM another tool wrote gets. --- docs/changelog.d/+maturin.doc.rst | 5 ++- docs/conf.py | 1 + docs/how-to/archive.rst | 12 ++++++ docs/how-to/backends/flit-core.rst | 19 +++++++++ docs/how-to/backends/hatchling.rst | 18 ++++---- docs/how-to/backends/index.rst | 22 ++++++++++ docs/how-to/backends/maturin.rst | 46 ++++++++------------ docs/how-to/backends/meson-python.rst | 39 +++++++++++++++++ docs/how-to/backends/other-backends.rst | 49 ++++++++++------------ docs/how-to/backends/pdm-backend.rst | 16 +++---- docs/how-to/backends/poetry-core.rst | 19 +++++++++ docs/how-to/backends/scikit-build-core.rst | 30 +++++++++++++ docs/how-to/backends/setuptools.rst | 20 ++++----- docs/how-to/backends/uv-build.rst | 26 ++++++++++++ docs/how-to/built-elsewhere.rst | 31 +++++++++----- docs/how-to/index.rst | 13 +++--- docs/how-to/validate.rst | 9 ++-- docs/index.rst | 47 ++++++--------------- docs/reference/backends.rst | 11 +++-- docs/reference/configuration.rst | 2 +- docs/tutorials/first-sbom.rst | 29 +++---------- 21 files changed, 292 insertions(+), 172 deletions(-) create mode 100644 docs/how-to/backends/flit-core.rst create mode 100644 docs/how-to/backends/index.rst create mode 100644 docs/how-to/backends/meson-python.rst create mode 100644 docs/how-to/backends/poetry-core.rst create mode 100644 docs/how-to/backends/scikit-build-core.rst create mode 100644 docs/how-to/backends/uv-build.rst diff --git a/docs/changelog.d/+maturin.doc.rst b/docs/changelog.d/+maturin.doc.rst index 5dec393..389e933 100644 --- a/docs/changelog.d/+maturin.doc.rst +++ b/docs/changelog.d/+maturin.doc.rst @@ -1,2 +1,3 @@ -Add a how-to 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. +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. diff --git a/docs/conf.py b/docs/conf.py index b865851..17ba2f4 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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"), } diff --git a/docs/how-to/archive.rst b/docs/how-to/archive.rst index 512dedb..40da89f 100644 --- a/docs/how-to/archive.rst +++ b/docs/how-to/archive.rst @@ -22,3 +22,15 @@ validate virtualenv.pyz`` finds it. It goes in deflated at level 9 whatever the zipapp may store them all and the :term:`SBOM`, megabytes of :term:`JSON`, would then add its full size. The entry carries a fixed time and Unix attributes and the other members keep their bytes, so adding it to one archive gives the same bytes on every system with the same zlib. + +***************************** + A zipapp built from a wheel +***************************** + +:example:`zipapp` builds its wheel with the hatchling hook, unpacks it into a zipapp, and describes the zipapp: + +.. literalinclude:: /examples/zipapp/session.console + :language: console + +The archive's SBOM sits at its top level, as ``greet.pyz.cdx.json``, and the wheel's SBOM, which names the wheel, stays +under ``greet-1.0.dist-info/sboms``. diff --git a/docs/how-to/backends/flit-core.rst b/docs/how-to/backends/flit-core.rst new file mode 100644 index 0000000..9c6c826 --- /dev/null +++ b/docs/how-to/backends/flit-core.rst @@ -0,0 +1,19 @@ +####################### + Use it with flit-core +####################### + +flit-core_ has no plugin interface, so its projects get the :term:`SBOM` through the :term:`wrapper backend`. Make +``python_sbom.backend`` the project's backend, keep flit-core in the build requirements, and name ``flit_core.buildapi`` +in ``[tool.python-sbom] build-backend``: + +.. literalinclude:: /examples/flit-core/pyproject.toml + :language: toml + :caption: pyproject.toml + +Then build a :term:`wheel` and check it: + +.. literalinclude:: /examples/flit-core/session.console + :language: console + +:example:`flit-core` holds the whole project. :doc:`other-backends` describes what the wrapper does with each +hook. diff --git a/docs/how-to/backends/hatchling.rst b/docs/how-to/backends/hatchling.rst index bba3f24..44a1318 100644 --- a/docs/how-to/backends/hatchling.rst +++ b/docs/how-to/backends/hatchling.rst @@ -5,19 +5,17 @@ python-sbom ships a hatchling_ :term:`build hook`. Add it to the build requirements, with the ``hatch`` extra, and enable it with an empty table: -.. code-block:: toml +.. literalinclude:: /examples/hatchling/pyproject.toml + :language: toml + :caption: pyproject.toml - [build-system] - build-backend = 'hatchling.build' - requires = ['hatchling>=1.28', 'python-sbom[hatch]>=0.2'] - - [tool.hatch.build.hooks.python-sbom] +Every :term:`wheel` you build now carries the :term:`SBOM`. An editable wheel carries none, and an :term:`sdist` carries +the :term:`source revision` instead, so a wheel built from it still names its commit. Build one and check it: - [tool.python-sbom] - supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } +.. literalinclude:: /examples/hatchling/session.console + :language: console -Every :term:`wheel` you build now carries the :term:`SBOM`. An editable wheel carries none, and an :term:`sdist` carries -the :term:`source revision` instead, so a wheel built from it still names its commit. +:example:`hatchling` holds the whole project. Put python-sbom's options in ``[tool.python-sbom]``, the table every integration reads, never in the hook's table: the hook's table holds only hatchling's own options, such as ``enable-by-default``, and a python-sbom option there fails the diff --git a/docs/how-to/backends/index.rst b/docs/how-to/backends/index.rst new file mode 100644 index 0000000..e929285 --- /dev/null +++ b/docs/how-to/backends/index.rst @@ -0,0 +1,22 @@ +############################### + Set it up for a build backend +############################### + +Each guide adds the :term:`SBOM` to the :term:`wheels ` one :term:`build backend` writes. It shows one of +:example:`the example projects <>` and the commands that build and check its wheel. hatchling_, pdm-backend_ and +setuptools_ load python-sbom as a plugin; the others get the SBOM through the :term:`wrapper backend`, and +:doc:`other-backends` covers a backend without a guide of its own. + +.. toctree:: + :maxdepth: 1 + + hatchling + pdm-backend + setuptools + meson-python + scikit-build-core + maturin + flit-core + poetry-core + uv-build + other-backends diff --git a/docs/how-to/backends/maturin.rst b/docs/how-to/backends/maturin.rst index a59b52d..51fbe00 100644 --- a/docs/how-to/backends/maturin.rst +++ b/docs/how-to/backends/maturin.rst @@ -33,8 +33,8 @@ Both sit in the wheel's ``.dist-info/sboms`` directory, as :term:`PEP 770` allow other file in the directory, with its SHA-256 Leave maturin's SBOM on. python-sbom does not list Rust crates, so ``[tool.maturin.sbom] rust = false`` drops the only -list of them from the wheel. When maturin's repair copies shared libraries into the wheel, it adds a third SBOM, ``auditwheel.cdx.json``, -which python-sbom links the same way. +list of them from the wheel. When maturin's repair copies shared libraries into the wheel, it adds a third SBOM, +``auditwheel.cdx.json``, which python-sbom links the same way. ******************************** Wheels a build frontend builds @@ -44,26 +44,24 @@ pip_, uv_, ``python -m build`` and cibuildwheel_ build through the standard buil :term:`wrapper backend` the project's backend, keep maturin in the build requirements, and name it in ``[tool.python-sbom]``: -.. code-block:: toml +.. literalinclude:: /examples/maturin/pyproject.toml + :language: toml + :caption: pyproject.toml - [build-system] - build-backend = 'python_sbom.backend' - requires = ['maturin>=1.12,<2', 'python-sbom>=0.3'] +.. literalinclude:: /examples/maturin/Cargo.toml + :language: toml + :caption: Cargo.toml - [tool.python-sbom] - build-backend = 'maturin' - supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } +:example:`maturin` holds the whole project, a Rust binary with one Python dependency. The wrapper passes every hook to maturin unchanged, so ``[tool.maturin]`` and ``--config-settings`` behave as before. Once maturin has written the wheel, with its own SBOM inside, the wrapper adds python-sbom's from within the build's isolated environment, so the SBOM lists the maturin version the frontend installed. -.. code-block:: console +Build a wheel and check it; ``validate`` checks both SBOMs: - $ uv build --wheel - $ unzip -Z1 dist/*.whl '*/sboms/*' - matex-1.0.dist-info/sboms/matex.cyclonedx.json - matex-1.0.dist-info/sboms/matex.cdx.json +.. literalinclude:: /examples/maturin/session.console + :language: console *************************************************** Wheels ``maturin build`` or maturin-action builds @@ -72,11 +70,8 @@ isolated environment, so the SBOM lists the maturin version the frontend install ``maturin build`` and maturin-action_ call maturin's own command line, so the wrapper never runs. Describe those wheels afterwards with ``python-sbom embed``, run from the project root so it finds ``[tool.python-sbom]``: -.. code-block:: console - - $ maturin build --release --out dist - $ python-sbom embed dist/*.whl - wrote matex-1.0.dist-info/sboms/matex.cdx.json into matex-1.0-py3-none-manylinux_2_34_x86_64.whl +.. literalinclude:: /examples/maturin/session-maturin-build.console + :language: console ``embed`` lists the packages of the environment it runs in as the build tools. maturin-action builds with a maturin binary of its own, so install the same maturin version next to python-sbom, and the SBOM records the version that built @@ -102,15 +97,8 @@ revision of a wheel built from an :term:`sdist`. Check it ********** -``python-sbom validate`` checks maturin's ``.cyclonedx.json`` file as well as the ``.cdx.json`` ones: - -.. code-block:: console - - $ python-sbom validate dist/ - SBOM in matex-1.0-py3-none-manylinux_2_34_x86_64.whl is valid - -python-sbom's own SBOM gets the full check; maturin's and auditwheel's get the CycloneDX schema check alone, as -:doc:`/how-to/validate` describes. +``python-sbom validate`` checks maturin's ``.cyclonedx.json`` file as well as the ``.cdx.json`` ones. maturin's gets the +checks :doc:`/how-to/validate` lists for an SBOM another tool wrote. ************************************************ Pitfall: a build backend in the project's tree @@ -125,5 +113,5 @@ path. Run ``python-sbom embed`` on the finished wheels instead, as for ``maturin *********************************** maturin applies its manylinux repair while it writes the wheel, so the file name is final. A later ``delocate`` or -``auditwheel repair`` renames the wheel, and the SBOM written before it names a file that is never published. Run +``auditwheel repair`` can rename the wheel, and the SBOM written before it then names a file that is never published. Run ``python-sbom embed`` on the repaired wheel. diff --git a/docs/how-to/backends/meson-python.rst b/docs/how-to/backends/meson-python.rst new file mode 100644 index 0000000..ae4a9b6 --- /dev/null +++ b/docs/how-to/backends/meson-python.rst @@ -0,0 +1,39 @@ +########################## + Use it with meson-python +########################## + +meson-python_ has no plugin interface, so its projects get the :term:`SBOM` through the :term:`wrapper backend`. Make +``python_sbom.backend`` the project's backend, keep meson-python in the build requirements, and name ``mesonpy`` in +``[tool.python-sbom] build-backend``: + +.. literalinclude:: /examples/meson-python/pyproject.toml + :language: toml + :caption: pyproject.toml + +.. literalinclude:: /examples/meson-python/meson.build + :language: meson + :caption: meson.build + +Then build a :term:`wheel` and check it: + +.. literalinclude:: /examples/meson-python/session.console + :language: console + +:example:`meson-python` holds the whole project. :doc:`other-backends` describes what the wrapper does with each +hook. + +************************************** + Pitfall: an sdist outside a checkout +************************************** + +meson-python builds an :term:`sdist` with ``meson dist``, which needs a git_ or Mercurial checkout; the wrapper changes +nothing there. + +*********************************** + Pitfall: a repair after the build +*********************************** + +cibuildwheel_ repairs a Linux wheel with auditwheel_, which renames it to its manylinux tag, and a macOS one with +delocate_. Both may copy shared libraries into the wheel, and the SBOM the wrapper wrote names neither those libraries +nor the new file name. Run ``python-sbom embed`` on the repaired wheel, as :ref:`how-to/built-elsewhere:After a repair` +shows with this project. diff --git a/docs/how-to/backends/other-backends.rst b/docs/how-to/backends/other-backends.rst index 0d046ed..295561f 100644 --- a/docs/how-to/backends/other-backends.rst +++ b/docs/how-to/backends/other-backends.rst @@ -2,19 +2,14 @@ Use it with any other backend ############################### -Backends without a plugin interface, such as meson-python_, maturin_, scikit-build-core_, flit-core_, poetry-core_ and -uv_build_, get the :term:`SBOM` through ``python_sbom.backend``, a :term:`build backend` that wraps yours. Make it the -project's backend, keep yours in the build requirements, and name yours in ``[tool.python-sbom]``: +Backends without a plugin interface get the :term:`SBOM` through ``python_sbom.backend``, a :term:`build backend` that +wraps yours. The table below links a guide with a complete project for each backend python-sbom is tested with; this +page covers how the wrapper works for those and any other backend. Make ``python_sbom.backend`` the project's backend, +keep yours in the build requirements, and name yours in ``[tool.python-sbom]``, as the meson-python project does: -.. code-block:: toml - - [build-system] - build-backend = 'python_sbom.backend' - requires = ['meson-python>=0.18', 'meson>=1.6', 'ninja', 'python-sbom>=0.2'] - - [tool.python-sbom] - build-backend = 'mesonpy' - supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } +.. literalinclude:: /examples/meson-python/pyproject.toml + :language: toml + :caption: pyproject.toml ``build-backend`` takes what ``[build-system] build-backend`` took before: a module, or ``module:object``. Every hook a :term:`frontend ` calls goes to your backend unchanged, ``--config-settings`` included, and the optional @@ -36,29 +31,29 @@ Use the module name from your current ``[build-system] build-backend``: - - Backend - ``[tool.python-sbom] build-backend`` - - Notes - - - `meson-python `_ + - Guide + - - meson-python_ - ``mesonpy`` - - Its sdist step needs a git_ or Mercurial checkout, as without the wrapper. - - - maturin_ - - ``maturin`` - - maturin writes its own SBOM of the Rust crates next to python-sbom's; :doc:`/how-to/maturin` covers both. + - :doc:`/how-to/backends/meson-python` - - scikit-build-core_ - ``scikit_build_core.build`` - - A project built with hatchling_ and scikit-build-core's hatch plugin uses :doc:`/how-to/hatchling` instead. + - :doc:`/how-to/backends/scikit-build-core` + - - maturin_ + - ``maturin`` + - :doc:`/how-to/backends/maturin` - - flit-core_ - ``flit_core.buildapi`` - - - - - `poetry-core `_ + - :doc:`/how-to/backends/flit-core` + - - poetry-core_ - ``poetry.core.masonry.api`` - - + - :doc:`/how-to/backends/poetry-core` - - uv_build_ - ``uv_build`` - - ``uv build`` builds a uv_build project in its own process, skipping the build interface; with the wrapper as the - backend, it calls the build interface, so the wrapper runs. + - :doc:`/how-to/backends/uv-build` - - pdm-backend_, setuptools_ - ``pdm.backend``, ``setuptools.build_meta`` - - Use :doc:`/how-to/pdm-backend` or :doc:`/how-to/setuptools` instead; wrap them only when the plugin cannot act. + - :doc:`/how-to/backends/pdm-backend`, :doc:`/how-to/backends/setuptools`: use their plugin, and wrap them only + when it cannot act *********************************************** Pitfall: builds that skip the build interface @@ -80,6 +75,6 @@ lives in the build environment. Describe those wheels after the build, as :doc:` Pitfall: tools that rename the wheel afterwards ************************************************* -``auditwheel repair`` and ``delocate`` rename a wheel to its final platform tag and may copy shared libraries into it, -so the SBOM the wrapper wrote names the old file and misses those libraries. Run ``python-sbom embed`` on the repaired +``auditwheel repair`` renames a wheel to its manylinux tag, ``delocate`` can change its macOS tag, and both may copy +shared libraries into it, so the SBOM the wrapper wrote can name the old file and misses those libraries. Run ``python-sbom embed`` on the repaired wheel, as :doc:`/how-to/built-elsewhere` shows. diff --git a/docs/how-to/backends/pdm-backend.rst b/docs/how-to/backends/pdm-backend.rst index 25f1b17..a8eea00 100644 --- a/docs/how-to/backends/pdm-backend.rst +++ b/docs/how-to/backends/pdm-backend.rst @@ -5,17 +5,17 @@ python-sbom ships a pdm-backend_ :term:`build hook`, registered in pdm-backend's ``pdm.build.hook`` entry point group. Add python-sbom to the build requirements, with the ``pdm`` extra, and add a ``[tool.python-sbom]`` table, empty or not: -.. code-block:: toml +.. literalinclude:: /examples/pdm-backend/pyproject.toml + :language: toml + :caption: pyproject.toml - [build-system] - build-backend = 'pdm.backend' - requires = ['pdm-backend>=2.4', 'python-sbom[pdm]>=0.2'] +Every :term:`wheel` you build now carries the :term:`SBOM`, and every :term:`sdist` the :term:`source revision`. An +editable wheel carries none. Build one and check it: - [tool.python-sbom] - supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } +.. literalinclude:: /examples/pdm-backend/session.console + :language: console -Every :term:`wheel` you build now carries the :term:`SBOM`, and every :term:`sdist` the :term:`source revision`. An -editable wheel carries none. +:example:`pdm-backend` holds the whole project. pdm-backend loads every hook installed in the build environment, so the table is what turns this one on: a project without ``[tool.python-sbom]`` builds as before even when python-sbom is installed. diff --git a/docs/how-to/backends/poetry-core.rst b/docs/how-to/backends/poetry-core.rst new file mode 100644 index 0000000..7d57840 --- /dev/null +++ b/docs/how-to/backends/poetry-core.rst @@ -0,0 +1,19 @@ +######################### + Use it with poetry-core +######################### + +poetry-core_ has no plugin interface, so its projects get the :term:`SBOM` through the :term:`wrapper backend`. Make +``python_sbom.backend`` the project's backend, keep poetry-core in the build requirements, and name +``poetry.core.masonry.api`` in ``[tool.python-sbom] build-backend``: + +.. literalinclude:: /examples/poetry-core/pyproject.toml + :language: toml + :caption: pyproject.toml + +Then build a :term:`wheel` and check it: + +.. literalinclude:: /examples/poetry-core/session.console + :language: console + +:example:`poetry-core` holds the whole project. :doc:`other-backends` describes what the wrapper does with each +hook. diff --git a/docs/how-to/backends/scikit-build-core.rst b/docs/how-to/backends/scikit-build-core.rst new file mode 100644 index 0000000..e0a5e1d --- /dev/null +++ b/docs/how-to/backends/scikit-build-core.rst @@ -0,0 +1,30 @@ +############################### + Use it with scikit-build-core +############################### + +scikit-build-core_ has no plugin interface, so its projects get the :term:`SBOM` through the :term:`wrapper backend`. +Make ``python_sbom.backend`` the project's backend, keep scikit-build-core in the build requirements, and name +``scikit_build_core.build`` in ``[tool.python-sbom] build-backend``: + +.. literalinclude:: /examples/scikit-build-core/pyproject.toml + :language: toml + :caption: pyproject.toml + +.. literalinclude:: /examples/scikit-build-core/CMakeLists.txt + :language: cmake + :caption: CMakeLists.txt + +Then build a :term:`wheel` and check it: + +.. literalinclude:: /examples/scikit-build-core/session.console + :language: console + +:example:`scikit-build-core` holds the whole project. :doc:`other-backends` describes what the wrapper does with each +hook. + +************************************ + Projects that build with hatchling +************************************ + +A project built with hatchling_ and scikit-build-core's hatch plugin uses :doc:`hatchling` instead: the +python-sbom hook runs next to scikit-build-core's. diff --git a/docs/how-to/backends/setuptools.rst b/docs/how-to/backends/setuptools.rst index 680c00a..ffcf870 100644 --- a/docs/how-to/backends/setuptools.rst +++ b/docs/how-to/backends/setuptools.rst @@ -6,17 +6,17 @@ python-sbom ships a setuptools_ plugin, registered in setuptools' ``setuptools.f point group, the one setuptools-scm_ uses. Add python-sbom to the build requirements, with the ``setuptools`` extra, and add a ``[tool.python-sbom]`` table, empty or not: -.. code-block:: toml +.. literalinclude:: /examples/setuptools/pyproject.toml + :language: toml + :caption: pyproject.toml - [build-system] - build-backend = 'setuptools.build_meta' - requires = ['setuptools>=77', 'python-sbom[setuptools]>=0.2'] +Every :term:`wheel` you build now carries the :term:`SBOM`, and every :term:`sdist` the :term:`source revision`. An +editable wheel carries none. Build one and check it: - [tool.python-sbom] - supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } +.. literalinclude:: /examples/setuptools/session.console + :language: console -Every :term:`wheel` you build now carries the :term:`SBOM`, and every :term:`sdist` the :term:`source revision`. An -editable wheel carries none. +:example:`setuptools` holds the whole project. setuptools calls the plugin for every build in an environment where python-sbom is installed, so the table is what turns it on: a project without ``[tool.python-sbom]``, or without a ``pyproject.toml``, builds as before. @@ -30,8 +30,8 @@ The plugin wraps the ``bdist_wheel`` and ``sdist`` commands the project uses, in setuptools applies ``[tool.setuptools.cmdclass]`` after the plugin runs, so a ``bdist_wheel`` or ``sdist`` named there would replace the plugin's and the wheel would get no SBOM. The plugin stops such a build with an error instead. Move -that command to ``setup.py``'s ``cmdclass``, or wrap the backend instead, as :doc:`/how-to/other-backends` shows with -``build-backend = 'setuptools.build_meta'``. +that command to ``setup.py``'s ``cmdclass``, or wrap the backend instead, as :doc:`/how-to/backends/other-backends` +shows with ``build-backend = 'setuptools.build_meta'``. *************************************** Pitfall: build output in the checkout diff --git a/docs/how-to/backends/uv-build.rst b/docs/how-to/backends/uv-build.rst new file mode 100644 index 0000000..53aadec --- /dev/null +++ b/docs/how-to/backends/uv-build.rst @@ -0,0 +1,26 @@ +###################### + Use it with uv-build +###################### + +uv_build_ has no plugin interface, so its projects get the :term:`SBOM` through the :term:`wrapper backend`. Make +``python_sbom.backend`` the project's backend, keep uv-build in the build requirements, and name ``uv_build`` in +``[tool.python-sbom] build-backend``: + +.. literalinclude:: /examples/uv-build/pyproject.toml + :language: toml + :caption: pyproject.toml + +Then build a :term:`wheel` and check it: + +.. literalinclude:: /examples/uv-build/session.console + :language: console + +:example:`uv-build` holds the whole project. :doc:`other-backends` describes what the wrapper does with each +hook. + +****************************************** + Pitfall: ``uv build`` without the wrapper +****************************************** + +``uv build`` builds a uv_build project in its own process when ``uv_build`` is the backend, so no build hook runs. With +the wrapper as the backend, uv calls the build interface, and the wrapper runs. diff --git a/docs/how-to/built-elsewhere.rst b/docs/how-to/built-elsewhere.rst index e237d6c..6f9273a 100644 --- a/docs/how-to/built-elsewhere.rst +++ b/docs/how-to/built-elsewhere.rst @@ -12,13 +12,11 @@ wrote before. Embed after the build *********************** -Run it from the project root, so it finds ``[tool.python-sbom]``: +Run it from the project root, so it finds ``[tool.python-sbom]``. For :example:`maturin`, built with ``maturin +build``: -.. code-block:: console - - $ maturin build --release --out dist - $ python-sbom embed dist/*.whl - wrote matex-1.0.dist-info/sboms/matex.cdx.json into matex-1.0-py3-none-manylinux_2_17_x86_64.whl +.. literalinclude:: /examples/maturin/session-maturin-build.console + :language: console ***************************** Record the real build tools @@ -47,13 +45,24 @@ or install the build requirements into an environment of their own and point ``- Run ``embed`` on the repaired wheel, so the SBOM names the file you publish: -.. code-block:: console +.. tab:: auditwheel + + cibuildwheel_ builds :example:`auditwheel`, a meson-python project whose extension links ``libuuid``, in a manylinux + container, and auditwheel_ copies ``libuuid`` into the wheel: + + .. literalinclude:: /examples/auditwheel/session.console + :language: console + + auditwheel's own SBOM, ``auditwheel.cdx.json``, stays in the wheel next to python-sbom's, which links to it by its + file name and SHA-256. The ``auditwheel.cdx.json`` written here lists the wheel twice under one ``bom-ref``, which + CycloneDX forbids, so ``python-sbom validate`` rejects this wheel. + +.. tab:: delocate - $ auditwheel repair dist/*.whl --wheel-dir wheelhouse - $ python-sbom embed wheelhouse/*.whl + On macOS, delocate_ repairs the wheel of :example:`meson-python`: -auditwheel_'s own SBOM, ``auditwheel.cdx.json``, stays in the wheel next to python-sbom's, which links to it by its file -name and SHA-256. + .. literalinclude:: /examples/meson-python/session-delocate.console + :language: console ************************** Name the source revision diff --git a/docs/how-to/index.rst b/docs/how-to/index.rst index 2c92619..937025d 100644 --- a/docs/how-to/index.rst +++ b/docs/how-to/index.rst @@ -2,18 +2,15 @@ How-to guides ############### -Each guide solves one task and assumes you know what python-sbom does, as the :doc:`/tutorials/index` show. The first -five set it up for a :term:`build backend`; the rest describe other artifacts, add what a project knows, and check the -result. The :doc:`/reference/index` lists every option and command, and :doc:`/concepts/index` explains the design. +Each guide solves one task and assumes you know what python-sbom does, as the :doc:`/tutorials/index` show. The first, +:doc:`backends/index`, holds one guide per :term:`build backend`; the rest describe other artifacts, add what a project +knows, and check the result. The :doc:`/reference/index` lists every option and command, and :doc:`/concepts/index` +explains the design. .. toctree:: :maxdepth: 1 - hatchling - pdm-backend - setuptools - other-backends - maturin + backends/index built-elsewhere archive content-provider diff --git a/docs/how-to/validate.rst b/docs/how-to/validate.rst index d81fb0b..bfe61ac 100644 --- a/docs/how-to/validate.rst +++ b/docs/how-to/validate.rst @@ -18,10 +18,11 @@ also catches a build that lost the plugin. What it checks **************** -Every SBOM gets the CycloneDX 1.6 schema check. For the SBOM python-sbom wrote, it also requires the ``urn:uuid`` serial -number `actions/attest`_ needs to recognize the format, checks that every reference resolves, and validates the -:term:`SPDX` rendering. An SBOM another tool wrote, such as auditwheel_'s ``auditwheel.cdx.json`` or maturin_'s -``.cyclonedx.json``, gets the schema check alone. +Every SBOM gets the CycloneDX 1.6 schema check, the limits on size, nesting and component count, and a check that no +``bom-ref`` repeats. For the SBOM python-sbom wrote, it also requires the ``urn:uuid`` serial number `actions/attest`_ +needs to recognize the format, checks that every reference resolves, and validates the :term:`SPDX` rendering. An SBOM +another tool wrote, such as auditwheel_'s ``auditwheel.cdx.json`` or maturin_'s ``.cyclonedx.json``, gets only +the checks every SBOM gets. ************************************** Limit the licenses of bundled wheels diff --git a/docs/index.rst b/docs/index.rst index 10863b6..a9ecb3d 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -86,50 +86,27 @@ python-sbom runs inside your build, so it goes in ``[build-system] requires`` wi .. tab:: hatchling - .. code-block:: toml - - [build-system] - build-backend = 'hatchling.build' - requires = ['hatchling>=1.28', 'python-sbom[hatch]>=0.2'] - - [tool.hatch.build.hooks.python-sbom] - - [tool.python-sbom] - supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } + .. literalinclude:: /examples/hatchling/pyproject.toml + :language: toml + :caption: pyproject.toml .. tab:: pdm-backend - .. code-block:: toml - - [build-system] - build-backend = 'pdm.backend' - requires = ['pdm-backend>=2.4', 'python-sbom[pdm]>=0.2'] - - [tool.python-sbom] - supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } + .. literalinclude:: /examples/pdm-backend/pyproject.toml + :language: toml + :caption: pyproject.toml .. tab:: setuptools - .. code-block:: toml - - [build-system] - build-backend = 'setuptools.build_meta' - requires = ['setuptools>=77', 'python-sbom[setuptools]>=0.2'] - - [tool.python-sbom] - supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } + .. literalinclude:: /examples/setuptools/pyproject.toml + :language: toml + :caption: pyproject.toml .. tab:: any other backend - .. code-block:: toml - - [build-system] - build-backend = 'python_sbom.backend' - requires = ['meson-python>=0.18', 'meson>=1.6', 'ninja', 'python-sbom>=0.2'] - - [tool.python-sbom] - build-backend = 'mesonpy' - supplier = { name = 'tox-dev', url = ['https://github.com/tox-dev'] } + .. literalinclude:: /examples/meson-python/pyproject.toml + :language: toml + :caption: pyproject.toml Every wheel you build from then on carries the SBOM. :doc:`/how-to/index` covers each backend in detail. diff --git a/docs/reference/backends.rst b/docs/reference/backends.rst index e35b30e..3ed2d49 100644 --- a/docs/reference/backends.rst +++ b/docs/reference/backends.rst @@ -17,22 +17,25 @@ the one it does. - :term:`build hook`, ``hatch`` entry point group - ``[tool.hatch.build.hooks.python-sbom]`` - ``python-sbom[hatch]`` - - :doc:`/how-to/hatchling` + - :doc:`/how-to/backends/hatchling` - - pdm-backend_ - build hook, ``pdm.build.hook`` entry point group - ``[tool.python-sbom]`` - ``python-sbom[pdm]`` - - :doc:`/how-to/pdm-backend` + - :doc:`/how-to/backends/pdm-backend` - - setuptools_ - plugin, ``setuptools.finalize_distribution_options`` entry point group - ``[tool.python-sbom]`` - ``python-sbom[setuptools]`` - - :doc:`/how-to/setuptools` + - :doc:`/how-to/backends/setuptools` - - meson-python_, maturin_, scikit-build-core_, flit-core_, poetry-core_, uv_build_ - ``python_sbom.backend``, which wraps the backend - ``[build-system] build-backend = 'python_sbom.backend'`` and ``[tool.python-sbom] build-backend`` - ``python-sbom`` - - :doc:`/how-to/other-backends` + - :doc:`/how-to/backends/meson-python`, :doc:`/how-to/backends/maturin`, + :doc:`/how-to/backends/scikit-build-core`, :doc:`/how-to/backends/flit-core`, + :doc:`/how-to/backends/poetry-core`, :doc:`/how-to/backends/uv-build`; any other: + :doc:`/how-to/backends/other-backends` - - any, for a :term:`wheel` built outside the build interface or renamed after it - ``python-sbom embed`` - running the command diff --git a/docs/reference/configuration.rst b/docs/reference/configuration.rst index b5b6784..1112a52 100644 --- a/docs/reference/configuration.rst +++ b/docs/reference/configuration.rst @@ -62,7 +62,7 @@ Each option is optional; an unknown key fails the build, so a typo cannot pass s ``build-backend`` The :term:`build backend` ``python_sbom.backend`` wraps, as ``module`` or ``module:object``, the form ``[build-system] build-backend`` takes. Only the wrapper reads it, and it fails the build when the project uses the - wrapper without it; :doc:`/how-to/other-backends` shows it. + wrapper without it; :doc:`/how-to/backends/other-backends` shows it. .. code-block:: toml diff --git a/docs/tutorials/first-sbom.rst b/docs/tutorials/first-sbom.rst index 895c60e..d78b579 100644 --- a/docs/tutorials/first-sbom.rst +++ b/docs/tutorials/first-sbom.rst @@ -19,29 +19,12 @@ python-sbom has the most to say about; :doc:`/reference/backends` lists the othe $ mkdir -p src/greet && touch src/greet/__init__.py $ printf 'Copyright (c) 2026 You\n\nMIT terms\n' > LICENSE -.. code-block:: toml - - [build-system] - build-backend = 'hatchling.build' - requires = ['hatchling>=1.28', 'python-sbom[hatch]>=0.2'] - - [project] - name = 'greet' - version = '1.0' - description = 'says hello' - license = 'MIT' - license-files = ['LICENSE'] - requires-python = '>=3.11' - 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'] } +.. literalinclude:: /examples/hatchling/pyproject.toml + :language: toml + :caption: pyproject.toml The empty ``[tool.hatch.build.hooks.python-sbom]`` table turns the hook on. ``[tool.python-sbom]`` holds python-sbom's -own options; here it names you as the :term:`supplier`. +own options; here it names you as the :term:`supplier`. :example:`hatchling` holds the finished project. Commit it, with the build output ignored, so the SBOM can name the exact :term:`source revision`. A checkout with uncommitted or untracked files has no commit that reproduces it, and then the SBOM names none: @@ -131,7 +114,7 @@ That is the check a CI job runs before publishing; :doc:`/how-to/validate` shows Next steps ************ -- Your project uses another :term:`build backend`? Pick its guide: :doc:`/how-to/pdm-backend`, :doc:`/how-to/setuptools` - or :doc:`/how-to/other-backends`; a Rust extension built with maturin: :doc:`/how-to/maturin`. +- Your project uses another :term:`build backend`? :doc:`/how-to/backends/index` has a guide with a complete project + for each one python-sbom is tested with. - Your project bundles wheels or knows more than its metadata says: :doc:`/how-to/content-provider`. - Every option python-sbom reads: :doc:`/reference/configuration`. From 2a35c67a640bc75b86ea8b365d1f91b462265d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 14:58:52 -0800 Subject: [PATCH 07/11] =?UTF-8?q?=F0=9F=93=9D=20docs(src):=20describe=20ea?= =?UTF-8?q?ch=20module=20in=20a=20docstring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/python_sbom/_cli/_archive.py | 2 ++ src/python_sbom/_cli/_embed.py | 2 ++ src/python_sbom/_cli/_main.py | 2 ++ src/python_sbom/_cli/_parser.py | 2 ++ src/python_sbom/_cli/_spdx.py | 2 ++ src/python_sbom/_cli/_validate.py | 2 ++ src/python_sbom/_collect/_archive.py | 2 ++ src/python_sbom/_collect/_content.py | 2 ++ src/python_sbom/_collect/_facts.py | 2 ++ src/python_sbom/_collect/_revision.py | 2 ++ src/python_sbom/_collect/_settings.py | 2 ++ src/python_sbom/_collect/_source.py | 2 ++ src/python_sbom/_collect/_wheel.py | 2 ++ src/python_sbom/_errors.py | 2 ++ src/python_sbom/_formats/_json.py | 2 ++ src/python_sbom/_formats/_spdx.py | 2 ++ src/python_sbom/_generate/_archive.py | 2 ++ src/python_sbom/_generate/_embed.py | 2 ++ src/python_sbom/_model/_archive.py | 2 ++ src/python_sbom/_model/_bom.py | 2 ++ src/python_sbom/_model/_components.py | 2 ++ src/python_sbom/_model/_content.py | 2 ++ src/python_sbom/_model/_graph.py | 2 ++ src/python_sbom/_model/_identity.py | 2 ++ src/python_sbom/_model/_inputs.py | 2 ++ src/python_sbom/_model/_iri.py | 2 ++ src/python_sbom/_model/_licenses.py | 2 ++ src/python_sbom/_model/_markers.py | 2 ++ src/python_sbom/_model/_metadata.py | 2 ++ src/python_sbom/_model/_names.py | 2 ++ src/python_sbom/_model/_record.py | 2 ++ src/python_sbom/_model/_tools.py | 2 ++ src/python_sbom/_model/_types.py | 2 ++ src/python_sbom/_model/_wheel.py | 2 ++ src/python_sbom/_validate/_artifact.py | 2 ++ src/python_sbom/_validate/_document.py | 2 ++ src/python_sbom/_validate/_licenses.py | 2 ++ src/python_sbom/_validate/_limits.py | 2 ++ src/python_sbom/_validate/_schemas.py | 2 ++ src/python_sbom/_wheel/_bundled.py | 2 ++ src/python_sbom/_wheel/_reader.py | 2 ++ src/python_sbom/_wheel/_sdist.py | 2 ++ src/python_sbom/_wheel/_write.py | 2 ++ src/python_sbom/_wheel/_zip.py | 2 ++ src/python_sbom/hatch/_hook.py | 2 ++ 45 files changed, 90 insertions(+) diff --git a/src/python_sbom/_cli/_archive.py b/src/python_sbom/_cli/_archive.py index a99bb91..c46a3a9 100644 --- a/src/python_sbom/_cli/_archive.py +++ b/src/python_sbom/_cli/_archive.py @@ -1,3 +1,5 @@ +"""The archive subcommand: write the SBOM of a zipapp or other non-wheel zip archive, and optionally embed it.""" + from __future__ import annotations import sys diff --git a/src/python_sbom/_cli/_embed.py b/src/python_sbom/_cli/_embed.py index ec7c1db..7887dbc 100644 --- a/src/python_sbom/_cli/_embed.py +++ b/src/python_sbom/_cli/_embed.py @@ -1,3 +1,5 @@ +"""The embed subcommand: write the SBOM into wheels another build backend built.""" + from __future__ import annotations import sys diff --git a/src/python_sbom/_cli/_main.py b/src/python_sbom/_cli/_main.py index 8888134..c8c43f2 100644 --- a/src/python_sbom/_cli/_main.py +++ b/src/python_sbom/_cli/_main.py @@ -1,3 +1,5 @@ +"""The command line's entry point: parse the arguments and run the chosen subcommand.""" + from __future__ import annotations import pkgutil diff --git a/src/python_sbom/_cli/_parser.py b/src/python_sbom/_cli/_parser.py index 88b09f5..a8f7ab8 100644 --- a/src/python_sbom/_cli/_parser.py +++ b/src/python_sbom/_cli/_parser.py @@ -1,3 +1,5 @@ +"""The argument parser for every subcommand and the options they share.""" + from __future__ import annotations from argparse import ArgumentParser, ArgumentTypeError, _SubParsersAction diff --git a/src/python_sbom/_cli/_spdx.py b/src/python_sbom/_cli/_spdx.py index 898ed22..828813e 100644 --- a/src/python_sbom/_cli/_spdx.py +++ b/src/python_sbom/_cli/_spdx.py @@ -1,3 +1,5 @@ +"""The spdx subcommand: render a CycloneDX SBOM as SPDX 2.3.""" + from __future__ import annotations from typing import TYPE_CHECKING, Protocol diff --git a/src/python_sbom/_cli/_validate.py b/src/python_sbom/_cli/_validate.py index 893a27a..3db5ac2 100644 --- a/src/python_sbom/_cli/_validate.py +++ b/src/python_sbom/_cli/_validate.py @@ -1,3 +1,5 @@ +"""The validate subcommand: check the SBOMs of wheels, archives and standalone documents.""" + from __future__ import annotations import sys diff --git a/src/python_sbom/_collect/_archive.py b/src/python_sbom/_collect/_archive.py index f11b47c..cd68079 100644 --- a/src/python_sbom/_collect/_archive.py +++ b/src/python_sbom/_collect/_archive.py @@ -1,3 +1,5 @@ +"""Read an archive's members, distributions and bundled wheels into the tree the model describes.""" + from __future__ import annotations from typing import TYPE_CHECKING, Final diff --git a/src/python_sbom/_collect/_content.py b/src/python_sbom/_collect/_content.py index 5bfed7e..3a80c60 100644 --- a/src/python_sbom/_collect/_content.py +++ b/src/python_sbom/_collect/_content.py @@ -1,3 +1,5 @@ +"""Resolve the content provider, from an instance, a module:attribute name or the option, and the files defining it.""" + from __future__ import annotations import inspect diff --git a/src/python_sbom/_collect/_facts.py b/src/python_sbom/_collect/_facts.py index d921d9a..79540c6 100644 --- a/src/python_sbom/_collect/_facts.py +++ b/src/python_sbom/_collect/_facts.py @@ -1,3 +1,5 @@ +"""Gather the build facts: timestamp, source revision, interpreter and the distributions in the build environment.""" + from __future__ import annotations import json diff --git a/src/python_sbom/_collect/_revision.py b/src/python_sbom/_collect/_revision.py index 0dafdd2..b6af9d1 100644 --- a/src/python_sbom/_collect/_revision.py +++ b/src/python_sbom/_collect/_revision.py @@ -1,3 +1,5 @@ +"""Find the commit a build comes from, and write the record an sdist keeps it in for the wheels built from it.""" + from __future__ import annotations import os diff --git a/src/python_sbom/_collect/_settings.py b/src/python_sbom/_collect/_settings.py index 05c3676..2a4294f 100644 --- a/src/python_sbom/_collect/_settings.py +++ b/src/python_sbom/_collect/_settings.py @@ -1,3 +1,5 @@ +"""Read python-sbom's settings from a project's [tool.python-sbom] table.""" + from __future__ import annotations import tomllib diff --git a/src/python_sbom/_collect/_source.py b/src/python_sbom/_collect/_source.py index a30b16e..fc39764 100644 --- a/src/python_sbom/_collect/_source.py +++ b/src/python_sbom/_collect/_source.py @@ -1,3 +1,5 @@ +"""Read what the project tree adds: the copyright notice, the bundled wheels it selects and its build scripts.""" + from __future__ import annotations from pathlib import PurePath diff --git a/src/python_sbom/_collect/_wheel.py b/src/python_sbom/_collect/_wheel.py index e1b1db8..60644fc 100644 --- a/src/python_sbom/_collect/_wheel.py +++ b/src/python_sbom/_collect/_wheel.py @@ -1,3 +1,5 @@ +"""Read a built wheel's metadata, bundled wheels and other SBOMs, with what the project tree adds, into a WheelTree.""" + from __future__ import annotations from typing import TYPE_CHECKING, Final diff --git a/src/python_sbom/_errors.py b/src/python_sbom/_errors.py index b6e6ba1..21506b9 100644 --- a/src/python_sbom/_errors.py +++ b/src/python_sbom/_errors.py @@ -1,3 +1,5 @@ +"""The errors python-sbom raises.""" + from __future__ import annotations diff --git a/src/python_sbom/_formats/_json.py b/src/python_sbom/_formats/_json.py index fd92b68..0bd9133 100644 --- a/src/python_sbom/_formats/_json.py +++ b/src/python_sbom/_formats/_json.py @@ -1,3 +1,5 @@ +"""Write documents as JSON, and parse JSON input and check it has the fields a document needs.""" + from __future__ import annotations import json diff --git a/src/python_sbom/_formats/_spdx.py b/src/python_sbom/_formats/_spdx.py index dde2be2..b2ad4a9 100644 --- a/src/python_sbom/_formats/_spdx.py +++ b/src/python_sbom/_formats/_spdx.py @@ -1,3 +1,5 @@ +"""Render a CycloneDX document as an SPDX 2.3 document.""" + from __future__ import annotations import hashlib diff --git a/src/python_sbom/_generate/_archive.py b/src/python_sbom/_generate/_archive.py index cd55593..bd802fd 100644 --- a/src/python_sbom/_generate/_archive.py +++ b/src/python_sbom/_generate/_archive.py @@ -1,3 +1,5 @@ +"""Build an archive's SBOM, write it beside the archive or to a given file, and optionally append it to the archive.""" + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/src/python_sbom/_generate/_embed.py b/src/python_sbom/_generate/_embed.py index b79a1f7..e6224ea 100644 --- a/src/python_sbom/_generate/_embed.py +++ b/src/python_sbom/_generate/_embed.py @@ -1,3 +1,5 @@ +"""Build a wheel's SBOM and write it into the wheel.""" + from __future__ import annotations from pathlib import PurePosixPath diff --git a/src/python_sbom/_model/_archive.py b/src/python_sbom/_model/_archive.py index f335220..0a04c36 100644 --- a/src/python_sbom/_model/_archive.py +++ b/src/python_sbom/_model/_archive.py @@ -1,3 +1,5 @@ +"""Describe an archive: its own files, the distributions it holds and the wheels it bundles.""" + from __future__ import annotations from dataclasses import dataclass diff --git a/src/python_sbom/_model/_bom.py b/src/python_sbom/_model/_bom.py index a2820b2..27617f9 100644 --- a/src/python_sbom/_model/_bom.py +++ b/src/python_sbom/_model/_bom.py @@ -1,3 +1,5 @@ +"""Assemble the CycloneDX document from the artifact, the tools and the provider's contributions.""" + from __future__ import annotations import json diff --git a/src/python_sbom/_model/_components.py b/src/python_sbom/_model/_components.py index b02c0d9..4a7d584 100644 --- a/src/python_sbom/_model/_components.py +++ b/src/python_sbom/_model/_components.py @@ -1,3 +1,5 @@ +"""Build the components for a distribution, a bundled wheel and a file.""" + from __future__ import annotations import re diff --git a/src/python_sbom/_model/_content.py b/src/python_sbom/_model/_content.py index cd51765..86c0ae5 100644 --- a/src/python_sbom/_model/_content.py +++ b/src/python_sbom/_model/_content.py @@ -1,3 +1,5 @@ +"""The content provider interface, the context it reads and the contributions it returns.""" + from __future__ import annotations from dataclasses import dataclass, field diff --git a/src/python_sbom/_model/_graph.py b/src/python_sbom/_model/_graph.py index 79dbff1..8374b9f 100644 --- a/src/python_sbom/_model/_graph.py +++ b/src/python_sbom/_model/_graph.py @@ -1,3 +1,5 @@ +"""Walk a document's components, pick what the artifact holds and ships, and check the references between them.""" + from __future__ import annotations from collections import Counter diff --git a/src/python_sbom/_model/_identity.py b/src/python_sbom/_model/_identity.py index 732a1f7..d59ed84 100644 --- a/src/python_sbom/_model/_identity.py +++ b/src/python_sbom/_model/_identity.py @@ -1,3 +1,5 @@ +"""Decide how a project's SBOMs name it: its property prefix, its repository URL and the namespace of their serials.""" + from __future__ import annotations import uuid diff --git a/src/python_sbom/_model/_inputs.py b/src/python_sbom/_model/_inputs.py index cda922d..7d30a7c 100644 --- a/src/python_sbom/_model/_inputs.py +++ b/src/python_sbom/_model/_inputs.py @@ -1,3 +1,5 @@ +"""The facts the edge gathers and the model turns into a document.""" + from __future__ import annotations from dataclasses import dataclass diff --git a/src/python_sbom/_model/_iri.py b/src/python_sbom/_model/_iri.py index 572226d..ec27f8a 100644 --- a/src/python_sbom/_model/_iri.py +++ b/src/python_sbom/_model/_iri.py @@ -1,3 +1,5 @@ +"""Check and percent-encode IRI references, as the CycloneDX schema expects them.""" + from __future__ import annotations import ipaddress diff --git a/src/python_sbom/_model/_licenses.py b/src/python_sbom/_model/_licenses.py index 9f0248e..15480a6 100644 --- a/src/python_sbom/_model/_licenses.py +++ b/src/python_sbom/_model/_licenses.py @@ -1,3 +1,5 @@ +"""Turn core metadata's license fields into CycloneDX licenses.""" + from __future__ import annotations import re diff --git a/src/python_sbom/_model/_markers.py b/src/python_sbom/_model/_markers.py index 0c0535d..57c5bf8 100644 --- a/src/python_sbom/_model/_markers.py +++ b/src/python_sbom/_model/_markers.py @@ -1,3 +1,5 @@ +"""Decide whether a requirement applies when no extra is selected.""" + from __future__ import annotations from typing import TYPE_CHECKING, Final diff --git a/src/python_sbom/_model/_metadata.py b/src/python_sbom/_model/_metadata.py index 2fa08d8..8b8aeaa 100644 --- a/src/python_sbom/_model/_metadata.py +++ b/src/python_sbom/_model/_metadata.py @@ -1,3 +1,5 @@ +"""Parse a distribution's core metadata, unvalidated, and read its fields as the distribution wrote them.""" + from __future__ import annotations import re diff --git a/src/python_sbom/_model/_names.py b/src/python_sbom/_model/_names.py index e9aeb72..6838b7f 100644 --- a/src/python_sbom/_model/_names.py +++ b/src/python_sbom/_model/_names.py @@ -1,3 +1,5 @@ +"""The names python-sbom derives: SBOM file names, property names, purls and reference types.""" + from __future__ import annotations import re diff --git a/src/python_sbom/_model/_record.py b/src/python_sbom/_model/_record.py index 9f7de64..593c43e 100644 --- a/src/python_sbom/_model/_record.py +++ b/src/python_sbom/_model/_record.py @@ -1,3 +1,5 @@ +"""Turn RECORD rows into the hashed files an SBOM lists, with CycloneDX algorithm names and hex digests.""" + from __future__ import annotations import base64 diff --git a/src/python_sbom/_model/_tools.py b/src/python_sbom/_model/_tools.py index 43eac69..6558580 100644 --- a/src/python_sbom/_model/_tools.py +++ b/src/python_sbom/_model/_tools.py @@ -1,3 +1,5 @@ +"""Describe the build tools: the interpreter, the installed distributions and the build scripts.""" + from __future__ import annotations from typing import TYPE_CHECKING, Final diff --git a/src/python_sbom/_model/_types.py b/src/python_sbom/_model/_types.py index 242ea52..5ff003f 100644 --- a/src/python_sbom/_model/_types.py +++ b/src/python_sbom/_model/_types.py @@ -1,3 +1,5 @@ +"""The CycloneDX 1.6 types python-sbom writes, as typed dictionaries.""" + from __future__ import annotations from typing import NotRequired, TypedDict diff --git a/src/python_sbom/_model/_wheel.py b/src/python_sbom/_model/_wheel.py index 5eb2d2c..ecc8608 100644 --- a/src/python_sbom/_model/_wheel.py +++ b/src/python_sbom/_model/_wheel.py @@ -1,3 +1,5 @@ +"""Describe a wheel: its declared dependencies, the wheels it bundles and the other SBOMs it carries.""" + from __future__ import annotations from itertools import starmap diff --git a/src/python_sbom/_validate/_artifact.py b/src/python_sbom/_validate/_artifact.py index 6605d2e..481c747 100644 --- a/src/python_sbom/_validate/_artifact.py +++ b/src/python_sbom/_validate/_artifact.py @@ -1,3 +1,5 @@ +"""Find the SBOMs in a wheel or archive, or read a standalone one, and check each.""" + from __future__ import annotations import zipfile diff --git a/src/python_sbom/_validate/_document.py b/src/python_sbom/_validate/_document.py index 2c041a7..c1118bf 100644 --- a/src/python_sbom/_validate/_document.py +++ b/src/python_sbom/_validate/_document.py @@ -1,3 +1,5 @@ +"""Check an SBOM's size, nesting and schema, and in one python-sbom wrote, its serial, references, SPDX and licenses.""" + from __future__ import annotations import math diff --git a/src/python_sbom/_validate/_licenses.py b/src/python_sbom/_validate/_licenses.py index af56aac..dbe85b6 100644 --- a/src/python_sbom/_validate/_licenses.py +++ b/src/python_sbom/_validate/_licenses.py @@ -1,3 +1,5 @@ +"""Check the licenses of the libraries an artifact ships against the allowed SPDX ids.""" + from __future__ import annotations from typing import TYPE_CHECKING, Final diff --git a/src/python_sbom/_validate/_limits.py b/src/python_sbom/_validate/_limits.py index eb7ef3e..4afd147 100644 --- a/src/python_sbom/_validate/_limits.py +++ b/src/python_sbom/_validate/_limits.py @@ -1,3 +1,5 @@ +"""The size limits that keep a hostile SBOM from exhausting memory or time.""" + from __future__ import annotations from typing import Final diff --git a/src/python_sbom/_validate/_schemas.py b/src/python_sbom/_validate/_schemas.py index d0e5f7a..d9e39e1 100644 --- a/src/python_sbom/_validate/_schemas.py +++ b/src/python_sbom/_validate/_schemas.py @@ -1,3 +1,5 @@ +"""Validate against the CycloneDX 1.6 JSON schema and check the SPDX rendering.""" + from __future__ import annotations import json diff --git a/src/python_sbom/_wheel/_bundled.py b/src/python_sbom/_wheel/_bundled.py index c0a22f0..42f861f 100644 --- a/src/python_sbom/_wheel/_bundled.py +++ b/src/python_sbom/_wheel/_bundled.py @@ -1,3 +1,5 @@ +"""Read the wheels a wheel or archive bundles, each verified against its RECORD, with the libraries it vendors.""" + from __future__ import annotations from collections import Counter diff --git a/src/python_sbom/_wheel/_reader.py b/src/python_sbom/_wheel/_reader.py index 4891971..7f5918b 100644 --- a/src/python_sbom/_wheel/_reader.py +++ b/src/python_sbom/_wheel/_reader.py @@ -1,3 +1,5 @@ +"""Open a built artifact once and read its members through one checked handle.""" + from __future__ import annotations from contextlib import contextmanager diff --git a/src/python_sbom/_wheel/_sdist.py b/src/python_sbom/_wheel/_sdist.py index 9532f37..8fc7da4 100644 --- a/src/python_sbom/_wheel/_sdist.py +++ b/src/python_sbom/_wheel/_sdist.py @@ -1,3 +1,5 @@ +"""Add a file to a built sdist.""" + from __future__ import annotations import gzip diff --git a/src/python_sbom/_wheel/_write.py b/src/python_sbom/_wheel/_write.py index fca97bf..2d1e555 100644 --- a/src/python_sbom/_wheel/_write.py +++ b/src/python_sbom/_wheel/_write.py @@ -1,3 +1,5 @@ +"""Write the SBOM into a wheel and its RECORD, or append it to an archive.""" + from __future__ import annotations import csv diff --git a/src/python_sbom/_wheel/_zip.py b/src/python_sbom/_wheel/_zip.py index 322f0f0..f591400 100644 --- a/src/python_sbom/_wheel/_zip.py +++ b/src/python_sbom/_wheel/_zip.py @@ -1,3 +1,5 @@ +"""Open zip archives, refusing member names that clash by case, and read members under a size cap.""" + from __future__ import annotations import hashlib diff --git a/src/python_sbom/hatch/_hook.py b/src/python_sbom/hatch/_hook.py index 7bbb9d8..13491d8 100644 --- a/src/python_sbom/hatch/_hook.py +++ b/src/python_sbom/hatch/_hook.py @@ -1,3 +1,5 @@ +"""The hatchling build hook: record the source revision in an sdist and write the SBOM into a wheel.""" + from __future__ import annotations import shutil From 98ccf0ee470a16ef25a996b79e2fd582e1a47ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 15:02:19 -0800 Subject: [PATCH 08/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(examples):?= =?UTF-8?q?=20print=20the=20greeting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/examples/auditwheel/src/greet/cli.py | 4 +--- docs/examples/flit-core/src/greet/cli.py | 4 +--- docs/examples/hatchling/src/greet/cli.py | 4 +--- docs/examples/meson-python/src/greet/cli.py | 4 +--- docs/examples/pdm-backend/src/greet/cli.py | 4 +--- docs/examples/poetry-core/src/greet/cli.py | 4 +--- docs/examples/scikit-build-core/src/greet/cli.py | 4 +--- docs/examples/setuptools/src/greet/cli.py | 4 +--- docs/examples/uv-build/src/greet/cli.py | 4 +--- docs/examples/zipapp/src/greet/cli.py | 4 +--- pyproject.toml | 1 + 11 files changed, 11 insertions(+), 30 deletions(-) diff --git a/docs/examples/auditwheel/src/greet/cli.py b/docs/examples/auditwheel/src/greet/cli.py index c000008..3ff0417 100644 --- a/docs/examples/auditwheel/src/greet/cli.py +++ b/docs/examples/auditwheel/src/greet/cli.py @@ -2,10 +2,8 @@ from __future__ import annotations -import sys - from ._greet import hello def main() -> None: - sys.stdout.write(f"{hello()}\n") + print(hello()) diff --git a/docs/examples/flit-core/src/greet/cli.py b/docs/examples/flit-core/src/greet/cli.py index 1d21367..3b351ab 100644 --- a/docs/examples/flit-core/src/greet/cli.py +++ b/docs/examples/flit-core/src/greet/cli.py @@ -2,8 +2,6 @@ from __future__ import annotations -import sys - def main() -> None: - sys.stdout.write("hello\n") + print("hello") diff --git a/docs/examples/hatchling/src/greet/cli.py b/docs/examples/hatchling/src/greet/cli.py index 1d21367..3b351ab 100644 --- a/docs/examples/hatchling/src/greet/cli.py +++ b/docs/examples/hatchling/src/greet/cli.py @@ -2,8 +2,6 @@ from __future__ import annotations -import sys - def main() -> None: - sys.stdout.write("hello\n") + print("hello") diff --git a/docs/examples/meson-python/src/greet/cli.py b/docs/examples/meson-python/src/greet/cli.py index c000008..3ff0417 100644 --- a/docs/examples/meson-python/src/greet/cli.py +++ b/docs/examples/meson-python/src/greet/cli.py @@ -2,10 +2,8 @@ from __future__ import annotations -import sys - from ._greet import hello def main() -> None: - sys.stdout.write(f"{hello()}\n") + print(hello()) diff --git a/docs/examples/pdm-backend/src/greet/cli.py b/docs/examples/pdm-backend/src/greet/cli.py index 1d21367..3b351ab 100644 --- a/docs/examples/pdm-backend/src/greet/cli.py +++ b/docs/examples/pdm-backend/src/greet/cli.py @@ -2,8 +2,6 @@ from __future__ import annotations -import sys - def main() -> None: - sys.stdout.write("hello\n") + print("hello") diff --git a/docs/examples/poetry-core/src/greet/cli.py b/docs/examples/poetry-core/src/greet/cli.py index 1d21367..3b351ab 100644 --- a/docs/examples/poetry-core/src/greet/cli.py +++ b/docs/examples/poetry-core/src/greet/cli.py @@ -2,8 +2,6 @@ from __future__ import annotations -import sys - def main() -> None: - sys.stdout.write("hello\n") + print("hello") diff --git a/docs/examples/scikit-build-core/src/greet/cli.py b/docs/examples/scikit-build-core/src/greet/cli.py index c000008..3ff0417 100644 --- a/docs/examples/scikit-build-core/src/greet/cli.py +++ b/docs/examples/scikit-build-core/src/greet/cli.py @@ -2,10 +2,8 @@ from __future__ import annotations -import sys - from ._greet import hello def main() -> None: - sys.stdout.write(f"{hello()}\n") + print(hello()) diff --git a/docs/examples/setuptools/src/greet/cli.py b/docs/examples/setuptools/src/greet/cli.py index 1d21367..3b351ab 100644 --- a/docs/examples/setuptools/src/greet/cli.py +++ b/docs/examples/setuptools/src/greet/cli.py @@ -2,8 +2,6 @@ from __future__ import annotations -import sys - def main() -> None: - sys.stdout.write("hello\n") + print("hello") diff --git a/docs/examples/uv-build/src/greet/cli.py b/docs/examples/uv-build/src/greet/cli.py index 1d21367..3b351ab 100644 --- a/docs/examples/uv-build/src/greet/cli.py +++ b/docs/examples/uv-build/src/greet/cli.py @@ -2,8 +2,6 @@ from __future__ import annotations -import sys - def main() -> None: - sys.stdout.write("hello\n") + print("hello") diff --git a/docs/examples/zipapp/src/greet/cli.py b/docs/examples/zipapp/src/greet/cli.py index 1d21367..3b351ab 100644 --- a/docs/examples/zipapp/src/greet/cli.py +++ b/docs/examples/zipapp/src/greet/cli.py @@ -2,8 +2,6 @@ from __future__ import annotations -import sys - def main() -> None: - sys.stdout.write("hello\n") + print("hello") diff --git a/pyproject.toml b/pyproject.toml index a820327..3a04aa5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -226,6 +226,7 @@ lint.per-file-ignores."bench/**/*.py" = [ ] lint.per-file-ignores."docs/examples/**/*.py" = [ "implicit-namespace-package", # Each example is a project of its own, with a src layout + "print", # The examples are command-line programs that print their greeting ] lint.per-file-ignores."tests/**/*.py" = [ "assert", # Tests use assertions From 5046de7652fd75ccae56de1d01b595dbc8c4f16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 15:06:32 -0800 Subject: [PATCH 09/11] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(tox):=20gen?= =?UTF-8?q?erate=20example=20envs=20from=20factors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/check.yaml | 24 +- .../test_flit_core.py | 0 .../test_meson_python.py | 0 .../test_pdm_backend.py | 0 .../test_poetry_core.py | 0 .../test_scikit_build_core.py | 0 .../{uv-build => uv_build}/test_uv_build.py | 0 tox.toml | 246 ++---------------- 8 files changed, 33 insertions(+), 237 deletions(-) rename tests/examples/{flit-core => flit_core}/test_flit_core.py (100%) rename tests/examples/{meson-python => meson_python}/test_meson_python.py (100%) rename tests/examples/{pdm-backend => pdm_backend}/test_pdm_backend.py (100%) rename tests/examples/{poetry-core => poetry_core}/test_poetry_core.py (100%) rename tests/examples/{scikit-build-core => scikit_build_core}/test_scikit_build_core.py (100%) rename tests/examples/{uv-build => uv_build}/test_uv_build.py (100%) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 0db8f07..79a52ef 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -35,18 +35,18 @@ jobs: {"env": "fix"}, {"env": "type"}, {"env": "pkg_meta"}, - {"env": "cibuildwheel", "python": "3.15"}, - {"env": "flit-core", "python": "3.15"}, - {"env": "hatchling", "python": "3.15"}, - {"env": "maturin", "python": "3.15"}, - {"env": "meson-python", "python": "3.15"}, - {"env": "pdm-backend", "python": "3.15"}, - {"env": "poetry-core", "python": "3.15"}, - {"env": "scikit-build-core", "python": "3.15"}, - {"env": "setuptools", "python": "3.15"}, - {"env": "uv-build", "python": "3.15"}, - {"env": "zipapp", "python": "3.15"}, - {"env": "delocate", "python": "3.15", "os": "macos-26"} + {"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 diff --git a/tests/examples/flit-core/test_flit_core.py b/tests/examples/flit_core/test_flit_core.py similarity index 100% rename from tests/examples/flit-core/test_flit_core.py rename to tests/examples/flit_core/test_flit_core.py diff --git a/tests/examples/meson-python/test_meson_python.py b/tests/examples/meson_python/test_meson_python.py similarity index 100% rename from tests/examples/meson-python/test_meson_python.py rename to tests/examples/meson_python/test_meson_python.py diff --git a/tests/examples/pdm-backend/test_pdm_backend.py b/tests/examples/pdm_backend/test_pdm_backend.py similarity index 100% rename from tests/examples/pdm-backend/test_pdm_backend.py rename to tests/examples/pdm_backend/test_pdm_backend.py diff --git a/tests/examples/poetry-core/test_poetry_core.py b/tests/examples/poetry_core/test_poetry_core.py similarity index 100% rename from tests/examples/poetry-core/test_poetry_core.py rename to tests/examples/poetry_core/test_poetry_core.py diff --git a/tests/examples/scikit-build-core/test_scikit_build_core.py b/tests/examples/scikit_build_core/test_scikit_build_core.py similarity index 100% rename from tests/examples/scikit-build-core/test_scikit_build_core.py rename to tests/examples/scikit_build_core/test_scikit_build_core.py diff --git a/tests/examples/uv-build/test_uv_build.py b/tests/examples/uv_build/test_uv_build.py similarity index 100% rename from tests/examples/uv-build/test_uv_build.py rename to tests/examples/uv_build/test_uv_build.py diff --git a/tox.toml b/tox.toml index cc872e0..ac4f7c6 100644 --- a/tox.toml +++ b/tox.toml @@ -1,19 +1,5 @@ requires = [ "tox>=4.64.7", "tox-uv>=1.36.1" ] env_list = [ "3.15", "3.14", "3.13", "3.12", "3.11", "3.14t", "3.15t", "docs", "fix", "pkg_meta", "type" ] -labels.examples = [ - "cibuildwheel", - "delocate", - "flit-core", - "hatchling", - "maturin", - "meson-python", - "pdm-backend", - "poetry-core", - "scikit-build-core", - "setuptools", - "uv-build", - "zipapp", -] labels.lint = [ "fix", "pkg_meta", "type" ] labels.test = [ "3.15", "3.14", "3.13", "3.12", "3.11", "3.14t", "3.15t" ] skip_missing_interpreters = true @@ -172,216 +158,25 @@ extras = [ "hatch", "validate" ] set_env.PYTHONPATH = "{tox_root}" commands = [ [ "python", "-m", "bench", { replace = "posargs", extend = true } ] ] -[env.cibuildwheel] -description = "build the cibuildwheel example of the docs and check its documented session" -dependency_groups = [ "cibuildwheel" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}cibuildwheel", - { replace = "posargs", extend = true }, - ], -] - -[env.delocate] -description = "build the delocate example of the docs and check its documented session" -dependency_groups = [ "delocate" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}delocate", - { replace = "posargs", extend = true }, - ], -] - -[env.dev] -description = "dev environment with all deps at {envdir}" -package = "editable" -dependency_groups = [ "dev" ] -commands = [ - [ "uv", "pip", "tree" ], - [ "python", "-c", "import sys; print(sys.executable)" ], -] - -[env.flit-core] -description = "build the flit-core example of the docs and check its documented session" -dependency_groups = [ "flit-core" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}flit-core", - { replace = "posargs", extend = true }, - ], -] - -[env.hatchling] -description = "build the hatchling example of the docs and check its documented session" -dependency_groups = [ "hatchling" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}hatchling", - { replace = "posargs", extend = true }, - ], -] - -[env.maturin] -description = "build the maturin example of the docs and check its documented session" -dependency_groups = [ "maturin" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}maturin", - { replace = "posargs", extend = true }, - ], -] - -[env.meson-python] -description = "build the meson-python example of the docs and check its documented session" -dependency_groups = [ "meson-python" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}meson-python", - { replace = "posargs", extend = true }, - ], -] - -[env.pdm-backend] -description = "build the pdm-backend example of the docs and check its documented session" -dependency_groups = [ "pdm-backend" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}pdm-backend", - { replace = "posargs", extend = true }, - ], -] - -[env.poetry-core] -description = "build the poetry-core example of the docs and check its documented session" -dependency_groups = [ "poetry-core" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}poetry-core", - { replace = "posargs", extend = true }, - ], -] - -[env.scikit-build-core] -description = "build the scikit-build-core example of the docs and check its documented session" -dependency_groups = [ "scikit-build-core" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}scikit-build-core", - { replace = "posargs", extend = true }, - ], -] - -[env.setuptools] -description = "build the setuptools example of the docs and check its documented session" -dependency_groups = [ "setuptools" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}setuptools", - { replace = "posargs", extend = true }, - ], -] - -[env.uv-build] -description = "build the uv-build example of the docs and check its documented session" -dependency_groups = [ "uv-build" ] -extras = [ "validate" ] -commands = [ - [ - "pytest", - "--cov", - "{tox_root}{/}tests{/}examples", - "--cov-config", - "{tox_root}{/}pyproject.toml", - "--cov-report", - "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}uv-build", - { replace = "posargs", extend = true }, - ], -] - -[env.zipapp] -description = "build the zipapp example of the docs and check its documented session" -dependency_groups = [ "zipapp" ] +[env_base.example] +factors = [ + { backend = [ + "cibuildwheel", + "delocate", + "flit_core", + "hatchling", + "maturin", + "meson_python", + "pdm_backend", + "poetry_core", + "scikit_build_core", + "setuptools", + "uv_build", + "zipapp", + ] }, +] +description = "build the {factor:backend} example of the docs and check its documented session" +dependency_groups = [ "{factor:backend}" ] extras = [ "validate" ] commands = [ [ @@ -392,7 +187,8 @@ commands = [ "{tox_root}{/}pyproject.toml", "--cov-report", "term-missing:skip-covered", - "{tox_root}{/}tests{/}examples{/}zipapp", + "{tox_root}{/}tests{/}examples{/}{factor:backend}", { replace = "posargs", extend = true }, ], ] +labels = [ "examples" ] From 4ca6cdde958a7b35c0ca19bedf259287f3fcead4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 15:10:54 -0800 Subject: [PATCH 10/11] =?UTF-8?q?=F0=9F=90=9B=20fix(tox):=20restore=20the?= =?UTF-8?q?=20dev=20environment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tox.toml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tox.toml b/tox.toml index ac4f7c6..0332128 100644 --- a/tox.toml +++ b/tox.toml @@ -158,6 +158,15 @@ extras = [ "hatch", "validate" ] set_env.PYTHONPATH = "{tox_root}" commands = [ [ "python", "-m", "bench", { replace = "posargs", extend = true } ] ] +[env.dev] +description = "dev environment with all deps at {envdir}" +package = "editable" +dependency_groups = [ "dev" ] +commands = [ + [ "uv", "pip", "tree" ], + [ "python", "-c", "import sys; print(sys.executable)" ], +] + [env_base.example] factors = [ { backend = [ From e579ba79a152c525b245adda25484f5b7b646b01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Mon, 9 Nov 2026 15:10:54 -0800 Subject: [PATCH 11/11] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20build(deps):=20requi?= =?UTF-8?q?re=20ty=200.0.100?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bench/__main__.py | 2 +- pylock.toml | 28 ++++++++++++++-------------- pyproject.toml | 5 ++++- src/python_sbom/_wheel/_write.py | 2 +- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/bench/__main__.py b/bench/__main__.py index 91b3704..f22ed1b 100644 --- a/bench/__main__.py +++ b/bench/__main__.py @@ -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]) diff --git a/pylock.toml b/pylock.toml index a45edcf..cc83f25 100644 --- a/pylock.toml +++ b/pylock.toml @@ -3416,28 +3416,28 @@ sha256 = "b854164df26db268af05f49aa5c0344b10e27a494343ff05b1e0bad3b135f5a7" [[packages]] name = "ty" -version = "0.0.95" +version = "0.0.100" marker = "\"dev\" in dependency_groups or \"type\" in dependency_groups" requires-python = ">=3.8" index = "https://pypi.org/simple/" [packages.sdist] -name = "ty-0.0.95.tar.gz" -upload-time = 2026-10-29T19:21:51.955948+00:00 -url = "https://files.pythonhosted.org/packages/39/08/d63954788578b9189dbf85081d8cbdba9a32a9a6a29729129a0da09cd3a0/ty-0.0.95.tar.gz" -size = 8115525 +name = "ty-0.0.100.tar.gz" +upload-time = 2026-11-09T20:16:27.534294+00:00 +url = "https://files.pythonhosted.org/packages/2a/b4/ac430b910566e28b1cd01faf7ee07ca38bcd7585b30fce8fd25dfc104edc/ty-0.0.100.tar.gz" +size = 8238916 [packages.sdist.hashes] -sha256 = "a480853a74d43074b2d4b28025d406b9d7223f7fe9f3a6c2adec3eacdbf14ca0" +sha256 = "ca75081ead663c077e40b90c38b6e9f039b6d168051e02918a8a1d7ecc4fa0dd" [[packages.wheels]] -name = "ty-0.0.95-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" -upload-time = 2026-10-29T19:21:30.801674+00:00 -url = "https://files.pythonhosted.org/packages/90/64/636308717989afa2fe765604ae2a76189f470d566e5e58da4482b625d64e/ty-0.0.95-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" -size = 16312046 +name = "ty-0.0.100-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" +upload-time = 2026-11-09T20:16:05.195593+00:00 +url = "https://files.pythonhosted.org/packages/b8/56/02b46b2a5f78f6edbd29afde54fce4461dd6462f901974deac0c9c1a987b/ty-0.0.100-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl" +size = 16749475 [packages.wheels.hashes] -sha256 = "6d47be2db5db80cd70c582b240a71dd8e9be215ce9288298c863c7c3611ef02b" +sha256 = "e23076fd67dc5c740a5cd292f3bbc10b82127dd01df3cb559e12b3144ceef72d" [[packages]] name = "typing-extensions" @@ -3780,6 +3780,6 @@ platforms = [ [tool.nab.validation] version = 1 -all-inputs-sha256 = "8aa355f4b82a36557184f7ad1d7371fa543d87d6c74d90f845353792ed9270c2" -selection-inputs-sha256 = "805268f7d0f2a4ebfdd771a30b5a8805b5b635d5a8154627aef8fbb43fe52ac9" -contents-sha256 = "b7167570fd0c38375480f42b84d1200c4c3d70c3ee6d66872f38bfd35e8c9a5e" +all-inputs-sha256 = "8ef75757f8e1b5983439523925f4e1274fa3dd3df4383ba69c15d13a73ea28fe" +selection-inputs-sha256 = "c471b6f745f74f253a2c2ba7095b5b07a49f5b770f1a9ff8b71a6eb8704a9431" +contents-sha256 = "ef98574fb95a6767aed70351a3b1ab64e68e6d5c01614aaa8e57a1800ede1cd7" diff --git a/pyproject.toml b/pyproject.toml index 3a04aa5..4f7fa0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,7 +106,7 @@ test = [ "spdx-tools>=0.8.5", ] type = [ - "ty>=0.0.84", + "ty>=0.0.100", { include-group = "bench" }, { include-group = "docs" }, { include-group = "test" }, @@ -330,3 +330,6 @@ packages.release-creator.uploaded-prior-to = 2026-11-02T21:45:00Z # simplint 0.7.1, the pre-commit hook, needs a seven-day cutoff exception. # expires 2026-11-13 packages.simplint.uploaded-prior-to = 2026-11-06T21:30:00Z +# ty 0.0.100 renamed unresolved-attribute to missing-attribute, needs a seven-day cutoff exception. +# expires 2026-11-16 +packages.ty.uploaded-prior-to = 2026-11-09T20:30:00Z diff --git a/src/python_sbom/_wheel/_write.py b/src/python_sbom/_wheel/_write.py index 2d1e555..ae8c098 100644 --- a/src/python_sbom/_wheel/_write.py +++ b/src/python_sbom/_wheel/_write.py @@ -49,7 +49,7 @@ def write_sbom(wheel: Path, name: str, content: bytes, epoch: int) -> str: # here; both go last, RECORD after the SBOM with zipremove.ZipFile(temporary, "a") as archive: stale = [info for info in archive.infolist() if info.filename in {record, sbom}] - archive.repack(list(map(archive.remove, stale))) # ty: ignore[unresolved-attribute] # zipremove adds both + archive.repack(list(map(archive.remove, stale))) # ty: ignore[missing-attribute] # zipremove adds both archive.writestr(entry, content) archive.writestr(record_info, rewritten) Path(temporary).chmod(stat.S_IMODE(wheel.stat().st_mode))