mirror of https://github.com/astral-sh/uv
Don't prefetch unreachable packages (#8246)
This commit is contained in:
parent
cf7fcaa942
commit
32bba9f33b
|
|
@ -2479,7 +2479,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pubgrub"
|
name = "pubgrub"
|
||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
source = "git+https://github.com/astral-sh/pubgrub?rev=19c77268c0ad5f69d7e12126e0cfacfbba466481#19c77268c0ad5f69d7e12126e0cfacfbba466481"
|
source = "git+https://github.com/astral-sh/pubgrub?rev=7243f4faf8e54837aa8a401a18406e7173de4ad5#7243f4faf8e54837aa8a401a18406e7173de4ad5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ pathdiff = { version = "0.2.1" }
|
||||||
petgraph = { version = "0.6.5" }
|
petgraph = { version = "0.6.5" }
|
||||||
platform-info = { version = "2.0.3" }
|
platform-info = { version = "2.0.3" }
|
||||||
proc-macro2 = { version = "1.0.86" }
|
proc-macro2 = { version = "1.0.86" }
|
||||||
pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "19c77268c0ad5f69d7e12126e0cfacfbba466481" }
|
pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "7243f4faf8e54837aa8a401a18406e7173de4ad5" }
|
||||||
quote = { version = "1.0.37" }
|
quote = { version = "1.0.37" }
|
||||||
rayon = { version = "1.10.0" }
|
rayon = { version = "1.10.0" }
|
||||||
reflink-copy = { version = "0.1.19" }
|
reflink-copy = { version = "0.1.19" }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
|
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use pubgrub::Range;
|
use pubgrub::{Range, Term};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use tokio::sync::mpsc::Sender;
|
use tokio::sync::mpsc::Sender;
|
||||||
use tracing::{debug, trace};
|
use tracing::{debug, trace};
|
||||||
|
|
@ -49,6 +49,7 @@ impl BatchPrefetcher {
|
||||||
index: Option<&IndexUrl>,
|
index: Option<&IndexUrl>,
|
||||||
version: &Version,
|
version: &Version,
|
||||||
current_range: &Range<Version>,
|
current_range: &Range<Version>,
|
||||||
|
unchangeable_constraints: Option<&Term<Range<Version>>>,
|
||||||
python_requirement: &PythonRequirement,
|
python_requirement: &PythonRequirement,
|
||||||
request_sink: &Sender<Request>,
|
request_sink: &Sender<Request>,
|
||||||
in_memory: &InMemoryIndex,
|
in_memory: &InMemoryIndex,
|
||||||
|
|
@ -119,11 +120,22 @@ impl BatchPrefetcher {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BatchPrefetchStrategy::InOrder { previous } => {
|
BatchPrefetchStrategy::InOrder { previous } => {
|
||||||
let range = if selector.use_highest_version(name) {
|
let mut range = if selector.use_highest_version(name) {
|
||||||
Range::strictly_lower_than(previous)
|
Range::strictly_lower_than(previous)
|
||||||
} else {
|
} else {
|
||||||
Range::strictly_higher_than(previous)
|
Range::strictly_higher_than(previous)
|
||||||
};
|
};
|
||||||
|
// If we have constraints from root, don't go beyond those. Example: We are
|
||||||
|
// prefetching for foo 1.60 and have a dependency for `foo>=1.50`, so we should
|
||||||
|
// only prefetch 1.60 to 1.50, knowing 1.49 will always be rejected.
|
||||||
|
if let Some(unchangeable_constraints) = unchangeable_constraints {
|
||||||
|
range = match unchangeable_constraints {
|
||||||
|
Term::Positive(constraints) => range.intersection(constraints),
|
||||||
|
Term::Negative(negative_constraints) => {
|
||||||
|
range.intersection(&negative_constraints.complement())
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
if let Some(candidate) =
|
if let Some(candidate) =
|
||||||
selector.select_no_preference(name, &range, version_map, markers)
|
selector.select_no_preference(name, &range, version_map, markers)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -477,6 +477,10 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
||||||
index,
|
index,
|
||||||
&version,
|
&version,
|
||||||
term_intersection.unwrap_positive(),
|
term_intersection.unwrap_positive(),
|
||||||
|
state
|
||||||
|
.pubgrub
|
||||||
|
.partial_solution
|
||||||
|
.unchanging_term_for_package(&state.next),
|
||||||
&state.python_requirement,
|
&state.python_requirement,
|
||||||
&request_sink,
|
&request_sink,
|
||||||
&self.index,
|
&self.index,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue