From 82161963bf40ff6b700ad5d61721550d9928aec6 Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Thu, 18 Jul 2024 12:47:06 -0400 Subject: [PATCH] set exact version specifiers when resolving from lockfile --- crates/uv-resolver/src/lock.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/uv-resolver/src/lock.rs b/crates/uv-resolver/src/lock.rs index 769b4f32593a..8fed070975d3 100644 --- a/crates/uv-resolver/src/lock.rs +++ b/crates/uv-resolver/src/lock.rs @@ -24,7 +24,7 @@ use distribution_types::{ RemoteSource, Resolution, ResolvedDist, SourceDistCompatibility, ToUrlError, UrlString, VersionId, WheelCompatibility, }; -use pep440_rs::{Version, VersionSpecifiers}; +use pep440_rs::{Version, VersionSpecifier}; use pep508_rs::{ ExtraOperator, MarkerEnvironment, MarkerExpression, MarkerTree, VerbatimUrl, VerbatimUrlError, }; @@ -2068,7 +2068,12 @@ impl Dependency { // Reconstruct the `RequirementSource` from the `Source`. let source = match &self.distribution_id.source { Source::Registry(_) => RequirementSource::Registry { - specifier: VersionSpecifiers::empty(), + // We don't store the version specifier that was originally used for resolution in + // the lockfile, so this might be too restrictive. However, this is the only version + // we have the metadata for, so if resolution fails we will need to fallback to a + // clean resolve. + specifier: VersionSpecifier::equals_version(self.distribution_id.version.clone()) + .into(), index: None, }, Source::Git(repository, git) => {