Skip to content

✨ feat(backends): support every build backend - #7

Merged
gaborbernat merged 26 commits into
mainfrom
all-backends
Nov 9, 2026
Merged

gaborbernat merged 26 commits into
mainfrom
all-backends

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

python-sbom wrote PEP 770 SBOMs only for hatchling projects. This PR adds pdm-backend, setuptools, meson-python, maturin, scikit-build-core, flit-core, poetry-core and uv_build, so projects on those backends can ship an SBOM in their wheels too. 📦

Review focus

  • Whether forwarding hooks through python_sbom.backend, with optional hooks present only when the wrapped backend has them, behaves like the wrapped backend for pip, uv and build.
  • Whether the setuptools plugin should wrap commands, or setuptools projects should use the wrapper backend instead.
  • Whether the new docs layout reads well; the preview has it.

Architecture

Each backend gets the lightest integration it allows. All of them read the same [tool.python-sbom] table and write the same document:

  • pdm-backend: a build hook in its pdm.build.hook entry point group.
  • setuptools: a plugin in the setuptools.finalize_distribution_options group, the one setuptools-scm uses. It wraps the project's bdist_wheel and sdist commands, including subclasses passed to setup(cmdclass=...).
  • The rest: python_sbom.backend, a PEP 517 backend that wraps the one named in [tool.python-sbom] build-backend. It forwards each hook unchanged, offers an optional hook only when the wrapped backend has it, and writes the SBOM once the wheel exists.

pdm-backend and setuptools load any plugin installed in the build environment, so for them the [tool.python-sbom] table is what turns python-sbom on. Each integration also records the source revision in the sdists it builds, so a wheel built later from that sdist still names its commit.

flowchart LR
    F[Frontend: pip, uv, build] --> H[hatchling hook]
    F --> P[pdm-backend hook]
    F --> S[setuptools plugin]
    F --> W[python_sbom.backend]
    W --> B[meson-python, maturin, scikit-build-core, ...]
    H & P & S & W --> D[Same SBOM document]
    classDef accent fill:#cfe4ff,stroke:#1f6feb,color:#0b1f3a;
    classDef warn fill:#ffe3a3,stroke:#d29200,color:#3a2c00;
    class F,B accent;
    class H,P,S,W,D warn;
Loading

Limits

Wheels built outside the build interface, such as maturin build run by maturin-action, and wheels that auditwheel repair or delocate rename afterwards still need python-sbom embed as the last step. A backend in the project's own tree can't be wrapped, because frontends load only a backend found on its backend-path.

setuptools applies [tool.setuptools.cmdclass] after plugins run, so a bdist_wheel or sdist named there would replace the plugin's command and drop the SBOM. The plugin stops such a build with an error.

Docs

The docs now follow the layout of sphinx-autodoc-typehints, grouped by Diátaxis quadrant. A landing page with install steps and cards leads to a section per quadrant, each with an index page and one page per guide, reference topic or concept. A glossary defines the terms and how they relate, and the architecture page traces one build instead of listing modules, so a refactor no longer leaves it stale. The theme, landing page and copy buttons follow simplint, and the logo puts the SBOM document above the package it describes.

This adds the python-sbom[pdm] and python-sbom[setuptools] extras. The docs ask for >=0.2, so this should ship as 0.2.0.

Split the pages into a tutorial, a how-to guide per build backend and task,
reference and explanation, and document the new backend integrations.
Lint every page with proselint, not only the top-level ones.
- add_to_sdist closes the sdist before replacing it, which Windows
  requires, and leaves the file name out of the gzip header so a rewrite
  reproduces
- the pdm hook writes the sdist revision outside pdm-backend's build
  directory, whose .gitignore otherwise lands in the sdist
- the setuptools plugin fails when [tool.setuptools.cmdclass] replaces
  bdist_wheel or sdist, instead of building a wheel with no SBOM
- the docs drop the in-tree backend claim, since frontends refuse the
  wrapper under backend-path, and tell setuptools users to ignore build/
  and the egg-info directory
@gaborbernat gaborbernat added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 9, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Follow sphinx-autodoc-typehints' layout: a landing page with install
steps and cards into each quadrant, then a single tutorials, how-to,
reference and concepts page each. The architecture diagram now follows
one build instead of every import between subpackages, which made it
unreadable.
Keep autosectionlabel at two levels, where every heading is unique, and
give the three deeper sections the index links to explicit labels. The
changelog's category headings rely on towncrier's own release labels.
One page per quadrant grew too long to scan. Each quadrant is now a
section with an index that lists one page per guide, reference topic or
concept, under the same landing page.
- filter setuptools-scm's file finder warning in the setuptools tests,
  which fail in the dev environment where hatch-vcs pulls it in
- build a wheel from the wrapper's and the setuptools plugin's sdist and
  check its SBOM names the commit, as the pdm test does
- keep module docstrings to one line; the guides carry the usage
- wrap the docs at 120 characters
- exempt nab 0.0.26, which the lock pins, from the News job's cooldown
validate-news runs the nested lock check with its own cutoff input, so
the exemption belongs there, not on install-locked-tools.
nab 0.0.26 pins nab-index, nab-markersets, nab-project, nab-provider
and nab-resolver at the same release, all uploaded with it.
Light and dark logos in the docs sidebar, a favicon, and the horizontal
logo at the top of the README. The theme colors are written into each
SVG, since CSS variables in presentation attributes do not render
everywhere.
Point the README at the logo by relative path, which GitHub resolves on
the branch being viewed, and rewrite it to the default branch's raw URL
for the PyPI description.
The document, package and check no longer overlap: each sits 1px apart
at the logo's 512px size, centered in the hexagon. The favicon drops its
white tile and keeps a transparent background.
JSON loading moves to _formats, so the spdx command no longer imports
validation. RECORD parsing joins the model, sdist rewriting joins _wheel,
the document header and reference checks merge into _bom, and
script_tool moves next to the other build tools. Wheel tests move from
test_bom to test_wheel to mirror the source.
A glossary page defines the terms the docs use and shows how they relate.
The architecture page and the contributing guide no longer list module and
test paths, which went stale with each refactor; the contributing guide
states the guarantees as behavior instead.
Each page links the first mention of a glossary term and of every external
project, so readers who land on a page directly can look up what an
abbreviation means. The glossary expands each abbreviation and links its
specification; the README spells them out inline.
@gaborbernat
gaborbernat marked this pull request as ready for review November 9, 2026 19:53
@gaborbernat
gaborbernat merged commit f56c81b into main Nov 9, 2026
25 checks passed
@gaborbernat
gaborbernat deleted the all-backends branch November 9, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant