Skip to content

Keep direct wheels available for uv lock --check - #23326

Draft
charliermarsh wants to merge 1 commit into
mainfrom
charlie/retain-direct-wheel-for-validation
Draft

charliermarsh wants to merge 1 commit into
mainfrom
charlie/retain-direct-wheel-for-validation

Conversation

@charliermarsh

Copy link
Copy Markdown
Member

Summary

uv lock --check can fail immediately after uv add writes the lockfile. For example, a project can depend on a local i686 wheel on machines that report x86_64. That combination is possible when running 32-bit Python on x86-64 Linux.

pip download --only-binary=:all: --platform manylinux2014_i686 --python-version 3.12 markupsafe==3.0.2
uv init --bare --python 3.12
uv add --no-sync --marker "sys_platform == 'linux' and platform_machine == 'x86_64'" ./*.whl
uv lock --check

We compare the wheel's i686 tag with the x86_64 marker and omit the wheel from the package's wheels list. When we validate the lockfile, we need to read the local wheel's metadata, even on macOS where the dependency is inactive. With an empty list, uv reports that the binary distribution is incompatible with the current platform.

We now record a direct wheel in uv.lock even when its platform tag conflicts with the marker. We check the Python version when writing the lockfile and the interpreter's supported tags when installing the package.

demo = {{ path = "{filename}" }}
"#})?;

uv_snapshot!(context.filters(), context.lock(), @"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P3] Treat a missing direct wheel as a stale lock entry

The test starts without a lockfile. If the merge base already wrote this path dependency without a wheels entry, uv lock --no-build still cannot repair it: Package::to_dist returns NoBuild, and do_lock stops before reaching the updated writer. Without --no-build, validation falls back to a fresh resolution without the old version preferences, so repairing one wheel can update unrelated packages. This recovery behavior predates the PR; a follow-up can classify the missing direct-wheel entry as a lock satisfaction mismatch before fetching metadata, retaining the other pins.

Comment on lines +9237 to +9242
Dist::Built(dist)
if is_wheel_unreachable_for_marker(
dist.wheel_filename(),
requires_python,
&UniversalMarker::TRUE,
None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P3] Record the selected direct wheel without rechecking reachability

ResolverState::choose_version_url already rejects incompatible Python tags and wheel variants during universal resolution. Unlike a registry wheel, a direct wheel is the selected artifact, not one candidate among several. Passing UniversalMarker::TRUE repeats those checks through a platform filter; if the resolver and writer ever disagree, the writer silently drops the only artifact validation needs. Remove this guard and let the direct URL, path, and Git-path arms record their wheel unconditionally. Installation still checks concrete tags.

This branch was previously deployed

1 inactive deployment
automations — 4cda8638 Deployed Nov 20, 2026 by charliermarsh via review | security / security review #54224
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