Skip to content

Add preview mode requiring wheels in required environments - #522

Draft
zaniebot wants to merge 13 commits into
mainfrom
zb/python-readiness-hard-wheel
Draft

zaniebot wants to merge 13 commits into
mainfrom
zb/python-readiness-hard-wheel

Conversation

@zaniebot

@zaniebot zaniebot commented Aug 3, 2026 •

Copy link
Copy Markdown
Collaborator

required-environments normally accepts source distributions, which prevents it from enforcing wheel availability for a newer Python version. Add the opt-in required-environments-mode = "require-wheels" setting under the required-environments-mode preview feature, preserving existing behavior by default while requiring compatible wheels for every active dependency in each required environment when enabled. Persist the selected mode in uv.lock so changing the policy triggers a fresh resolution; known holdouts can remain supported by limiting their dependency markers to other environments.

@astral-automations-bot astral-automations-bot Bot added breaking A breaking change enhancement New feature or request labels Aug 3, 2026
@zaniebot
zaniebot force-pushed the zb/python-readiness-hard-wheel branch from 19b9fbd to bf34f98 Compare August 3, 2026 19:04
@zaniebot zaniebot changed the title Require compatible wheels in required environments Add preview mode requiring wheels in required environments Aug 3, 2026
@zaniebot zaniebot added preview Experimental behavior and removed breaking A breaking change labels Aug 3, 2026
@zaniebot
zaniebot force-pushed the zb/python-readiness-hard-wheel branch from bf34f98 to 5443ac6 Compare August 3, 2026 19:16
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/python-readiness-hard-wheel branch 2 times, most recently from 897a2bf to 1a5ba01 Compare August 14, 2026 10:40
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/python-readiness-hard-wheel branch from 1a5ba01 to 9e45e69 Compare August 19, 2026 19:20
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/python-readiness-hard-wheel branch from 9e45e69 to f79a5f1 Compare September 3, 2026 17:56
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/python-readiness-hard-wheel branch 2 times, most recently from 9aa3251 to 0c460cc Compare September 8, 2026 17:55
@zaniebot zaniebot added priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. size:4 Complex: architectural or security-sensitive work requiring broad or cross-repository context. risk:3 Credible risk of meaningful incorrect behavior or regression; bounded or recoverable. labels Sep 9, 2026
@astral-automations-bot
astral-automations-bot Bot force-pushed the zb/python-readiness-hard-wheel branch from 0c460cc to 65392a8 Compare September 11, 2026 19:25
@codspeed

codspeed Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 8 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 54 untouched benchmarks
⏩ 35 skipped benchmarks1


Comparing zb/python-readiness-hard-wheel (58a9ece) with main (4efeeaf)

Open in CodSpeed

Footnotes

  1. 35 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Comment on lines +243 to +247
.packages()
.iter()
.filter(|(name, _)| !no_sources.for_package(name))
.map(|(_, member)| member.root().clone())
.collect(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P3] Share workspace membership instead of copying it per package

Loading metadata for N workspace members now creates N separately owned sets of N paths, even when require-wheels is disabled. Metadata::from_workspace retains these sets, and lookahead and resolution metadata clones copy them again, although the paths are only consumed during source-tree/group input preparation. Carry shared membership from workspace discovery and collect exemption paths once at that boundary, avoiding quadratic path storage in ordinary workspace resolution.

Comment thread crates/uv/tests/lock/lock.rs Outdated
Comment on lines +48955 to +48959
let lock: toml::Value = toml::from_str(&context.read("uv.lock"))?;
assert_eq!(
lock["package"]
.as_array()
.unwrap()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P3] Use the existing lockfile snapshot pattern

This assertion manually parses and traverses the lockfile with unchecked field accesses, unlike lock_required_environment_python_fork and the first new required-wheel test. Snapshot context.read("uv.lock") using the context and Packse hash filters. That keeps the selected version, required markers, and persisted policy visible together, removes the custom structural lookup, and provides a useful output diff on failure.

@zaniebot
zaniebot deployed to automations October 10, 2026 00:41 — with GitHub Actions Active
@zaniebot
zaniebot deployed to automations October 10, 2026 00:47 — with GitHub Actions Active
Comment on lines +1578 to +1580
prioritized.has_wheel_coverage(
self.options.minimum_libc_version,
required_markers.and(fork_markers),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Include the target Python range in wheel coverage

ResolverEnvironment deliberately tracks requires-python separately, so this intersection can establish coverage outside the project's supported Python range. For example, with project requires-python = ">=3.13.2,<3.14" and required Python 3.13, a py3-none-any wheel declaring >=3.12,<3.13.2 passes via Python 3.13.0–3.13.1, although it supports none of the project's environments. The later is_contained_by check only compares lower bounds. Intersect the coverage markers with the effective target Python range, including on the direct-wheel path.

Comment thread crates/uv-resolver/src/resolver/mod.rs Outdated
Comment on lines +1279 to +1281
.any(|required| *required == environment_marker)
{
wheel_marker.and(python_marker)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Intersect direct-wheel coverage with dependency applicability

The direct-wheel path checks dependency applicability and wheel coverage independently, allowing different environments to satisfy each check. With project Python >=3.12, required Linux coverage, and a direct dependency marked python_version == '3.13', a py3-none-any wheel declaring >=3.12,<3.13 passes because it covers Linux on Python 3.12. A single marked dependency does not force a resolver fork, and the later Python check ignores upper bounds. Intersect the wheel marker with find_environments(id, pubgrub) when checking coverage, matching the registry path.

Comment on lines +1241 to +1243
let applicable = find_environments(id, pubgrub);
for marker in self.options.required_environments.iter().copied() {
if env.included_by_marker(applicable.and(marker)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Limit source wheel requirements to supported Python versions

With requires-python = ">=3.12,<3.13", required Python 3.13 coverage, and an unmarked external sdist URL, this branch rejects the dependency despite the required environment being outside the project's supported range. ResolverEnvironment tracks requires-python separately, and find_environments only supplies dependency applicability, so neither excludes Python 3.13 here. The registry and direct-wheel branches already intersect the target Python specifiers. Apply the same intersection before rejecting source distributions, preferably sharing the applicability calculation across these paths.

Comment on lines +1653 to +1654
// Check the dependency's applicability before requesting metadata for this coverage.
let required_markers = marker.and(find_environments(id, pubgrub));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P3] Compute dependency applicability once per candidate

With multiple configured artifact environments, this reruns find_environments(id, pubgrub) for every marker, including when coverage succeeds. That helper allocates collections, traverses the reverse dependency closure, and propagates markers to a fixed point; neither input changes during this loop. Compute applicability once and reuse it across the coverage checks, while retaining the no-work path when there are no artifact environments.

This branch was successfully deployed

1 active deployment
automations — 56ef9654 Deployed Oct 21, 2026 by astral-automations-bot[bot] via review-code-quality / report #11247
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build:skip-release Disable building release binaries for a pull request enhancement New feature or request preview Experimental behavior priority:3 Normal: useful features, documentation, usability, or routine efficiency improvements. risk:3 Credible risk of meaningful incorrect behavior or regression; bounded or recoverable. size:4 Complex: architectural or security-sensitive work requiring broad or cross-repository context.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants