Repository navigation
Preserve a registry wheel for pylock.toml when marker filtering removes every distribution - #23320
charliermarsh wants to merge 1 commit into
Conversation
23c5640 to
9fd9819
Compare
pylock.toml readable when platform filtering removes the last wheel
9fd9819 to
bcd3d5e
Compare
pylock.toml readable when platform filtering removes the last wheelpylock.toml entry empty
bcd3d5e to
17e1dc8
Compare
17e1dc8 to
320474c
Compare
320474c to
6003c22
Compare
pylock.toml entry empty6003c22 to
4c3c4c6
Compare
…es every distribution
4c3c4c6 to
2ec7ded
Compare
| .peekable(); | ||
|
|
||
| let fallback = if sdist.is_none() && matching.peek().is_none() { | ||
| select_fallback_wheel(node, requires_python, tags, index_locations) |
There was a problem hiding this comment.
[P2] Enforce the index hash algorithm for fallback wheels
If an index requires SHA-256 but its only eligible fallback advertises just MD5, select_fallback_wheel still returns it and uv pip compile writes the MD5 into pylock.toml. If a non-proxied index advertises no hash, compile downloads the wheel and hashes whatever bytes the artifact host serves. Both paths bypass the requirement for an index-advertised SHA-256. The fallback can still be installed on a 32-bit Linux interpreter that reports platform_machine == 'x86_64' while accepting i686 wheels.
| select_fallback_wheel(node, requires_python, tags, index_locations) | |
| let fallback = select_fallback_wheel(node, requires_python, tags, index_locations); | |
| if let Some(wheel) = fallback { | |
| let _ = crate::lock::select_registry_hash( | |
| &wheel.file.hashes, | |
| &wheel.index, | |
| index_locations, | |
| wheel.file.filename.as_ref(), | |
| )?; | |
| } | |
| fallback |
| let wheels = package | ||
| .wheels | ||
| .iter() | ||
| .chain(fallback) |
There was a problem hiding this comment.
[P3] Check the locked fallback size before recording its digest
A non-proxied index can supply a wheel size without a hash. When uv export --frozen --format pylock.toml includes that fallback, generate_missing_hashes passes only its URL to RegistryClient::hash_file. If the artifact host serves different-length bytes after locking, export succeeds and records their SHA-256 alongside the original size. uv will reject that pair if it later selects the wheel. Pass the locked size into hash completion and reject a byte-count mismatch before writing the digest.
| if let Some(wheel) = &package.fallback_wheel { | ||
| writer.key_start("fallback-wheel")?; | ||
| write_wheel_inline(writer, wheel)?; |
There was a problem hiding this comment.
[P2] Preserve the fallback wheel’s advertised filename in uv.lock
A JSON index can advertise demo-1.0-py3-none-win32.whl at /downloads/42. write_wheel_inline records only the URL, and Wheel::try_from(WheelWire) then tries to parse 42 as a wheel filename. uv lock can therefore write a lockfile that uv export --frozen cannot read. The same encoding limitation exists for ordinary wheels at the merge base, but marker filtering previously omitted this wheel and left the native lock readable. Record and honor the advertised filename when it cannot be recovered from the fallback URL; the broader ordinary-wheel fix can follow.
| !can_lock_fallback(wheel, index_locations), | ||
| wheel.file.yanked.as_deref().is_some_and(Yanked::is_yanked), | ||
| wheel.file.hashes.is_empty(), |
There was a problem hiding this comment.
[P2] Rank fallback wheels the pylock writer can serialize first
Consider a pinned package on a proxied index configured for SHA-512, with two marker-incompatible wheels: an unyanked wheel without a hash and a permitted yanked wheel with SHA-256. Both fail can_lock_fallback, so yank status selects the hashless wheel and validate_proxy_artifact aborts compilation. The pylock writer accepts the SHA-256 wheel; it is the native writer that requires the configured algorithm. The merge base omitted both wheels. Prefer candidates that pass pylock’s mandatory proxy-hash check before applying the yank tie-break, while retaining the configured-algorithm filter for uv.lock.
| #[serde(default)] | ||
| fallback_wheel: Option<Box<Wheel>>, |
There was a problem hiding this comment.
[P3] Track the fallback-wheel field in the lockfile revision
docs/concepts/resolution.md names adding a distribution field as an example of a backwards-compatible revision change. Both old and new writers currently emit revision 5, so when fallback-wheel is absent, a reader cannot distinguish a writer that never considered a fallback from one that found no recordable candidate. Increment REVISION and document the field in the revision history; this need not force old lockfiles to re-resolve.
| name = "project" | ||
| version = "0.1.0" | ||
| requires-python = ">=3.12" | ||
| dependencies = ["demo==1.0; sys_platform == 'freebsd'"] |
There was a problem hiding this comment.
[P3] Exercise rejection of a yanked fallback, not just its ranking
The exact pin permits the yanked build, so the snapshots still pass if rejected_yank is always false: the unyanked hashed build wins on ranking alone. A focused compile case with an unpinned dependency, a hashless unyanked proxy wheel, and a yanked wheel as the only hashed candidate would distinguish the two rules. It should report the missing proxy hash rather than export the rejected wheel.
| let requirements = context.export().arg("--frozen").output()?; | ||
| assert!(requirements.status.success()); | ||
| let requirements = String::from_utf8(requirements.stdout)?; | ||
| assert!(requirements.contains("demo==1.0")); | ||
| assert!(!requirements.contains(WHEEL_HASH)); |
There was a problem hiding this comment.
[P3] Snapshot the requirements export directly
These substring checks pass if the export drops the FreeBSD marker or emits a different digest, and a failed status assertion does not show the command’s stderr. Use uv_snapshot! with export --frozen --no-header, as in the neighboring export tests. The expected requirement line shows both the marker and the absence of a hash without manually parsing stdout.
Summary
On macOS, pip rejects this universal lockfile before it can install Jupyter Core.
Jupyter requests
pywin32on Windows outside PyPy. The resolver admitssys_platform == 'win32'together with the caller'sos_name != 'nt', so it includespywin32. The wheel filter requiresos_name == 'nt'for Windows wheels, which removes every file. With no sdist to record, we write just the name, version and marker. pip validates each package's source before checking its marker, so the empty entry prevents installation even on macOS. Jupyter dependencyWhen the marker removes every wheel and there is no sdist,
uv pip compilenow keeps one wheel in the pylock entry. The wheel must come from the selected index, pass the existing tag checks for the Python range and target, and satisfy the resolver’s yanking policy. The selection favors a wheel that meets the index's hash requirements, then an unyanked file, then a file with an advertised hash. The filename and URL break ties. Pip can validate the source and skippywin32on macOS. If the marker applies on a target where the wheel is incompatible, installation still fails for that package. Installation rulesFor frozen export,
uv lockrecords that candidate in an optionalfallback-wheelfield when the package would otherwise have no distribution and the index permits recording the file. Onlyuv export --format pylock.tomluses it as a package source. Keeping the field separate fromwheelskeeps the extra digest out of native build verification and requirements exports. Older lockfiles need a fresh resolution to acquire the field. If every candidate fails the index’s hash requirements, the native lock omits the field and the frozen export can still lack a source. If the index omits hashes, producing the pylock file may require downloading that wheel to compute its hash.