Select most recent wheel, most recent sdist (#190)

Select a compatible wheel for a version, even we already found a source
distribution previously.

If no wheel is found, select the most recent source distribution, not
the oldest compatible one.

This fixes the resolution of `mst.in`, which i added
This commit is contained in:
konsti 2023-10-26 10:15:26 +02:00 committed by GitHub
parent 13e4171916
commit 862c1654a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 5 deletions

View file

@ -531,10 +531,21 @@ impl<'a, Context: BuildContext> Resolver<'a, Context> {
if let Ok(name) = WheelFilename::from_str(file.filename.as_str()) {
if name.is_compatible(self.tags) {
let version = PubGrubVersion::from(name.version);
if let std::collections::btree_map::Entry::Vacant(entry) =
version_map.entry(version)
{
entry.insert(DistributionFile::from(WheelFile::from(file)));
match version_map.entry(version) {
std::collections::btree_map::Entry::Occupied(mut entry) => {
if let DistributionFile::Sdist(_) = entry.get() {
// Wheels get precedence over source distributions
entry.insert(DistributionFile::from(
WheelFile::from(file),
));
}
}
std::collections::btree_map::Entry::Vacant(entry) => {
entry.insert(DistributionFile::from(WheelFile::from(
file,
)));
}
}
}
} else if let Ok(name) = SourceDistributionFilename::parse(

View file

@ -153,13 +153,16 @@ impl CandidateSelector {
file: file.clone(),
});
}
DistributionFile::Sdist(_) => {
DistributionFile::Sdist(_) if sdist.is_none() => {
sdist = Some(Candidate {
package_name: package_name.clone(),
version: version.clone(),
file: file.clone(),
});
}
DistributionFile::Sdist(_) => {
// We already selected a more recent source distribution
}
}
}
}

View file

@ -0,0 +1 @@
meine_stadt_transparent