mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 04:48:18 +00:00
Allow package lookups across multiple indexes via explicit opt-in (#2815)
## Summary This partially revives https://github.com/astral-sh/uv/pull/2135 (with some modifications) to enable users to opt-in to looking for packages across multiple indexes. The behavior is such that, in version selection, we take _any_ compatible version from a "higher-priority" index over the compatible versions of a "lower-priority" index, even if that means we might accept an "older" version. Closes https://github.com/astral-sh/uv/issues/2775.
This commit is contained in:
parent
e0d55ef496
commit
34341bd6e9
23 changed files with 351 additions and 106 deletions
|
|
@ -21,6 +21,7 @@ uv-interpreter = { workspace = true }
|
|||
uv-normalize = { workspace = true }
|
||||
|
||||
anyhow = { workspace = true }
|
||||
clap = { workspace = true, features = ["derive"], optional = true }
|
||||
itertools = { workspace = true }
|
||||
rustc-hash = { workspace = true }
|
||||
serde = { workspace = true, optional = true }
|
||||
|
|
|
|||
|
|
@ -211,6 +211,29 @@ impl NoBuild {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Hash, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
||||
pub enum IndexStrategy {
|
||||
/// Only use results from the first index that returns a match for a given package name.
|
||||
///
|
||||
/// While this differs from pip's behavior, it's the default index strategy as it's the most
|
||||
/// secure.
|
||||
#[default]
|
||||
FirstMatch,
|
||||
/// Search for every package name across all indexes, exhausting the versions from the first
|
||||
/// index before moving on to the next.
|
||||
///
|
||||
/// In this strategy, we look for every package across all indexes. When resolving, we attempt
|
||||
/// to use versions from the indexes in order, such that we exhaust all available versions from
|
||||
/// the first index before moving on to the next. Further, if a version is found to be
|
||||
/// incompatible in the first index, we do not reconsider that version in subsequent indexes,
|
||||
/// even if the secondary index might contain compatible versions (e.g., variants of the same
|
||||
/// versions with different ABI tags or Python version constraints).
|
||||
///
|
||||
/// See: https://peps.python.org/pep-0708/
|
||||
UnsafeAnyMatch,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::str::FromStr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue