mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-17 05:47:45 +00:00
uv-resolver: use new simplify/complexify marker routines
This finally gets rid of our hack for working around "hidden" state. We no longer do a roundtrip marker serialization and deserialization just to avoid the hidden state.
This commit is contained in:
parent
2c139d6fca
commit
f6bc701ac3
1 changed files with 5 additions and 15 deletions
|
@ -317,14 +317,8 @@ impl RequiresPython {
|
|||
/// markers are "complexified" to put the `requires-python` assumption back
|
||||
/// into the marker explicitly.
|
||||
pub(crate) fn simplify_markers(&self, marker: MarkerTree) -> MarkerTree {
|
||||
let simplified = marker.simplify_python_versions(Range::from(self.range().clone()));
|
||||
// FIXME: This is a hack to avoid the hidden state created by
|
||||
// ADD's `restrict_versions`. I believe this is sound, but it's
|
||||
// wasteful and silly.
|
||||
simplified
|
||||
.try_to_string()
|
||||
.map(|s| s.parse().unwrap())
|
||||
.unwrap_or(MarkerTree::TRUE)
|
||||
let (lower, upper) = (self.range().lower(), self.range().upper());
|
||||
marker.simplify_python_versions(lower.0.as_ref(), upper.0.as_ref())
|
||||
}
|
||||
|
||||
/// The inverse of `simplify_markers`.
|
||||
|
@ -342,13 +336,9 @@ impl RequiresPython {
|
|||
/// ```text
|
||||
/// python_full_version >= '3.8' and python_full_version < '3.12'
|
||||
/// ```
|
||||
pub(crate) fn complexify_markers(&self, mut marker: MarkerTree) -> MarkerTree {
|
||||
// PERF: There's likely a way to amortize this, particularly
|
||||
// the construction of `to_marker_tree`. But at time of
|
||||
// writing, it wasn't clear if this was an actual perf problem
|
||||
// or not. If it is, try a `std::sync::OnceLock`.
|
||||
marker.and(self.to_marker_tree());
|
||||
marker
|
||||
pub(crate) fn complexify_markers(&self, marker: MarkerTree) -> MarkerTree {
|
||||
let (lower, upper) = (self.range().lower(), self.range().upper());
|
||||
marker.complexify_python_versions(lower.0.as_ref(), upper.0.as_ref())
|
||||
}
|
||||
|
||||
/// Returns `false` if the wheel's tags state it can't be used in the given Python version
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue