mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
uv-resolver: use Requires-Python to filter dependencies during universal resolution
In the time before universal resolving, we would always pass a `MarkerEnvironment`, and this environment would capture any relevant `Requires-Python` specifier (including if `-p/--python` was provided on the CLI). But in universal resolution, we very specifically do not use a `MarkerEnvironment` because we want to produce a resolution that is compatible across potentially multiple environments. This in turn meant that we lost `Requires-Python` filtering. This PR adds it back. We do this by converting our `PythonRequirement` into a `MarkerTree` that encodes the version specifiers in a `Requires-Python` specifier. We then ask whether that `MarkerTree` is disjoint with a dependency specification's `MarkerTree`. If it is, then we know it's impossible for that dependency specification to every be true, and we can completely ignore it.
This commit is contained in:
parent
c32667caec
commit
75b323232d
8 changed files with 147 additions and 422 deletions
|
@ -58,6 +58,12 @@ impl PythonRequirement {
|
|||
pub fn target(&self) -> Option<&PythonTarget> {
|
||||
self.target.as_ref()
|
||||
}
|
||||
|
||||
/// Return the target version of Python as a "requires python" type,
|
||||
/// if available.
|
||||
pub(crate) fn requires_python(&self) -> Option<&RequiresPython> {
|
||||
self.target().and_then(|target| target.as_requires_python())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue