Skip to content

Preserve original constraint declarations in Constraints - #21459

Merged
zsol merged 3 commits into
mainfrom
zsol/preserve-constraint-hashes
Sep 15, 2026
Merged

zsol merged 3 commits into
mainfrom
zsol/preserve-constraint-hashes

Conversation

@zsol

@zsol zsol commented Sep 4, 2026

Copy link
Copy Markdown
Member

Constraints currently stores only normalized requirements for resolution, with extras and empty constraints removed. Callers that need the original declarations and their hashes have to keep a separate collection.

Preserve the original NameRequirementSpecifications in input order alongside the resolver map. Use this representation for build constraints in uv pip install, uv pip sync, and uv build, preserving their existing hash-checking and resolution behavior.

@zsol
zsol marked this pull request as draft September 4, 2026 12:21
@astral-sh-bot

astral-sh-bot Bot commented Sep 4, 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::it: +1 / -0

Added:

  • uv::it::requirements::constraint_specifications_preserve_hashes

Removed: none

@zsol
zsol marked this pull request as ready for review September 4, 2026 16:21
@zsol
zsol force-pushed the zsol/preserve-constraint-hashes branch from f7bb464 to 8827257 Compare September 7, 2026 13:08
@zsol
zsol force-pushed the zsol/preserve-constraint-hashes branch from f144681 to d29c20a Compare September 10, 2026 10:37
@zsol zsol changed the title Preserve original constraint declarations Preserve original constraint declarations in Constraints Sep 14, 2026
@zsol zsol added the internal A refactor or improvement that is not user-facing label Sep 14, 2026
Comment thread crates/uv/tests/build/build.rs Resolved
let constraints_txt = context.temp_dir.child("build_constraints.txt");
constraints_txt.write_str("setuptools>=40")?;
// Verify mode ignores hashes on unpinned constraints and does not activate extras.
constraints_txt.write_str("setuptools[foo]>=40 --hash=sha256:incorrect")?;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More for a follow-up PR, but that looks like a footgun: I spelled out the hash I want, and I said I want that hash verified, but it ignores that silently.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I completely agree with you

@zsol
zsol force-pushed the zsol/preserve-constraint-hashes branch from 46fd0fd to 83fa013 Compare September 15, 2026 10:02
@zsol
zsol merged commit c32f34a into main Sep 15, 2026
61 checks passed
@zsol
zsol deleted the zsol/preserve-constraint-hashes branch September 15, 2026 10:42
zsol added a commit that referenced this pull request Sep 15, 2026
…21467)

## Summary

Project build constraints can pin versions, but cannot attach hashes to
those pins. Allow `build-constraint-dependencies` to contain `{
requirement, hashes }` entries alongside strings, and retain the hashes
in `uv.lock` and tool receipts.

Verify supplied hashes when uv downloads build dependencies for project,
script, build, pip, and tool commands. This includes the build used to
infer a tool's name and fresh `uv run --no-sync --with` overlays. Build
dependencies without supplied hashes remain allowed.

Stacked on #21459.

This branch was previously deployed

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

Labels

internal A refactor or improvement that is not user-facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants