Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If multiple indices contain the same version, use the first index #5288

Merged
merged 2 commits into from
Jul 22, 2024

Conversation

yorickvP
Copy link
Contributor

@yorickvP yorickvP commented Jul 22, 2024

This fixes resolving packages that publish an invalid stub to pypi, such as tensorrt-llm.

Summary

In #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

$ 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

cc: @charliermarsh

@charliermarsh charliermarsh self-assigned this Jul 22, 2024
@charliermarsh charliermarsh added the bug Something isn't working label Jul 22, 2024
This fixes resolving packages that publish an invalid stub to pypi,
such as tensorrt-llm.
@yorickvP yorickvP force-pushed the yorickvp/fix-multi-index branch from ddde8d7 to 829c2cb Compare July 22, 2024 14:21
@charliermarsh
Copy link
Member

charliermarsh commented Jul 22, 2024

Yeah interesting, contrary to my expectation kmerge isn't "stable" by iterator:

#[cfg(test)]
mod tests {
    use itertools::Itertools;

    #[test]
    fn kmerge_reverse() {
        let a = vec![('a', 1), ('b', 2), ('c', 3)];
        let b = vec![('d', 1), ('e', 2), ('f', 3)];

        let its = [a, b];
        let its = its.iter().kmerge_by(|a, b| a.1 < b.1);

        let actual = its.collect::<Vec<_>>();
        let expected = vec![&('a', 1), &('d', 1), &('b', 2), &('e', 2), &('c', 3), &('f', 3)];

        // This fails; left is: `[('a', 1), ('d', 1), ('e', 2), ('b', 2), ('c', 3), ('f', 3)]`
        assert_eq!(actual, expected);
    }
}

I didn't have any basis for expecting that so I don't think it's a bug, I just assumed it was true.

@charliermarsh
Copy link
Member

@yorickvP - I tweaked to avoid re-comparing. Can you test that it's still passing on your test case?

@charliermarsh charliermarsh self-requested a review July 22, 2024 16:31
@yorickvP
Copy link
Contributor Author

Still works!

@charliermarsh charliermarsh merged commit 0c4627e into astral-sh:main Jul 22, 2024
54 checks passed
@charliermarsh
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants