Skip to content

Honor hashed uv-build version pins in bundled builds - #21708

Closed
zsol wants to merge 1 commit into
mainfrom
zsol/hashed-uv-build-pins
Closed

zsol wants to merge 1 commit into
mainfrom
zsol/hashed-uv-build-pins

Conversation

@zsol

@zsol zsol commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

uv can use the bundled uv_build backend even when a hashed build constraint pins a different version. Fall back to an external PEP 517 build when an active, exact pin with supplied hashes selects another version. --no-verify-hashes bypasses this behavior.

Stacked on #21467.

@zsol
zsol force-pushed the zsol/verify-build-constraint-hashes branch from 85b82da to 80bcb3e Compare September 15, 2026 12:35
@zsol
zsol force-pushed the zsol/hashed-uv-build-pins branch from 43e7794 to 21c665b Compare September 15, 2026 12:35
@zsol
zsol added this pull request to stack #21709 September 15, 2026 12:40
Base automatically changed from zsol/verify-build-constraint-hashes to main September 15, 2026 13:25
Use PEP 517 when an active build constraint pins and hashes a uv-build
version different from the bundled version. Matching pins, unhashed or
unpinned constraints, and --require-hashes alone remain eligible for
bundled builds; --no-verify-hashes bypasses the constraint check.

Share the check between uv build and BuildDispatch. Reject --list when
the constraint selects an external backend.
@zsol
zsol force-pushed the zsol/hashed-uv-build-pins branch from 21c665b to 1abc0c6 Compare September 15, 2026 13:25
@astral-sh-bot

astral-sh-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the main base revision.

  • Added tests: 1
  • Removed tests: 0
  • Changed suites: 1
uv::build: +1 / -0

Added:

  • uv::build::build::build_fast_path_hash_constraints

Removed: none

@zsol zsol closed this Sep 15, 2026
@zsol
zsol removed this pull request from stack #21709 September 15, 2026 15:48
zsol added a commit that referenced this pull request Oct 9, 2026
Add `--require-build-hashes` to require an exact version or direct URL
and a trusted hash for every build dependency, including transitive
dependencies. This builds on the supplied-hash verification in #21467,
which still allows dependencies without hashes. The requirement applies
to builds run by project, build, tool, and pip commands, including
builds needed to resolve metadata during locking or compilation.

Hashes can come from `tool.uv.build-constraint-dependencies`, a
`--build-constraint` file, or URL fragments in `build-system.requires`.
Dependencies discovered through backend hooks or package metadata still
need hashes declared upfront; hashes supplied only by those hooks or
metadata do not satisfy the requirement.

Enable the setting with `require-build-hashes = true` or the shared
`UV_REQUIRE_BUILD_HASHES` environment variable. Pip commands can
override the top-level setting in `[tool.uv.pip]`. CLI flags take
precedence over the environment, which takes precedence over
configuration. `--no-require-build-hashes` turns off the requirement
without disabling verification of supplied hashes.

This complements `--require-hashes` for runtime dependencies. The
existing `uv build --require-hashes` behavior for command-line build
constraints is unchanged.

Requiring build hashes needs build isolation, except when uv uses its
bundled `uv_build` backend, which is part of the executable. It does not
retroactively verify installed packages or previously built wheels. The
option is experimental and warns unless `--preview-features
build-dependency-hashes` is enabled.

Stacked on #21708.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
astral-automations-bot Bot pushed a commit to astral-sh/uv-dev that referenced this pull request Oct 10, 2026
Add `--require-build-hashes` to require an exact version or direct URL
and a trusted hash for every build dependency, including transitive
dependencies. This builds on the supplied-hash verification in astral-sh#21467,
which still allows dependencies without hashes. The requirement applies
to builds run by project, build, tool, and pip commands, including
builds needed to resolve metadata during locking or compilation.

Hashes can come from `tool.uv.build-constraint-dependencies`, a
`--build-constraint` file, or URL fragments in `build-system.requires`.
Dependencies discovered through backend hooks or package metadata still
need hashes declared upfront; hashes supplied only by those hooks or
metadata do not satisfy the requirement.

Enable the setting with `require-build-hashes = true` or the shared
`UV_REQUIRE_BUILD_HASHES` environment variable. Pip commands can
override the top-level setting in `[tool.uv.pip]`. CLI flags take
precedence over the environment, which takes precedence over
configuration. `--no-require-build-hashes` turns off the requirement
without disabling verification of supplied hashes.

This complements `--require-hashes` for runtime dependencies. The
existing `uv build --require-hashes` behavior for command-line build
constraints is unchanged.

Requiring build hashes needs build isolation, except when uv uses its
bundled `uv_build` backend, which is part of the executable. It does not
retroactively verify installed packages or previously built wheels. The
option is experimental and warns unless `--preview-features
build-dependency-hashes` is enabled.

Stacked on astral-sh#21708.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>

This branch was previously deployed

1 inactive deployment
automations — 1abc0c62 Deployed Sep 15, 2026 by zsol via review / security review #46756
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址