mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-03 07:14:35 +00:00
If multiple indices contain the same version, use the first index (#5288)
This fixes resolving packages that publish an invalid stub to pypi, such as tensorrt-llm. ## Summary In https://github.com/astral-sh/uv/pull/3138 , we implemented `unsafe-best-match`. However, it seems to not quite work as expected. When multiple indices contain the same version, it's not clear which index the current code uses. This PR fixes that to use the first index the package is in. ## Test Plan ```console $ echo 'tensorrt-llm==0.11.0' | ./target/debug/uv pip compile - --extra-index-url https://pypi.nvidia.com --python-version=3.10 --index-strategy=unsafe-best-match --annotation-style=line ```
This commit is contained in:
parent
6492f1a897
commit
0c4627e2f2
1 changed files with 28 additions and 4 deletions
|
@ -232,8 +232,20 @@ impl CandidateSelector {
|
|||
Self::select_candidate(
|
||||
version_maps
|
||||
.iter()
|
||||
.map(|version_map| version_map.iter().rev())
|
||||
.kmerge_by(|(version1, _), (version2, _)| version1 > version2),
|
||||
.enumerate()
|
||||
.map(|(map_index, version_map)| {
|
||||
version_map.iter().rev().map(move |item| (map_index, item))
|
||||
})
|
||||
.kmerge_by(
|
||||
|(index1, (version1, _)), (index2, (version2, _))| match version1
|
||||
.cmp(version2)
|
||||
{
|
||||
std::cmp::Ordering::Equal => index1 < index2,
|
||||
std::cmp::Ordering::Less => false,
|
||||
std::cmp::Ordering::Greater => true,
|
||||
},
|
||||
)
|
||||
.map(|(_, item)| item),
|
||||
package_name,
|
||||
range,
|
||||
allow_prerelease,
|
||||
|
@ -242,8 +254,20 @@ impl CandidateSelector {
|
|||
Self::select_candidate(
|
||||
version_maps
|
||||
.iter()
|
||||
.map(VersionMap::iter)
|
||||
.kmerge_by(|(version1, _), (version2, _)| version1 < version2),
|
||||
.enumerate()
|
||||
.map(|(map_index, version_map)| {
|
||||
version_map.iter().map(move |item| (map_index, item))
|
||||
})
|
||||
.kmerge_by(
|
||||
|(index1, (version1, _)), (index2, (version2, _))| match version1
|
||||
.cmp(version2)
|
||||
{
|
||||
std::cmp::Ordering::Equal => index1 < index2,
|
||||
std::cmp::Ordering::Less => true,
|
||||
std::cmp::Ordering::Greater => false,
|
||||
},
|
||||
)
|
||||
.map(|(_, item)| item),
|
||||
package_name,
|
||||
range,
|
||||
allow_prerelease,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue