diff --git a/crates/uv-resolver/src/lock.rs b/crates/uv-resolver/src/lock.rs index 72d819288..4cc2cbdbd 100644 --- a/crates/uv-resolver/src/lock.rs +++ b/crates/uv-resolver/src/lock.rs @@ -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 { - 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 { let mut locked_dists = BTreeMap::new(); diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index 21eb37a1e..80f71e719 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -710,7 +710,7 @@ pub(crate) async fn commit(lock: &Lock, workspace: &Workspace) -> Result<(), Pro /// Returns `Ok(None)` if the lockfile does not exist. pub(crate) async fn read(workspace: &Workspace) -> Result, ProjectError> { match fs_err::tokio::read_to_string(&workspace.install_path().join("uv.lock")).await { - Ok(encoded) => match Lock::from_toml(&encoded) { + Ok(encoded) => match toml::from_str(&encoded) { Ok(lock) => Ok(Some(lock)), Err(err) => { eprint!("Failed to parse lockfile; ignoring locked requirements: {err}");