Avoid dropping pip sync requirements with markers (#4051)

## Summary

Thankfully this is pretty rare since `pip sync` is usually run on `pip
compile` output, and `pip compile` never outputs markers.

Closes https://github.com/astral-sh/uv/issues/4044
This commit is contained in:
Charlie Marsh 2024-06-05 12:05:46 -04:00 committed by GitHub
parent b0d1fc85a9
commit ae9610104a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View file

@ -954,6 +954,20 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
} => {
// If we're excluding transitive dependencies, short-circuit.
if self.dependency_mode.is_direct() {
// If a package has a marker, add a dependency from it to the
// same package without markers.
if marker.is_some() {
return Ok(Dependencies::Available(vec![(
PubGrubPackage::from(PubGrubPackageInner::Package {
name: name.clone(),
extra: extra.clone(),
marker: None,
url: url.clone(),
}),
Range::singleton(version.clone()),
)]));
}
// If an extra is provided, wait for the metadata to be available, since it's
// still required for generating the lock file.
let dist = match url {