Set exact version specifiers when resolving from lockfile (#5193)

## Summary

Should resolve https://github.com/astral-sh/uv/issues/5192.

## Test Plan

@konstin can you confirm this fixes your issue?
This commit is contained in:
Ibraheem Ahmed 2024-07-18 13:02:08 -04:00 committed by GitHub
parent 7beae77283
commit bbd65fc626
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,7 +24,7 @@ use distribution_types::{
RemoteSource, Resolution, ResolvedDist, SourceDistCompatibility, ToUrlError, UrlString, RemoteSource, Resolution, ResolvedDist, SourceDistCompatibility, ToUrlError, UrlString,
VersionId, WheelCompatibility, VersionId, WheelCompatibility,
}; };
use pep440_rs::{Version, VersionSpecifiers}; use pep440_rs::{Version, VersionSpecifier};
use pep508_rs::{ use pep508_rs::{
ExtraOperator, MarkerEnvironment, MarkerExpression, MarkerTree, VerbatimUrl, VerbatimUrlError, ExtraOperator, MarkerEnvironment, MarkerExpression, MarkerTree, VerbatimUrl, VerbatimUrlError,
}; };
@ -2068,7 +2068,12 @@ impl Dependency {
// Reconstruct the `RequirementSource` from the `Source`. // Reconstruct the `RequirementSource` from the `Source`.
let source = match &self.distribution_id.source { let source = match &self.distribution_id.source {
Source::Registry(_) => RequirementSource::Registry { 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, index: None,
}, },
Source::Git(repository, git) => { Source::Git(repository, git) => {