mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Remove requires-python
application in lock deserialization (#6115)
## Summary This is no longer required since we no longer implement `Eq` on `Lock`. It will also sometimes be "wrong" as of #6076, since we now apply different `requires-python` filtering to different parts of the tree during resolution.
This commit is contained in:
parent
3ee865831f
commit
592af438b8
2 changed files with 1 additions and 56 deletions
|
@ -8,7 +8,6 @@ use std::str::FromStr;
|
|||
use either::Either;
|
||||
use itertools::Itertools;
|
||||
use petgraph::visit::EdgeRef;
|
||||
use pubgrub::Range;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use toml_edit::{value, Array, ArrayOfTables, InlineTable, Item, Table, Value};
|
||||
use tracing::debug;
|
||||
|
@ -70,60 +69,6 @@ pub struct Lock {
|
|||
}
|
||||
|
||||
impl Lock {
|
||||
/// Deserialize the [`Lock`] from a TOML string.
|
||||
pub fn from_toml(s: &str) -> Result<Lock, toml::de::Error> {
|
||||
let mut lock: Lock = toml::from_str(s)?;
|
||||
|
||||
// Simplify all marker expressions based on the requires-python bound.
|
||||
//
|
||||
// This is necessary to ensure the a `Lock` deserialized from a lockfile compares
|
||||
// equally to a newly created `Lock`.
|
||||
// TODO(ibraheem): we should only simplify python versions when serializing or ensure
|
||||
// the requires-python bound is enforced on construction to avoid this step.
|
||||
if let Some(requires_python) = &lock.requires_python {
|
||||
let python_version = Range::from(requires_python.bound_major_minor().clone());
|
||||
let python_full_version = Range::from(requires_python.bound().clone());
|
||||
|
||||
for package in &mut lock.packages {
|
||||
for dep in &mut package.dependencies {
|
||||
dep.marker = dep.marker.clone().simplify_python_versions(
|
||||
python_version.clone(),
|
||||
python_full_version.clone(),
|
||||
);
|
||||
}
|
||||
|
||||
for dep in package.optional_dependencies.values_mut().flatten() {
|
||||
dep.marker = dep.marker.clone().simplify_python_versions(
|
||||
python_version.clone(),
|
||||
python_full_version.clone(),
|
||||
);
|
||||
}
|
||||
|
||||
for dep in package.dev_dependencies.values_mut().flatten() {
|
||||
dep.marker = dep.marker.clone().simplify_python_versions(
|
||||
python_version.clone(),
|
||||
python_full_version.clone(),
|
||||
);
|
||||
}
|
||||
|
||||
for markers in &mut package.fork_markers {
|
||||
*markers = markers.clone().simplify_python_versions(
|
||||
python_version.clone(),
|
||||
python_full_version.clone(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for markers in &mut lock.fork_markers {
|
||||
*markers = markers
|
||||
.clone()
|
||||
.simplify_python_versions(python_version.clone(), python_full_version.clone());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(lock)
|
||||
}
|
||||
|
||||
/// Initialize a [`Lock`] from a [`ResolutionGraph`].
|
||||
pub fn from_resolution_graph(graph: &ResolutionGraph) -> Result<Self, LockError> {
|
||||
let mut locked_dists = BTreeMap::new();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue