Loosen .dist-info validation to accept arbitrary versions (#2441)

## Summary

It turns out that pip does _not_ validate the normalization of the
version specifier in the `.dist-info` directory. In particular, it seems
that some tools replace the `+` in a local version segment with a `_`.

Closes https://github.com/astral-sh/uv/issues/2424.
This commit is contained in:
Charlie Marsh 2024-03-14 06:04:39 -07:00 committed by GitHub
parent b5d9014918
commit 492ffbf997
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 63 additions and 33 deletions

View file

@ -137,6 +137,8 @@ pub fn install_wheel(
/// Find the `dist-info` directory in an unzipped wheel.
///
/// See: <https://github.com/PyO3/python-pkginfo-rs>
///
/// See: <https://github.com/pypa/pip/blob/36823099a9cdd83261fdbc8c1d2a24fa2eea72ca/src/pip/_internal/utils/wheel.py#L38>
fn find_dist_info(path: impl AsRef<Path>) -> Result<String, Error> {
// Iterate over `path` to find the `.dist-info` directory. It should be at the top-level.
let Some(dist_info) = fs::read_dir(path.as_ref())?.find_map(|entry| {