Reject already-installed wheels that don't match the target platform (#15484)

## Summary

We've received several requests to validate that installed wheels match
the current Python platform. This isn't _super_ common, since it
requires that your platform changes in some meaningful way (e.g., you
switch from x86 to ARM), though in practice, it sounds like it _can_
happen in HPC environments. This seems like a good thing to do
regardless, so we now validate that the tags (as recoded in `WHEEL`) are
consistent with the current platform during installs.

Closes https://github.com/astral-sh/uv/issues/15035.
This commit is contained in:
Charlie Marsh 2025-08-25 09:20:54 -04:00 committed by GitHub
parent 563adb8904
commit be4d5b72aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 751 additions and 63 deletions

View file

@ -5270,18 +5270,14 @@ impl WheelTagHint {
fn python_tags<'a>(
filenames: impl Iterator<Item = &'a WheelFilename> + 'a,
) -> impl Iterator<Item = LanguageTag> + 'a {
filenames
.flat_map(uv_distribution_filename::WheelFilename::python_tags)
.copied()
filenames.flat_map(WheelFilename::python_tags).copied()
}
/// Returns an iterator over the compatible Python tags of the available wheels.
fn abi_tags<'a>(
filenames: impl Iterator<Item = &'a WheelFilename> + 'a,
) -> impl Iterator<Item = AbiTag> + 'a {
filenames
.flat_map(uv_distribution_filename::WheelFilename::abi_tags)
.copied()
filenames.flat_map(WheelFilename::abi_tags).copied()
}
/// Returns the set of platform tags for the distribution that are ABI-compatible with the given