mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-03 10:33:49 +00:00
Choose most-compatible wheel in resolver and installer (#422)
## Summary This PR implements logic to sort wheels by priority, where priority is defined as preferring more "specific" wheels over less "specific" wheels. For example, in the case of Black, my machine now selects `black-23.11.0-cp311-cp311-macosx_11_0_arm64.whl`, whereas sorting by lowest priority instead gives me `black-23.11.0-py3-none-any.whl`. As part of this change, I've also modified the resolver to fallback to using incompatible wheels when determining package metadata, if no compatible wheels are available. The `VersionMap` was also moved out of `resolver.rs` and into its own file with a wrapper type, for clarity. Closes https://github.com/astral-sh/puffin/issues/380. Closes https://github.com/astral-sh/puffin/issues/421.
This commit is contained in:
parent
1147a4de14
commit
d3caf9ae86
10 changed files with 254 additions and 87 deletions
|
@ -5,7 +5,7 @@ use thiserror::Error;
|
|||
use url::Url;
|
||||
|
||||
use pep440_rs::Version;
|
||||
use platform_tags::Tags;
|
||||
use platform_tags::{TagPriority, Tags};
|
||||
use puffin_normalize::{InvalidNameError, PackageName};
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
|
@ -122,6 +122,12 @@ impl WheelFilename {
|
|||
compatible_tags.is_compatible(&self.python_tag, &self.abi_tag, &self.platform_tag)
|
||||
}
|
||||
|
||||
/// Return the [`TagPriority`] score of the wheel with the given tags, or `None` if the wheel is
|
||||
/// incompatible.
|
||||
pub fn compatibility(&self, compatible_tags: &Tags) -> Option<TagPriority> {
|
||||
compatible_tags.compatibility(&self.python_tag, &self.abi_tag, &self.platform_tag)
|
||||
}
|
||||
|
||||
/// Get the tag for this wheel.
|
||||
pub fn get_tag(&self) -> String {
|
||||
format!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue