mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-27 18:36:44 +00:00
Migrate resolver proof-of-concept to PubGrub (#97)
## Summary This PR enables the proof-of-concept resolver to backtrack by way of using the `pubgrub-rs` crate. Rather than using PubGrub as a _framework_ (implementing the `DependencyProvider` trait, letting PubGrub call us), I've instead copied over PubGrub's primary solver hook (which is only ~100 lines or so) and modified it for our purposes (e.g., made it async). There's a lot to improve here, but it's a start that will let us understand PubGrub's appropriateness for this problem space. A few observations: - In simple cases, the resolver is slower than our current (naive) resolver. I think it's just that the pipelining isn't as efficient as in the naive case, where we can just stream package and version fetches concurrently without any bottlenecks. - A lot of the code here relates to bridging PubGrub with our own abstractions -- so we need a `PubGrubPackage`, a `PubGrubVersion`, etc.
This commit is contained in:
parent
a8d020f53c
commit
471a1d657d
53 changed files with 12301 additions and 257 deletions
|
|
@ -264,7 +264,10 @@ impl Requirement {
|
|||
#[allow(clippy::needless_pass_by_value)]
|
||||
#[pyo3(name = "evaluate_markers")]
|
||||
pub fn py_evaluate_markers(&self, env: &MarkerEnvironment, extras: Vec<String>) -> bool {
|
||||
self.evaluate_markers(env, &extras)
|
||||
self.evaluate_markers(
|
||||
env,
|
||||
&extras.iter().map(String::as_str).collect::<Vec<&str>>(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns whether the requirement would be satisfied, independent of environment markers, i.e.
|
||||
|
|
@ -320,12 +323,9 @@ impl Requirement {
|
|||
}
|
||||
|
||||
/// Returns whether the markers apply for the given environment
|
||||
pub fn evaluate_markers(&self, env: &MarkerEnvironment, extras: &[String]) -> bool {
|
||||
pub fn evaluate_markers(&self, env: &MarkerEnvironment, extras: &[&str]) -> bool {
|
||||
if let Some(marker) = &self.marker {
|
||||
marker.evaluate(
|
||||
env,
|
||||
&extras.iter().map(String::as_str).collect::<Vec<&str>>(),
|
||||
)
|
||||
marker.evaluate(env, extras)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue