mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-11 04:56:24 +00:00
Always narrow markers by Python version (#6076)
## Summary Using https://github.com/astral-sh/uv/issues/6064 as a motivating example: at present, on main, we're not properly propagating the `Requires-Python` simplifications. In that case, for example, we end up solving for a branch with `python_version < 3.11`, and a branch `>= 3.11`, even though `Requires-Python` is `>=3.11`. Later, when we get to the graph, we apply version simplification based on `Requires-Python`, which causes us to _remove_ the `python_version < 3.11` markers entirely, leaving us with duplicate dependencies for `pylint`. This PR instead tries to ensure that we always apply this narrowing to requirements and forks, so that we don't need to apply the same simplification when constructing the graph at all. Closes https://github.com/astral-sh/uv/issues/6064. Closes #6059.
This commit is contained in:
parent
f988e43ebd
commit
fe0b873352
11 changed files with 699 additions and 584 deletions
|
@ -1,5 +1,4 @@
|
|||
use pep440_rs::{Version, VersionSpecifiers};
|
||||
use pep508_rs::MarkerTree;
|
||||
use uv_python::{Interpreter, PythonVersion};
|
||||
|
||||
use crate::{RequiresPython, RequiresPythonBound};
|
||||
|
@ -70,17 +69,6 @@ impl PythonRequirement {
|
|||
pub fn target(&self) -> Option<&PythonTarget> {
|
||||
self.target.as_ref()
|
||||
}
|
||||
|
||||
/// Return a [`MarkerTree`] representing the Python requirement.
|
||||
///
|
||||
/// See: [`RequiresPython::to_marker_tree`]
|
||||
pub fn to_marker_tree(&self) -> Option<MarkerTree> {
|
||||
if let Some(PythonTarget::RequiresPython(requires_python)) = self.target.as_ref() {
|
||||
Some(requires_python.to_marker_tree())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue