Skip to content

Use implementation_name to resolve wheel-only releases - #23335

Draft
charliermarsh wants to merge 1 commit into
charlie/infer-implementation-markersfrom
charlie/resolve-wheel-implementation
Draft

charliermarsh wants to merge 1 commit into
charlie/infer-implementation-markersfrom
charlie/resolve-wheel-implementation

Conversation

@charliermarsh

@charliermarsh charliermarsh commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Consider a package with two releases. Version 1.0 has a generic Python wheel, and 2.0 has only a CPython wheel. Neither release has a source distribution. A project can ask uv to ensure that a release is available for an interpreter other than CPython.

[tool.uv]
required-environments = ["implementation_name != 'cpython'"]

uv can choose 2.0 everywhere. It infers platform_python_implementation == 'CPython' from the cp311 tag. That condition can hold on Pyston, whose implementation_name is pyston, so the resolver counts the CPython wheel toward the requirement.

We now infer implementation_name == 'cpython' from cp311, just as we infer sys_platform == 'linux' from a Linux wheel. The resolver selects 2.0 on CPython and 1.0 elsewhere. The relationship from #23334 lets the same inferred marker answer questions about platform_python_implementation. This also applies when environments restricts the supported interpreters and when choosing between a local version and its base version.

New resolutions can use implementation_name in the generated fork markers. An existing lock can keep its previous fork markers until uv resolves again.

This should land together with #23310. A fork can select a release only on PyPy, for example. The writer needs to skip its CPython wheels before checking that the index provided the required hash for each file.

}

marker = marker.or(tree);
marker = marker.or(version.and(wheel_implementation_marker(*python_tag)));

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.

[P2] Exclude implementation-incompatible wheels before checking index hashes

The new fork can select 1.0 only outside CPython. If 1.0 has a py3-none-any wheel with SHA-256 and a cp311 wheel with only SHA-512, is_wheel_unreachable_for_marker retains both, so uv lock fails on an index requiring SHA-256 even though the CPython wheel cannot be installed in that fork. The lock filter already missed explicit implementation restrictions at the merge base, but the two-release example previously selected only 2.0 and never checked 1.0’s wheels. Apply the union of the wheel’s implementation markers in the lock filter before hash selection, keeping unknown tags conservative. If split out, land that fix first.

Comment thread crates/uv/tests/lock/lock.rs Resolved
Comment thread crates/uv/tests/lock/lock.rs Resolved
@charliermarsh
charliermarsh force-pushed the charlie/resolve-wheel-implementation branch from ad2f0a8 to ad0314f Compare November 21, 2026 01:10
Comment thread crates/uv/tests/lock/lock.rs Resolved
@charliermarsh
charliermarsh force-pushed the charlie/resolve-wheel-implementation branch from 97d09ba to 14e3782 Compare November 23, 2026 16:04
Comment on lines +1401 to +1402
"example-1.0-graalpy313-none-any.whl",
"python_full_version == '3.13.*' and implementation_name == 'graalpy'",

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] Use an installable GraalPy tag in the marker test

Tags::from_env emits an implementation-specific *-none-any tag only for CPython, so uv cannot select graalpy313-none-any on GraalPy. Use a tag already present in the ecosystem fixtures, such as graalpy312-graalpy250_312_native-macosx_10_13_x86_64, and expect 3.12.*. That tests the same implementation_name == 'graalpy' inference without asserting coverage for an unusable wheel.

}

marker = marker.or(tree);
marker = marker.or(version.and(wheel_implementation_marker(*python_tag)));

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.

[P2] Preserve locked build hashes when an implementation fork narrows wheel coverage

Consider a runtime dependency used on Windows or on non-CPython Linux, with non-CPython listed in required-environments. If 2.0 has only CPython wheels for both platforms and 1.0 has a generic wheel, re-resolving an existing lock now selects 2.0 only on Windows. If the index supplied a hash only for the Linux wheel, the lock writer drops 2.0’s last recorded digest without a package upgrade. Lock::hash_strategy then skips 2.0, so a CPython Linux isolated build requiring 2.0 without a separate build hash can install a publisher’s replacement wheel during uv sync --frozen. The previous lock enforced the original digest. Retain that digest for builds or require an explicit upgrade before discarding it.

This branch has not been deployed

No deployments
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