-
Notifications
You must be signed in to change notification settings - Fork 730
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
Implicit post release version/name splitting not splitting correctly #7155
Comments
I believe we do support implicit post-releases, e.g.: uv/crates/pep440-rs/src/version.rs Line 3408 in aa3297a
So the issue in just in how we do the splitting there. |
It should be not-too-hard to fix. We should instead try to strip the canonical name, and error if it doesn't match; then warn if the remaining segment doesn't match the version. (As opposed to splitting on |
PR welcome if you're up for it :) |
You're right, my bad! I'll update the title to better reflect the problem. |
I'll give it the ole college try. Never written a lick of Rust before, so we'll see how this goes 👍 |
Great! Just let me know if you're not able or don't plan to get to it, so we can prioritize accordingly. |
Sorry, should have followed up earlier. I've hit a few snags with the implementation --I'll try to sum them up. The problem (as least as I've come to understand it) lies in uv's inability (right now) to determine what the "package name" is vs. what the "version" is, mostly due to how unconstrained the I attempted to mirror what the pip implementation does, but that impl relies on a generic canonicalize_name function that subs whichever chars it can and ignores the others. uv, on the other hand, has structs when more elegantly handle normalizing/canonicalizing names on a per-object-type basis, so there's not a great parallel to what pip's doing (that I could find --there certainly could be one somewhere 😃). I got to: // Like `pip`, validate that the `.dist-info` directory is prefixed with the canonical
// package name, but only warn if the version is not the normalized version.
let canonical_dist_info_prefix = PackageName::from_str(&dist_info_prefix)?;
let Some(version) = canonical_dist_info_prefix.as_str().strip_prefix(&filename.name.as_dist_info_name().to_string()) else {
return Err(Error::MissingDistInfoPackageName(
dist_info_prefix.to_string(),
filename.name.to_string(),
));
};
// ...
// ... use `version` and warn user if necessary but I had issues with edge-case It seems that this could be solved with either:
Thanks for all that you do! Great products 🫡 |
FWIW, I didn't want to slap in a private |
No worries at all, thanks for following up! Lemme take a look... |
Does this work? diff --git a/crates/install-wheel-rs/src/metadata.rs b/crates/install-wheel-rs/src/metadata.rs
index 5129ad097..4308163e8 100644
--- a/crates/install-wheel-rs/src/metadata.rs
+++ b/crates/install-wheel-rs/src/metadata.rs
@@ -50,7 +50,8 @@ pub fn find_archive_dist_info<'a, T: Copy>(
// Like `pip`, validate that the `.dist-info` directory is prefixed with the canonical
// package name, but only warn if the version is not the normalized version.
- let Some((name, version)) = dist_info_prefix.rsplit_once('-') else {
+ let normalized_prefix = PackageName::from_str(&dist_info_prefix)?.as_dist_info_name();
+ let Some((name, version)) = normalized_prefix.rsplit_once('-') else {
return Err(Error::MissingDistInfoSegments(dist_info_prefix.to_string()));
};
if PackageName::from_str(name)? != filename.name { |
I think the issues lies in the |
I mean, could totally toss in a /// Canonicalize name according to PEP 503
fn canonicalize_name(name: &str) -> String {
let re = Regex::new(r"[-_.]+").unwrap();
re.replace_all(name, "-").to_lowercase()
} and compare |
It's possible that we should just skip these checks when there are multiple |
I think it's probably safe to pass the dist info name to |
If that's the case, great! I was running into issues with the normalization process because some versions can contain a (I don't believe what I linked above is the actual test that was failing --can't find the exact one. Just meant as an example) |
Ahh that's true, you're right. |
We may want to create a |
That's kinda where I arrived, but then I reminded myself that I'm not a rust dev and that biting that off would be a lot 😆 |
Haha no worries. I'll give it a try and can mark you as a co-author on it. |
As one would expect, right as I try to test it out I'm running into toolchain issues 😬. uv pip install aardvark-py==5.40 should flex the behavior. I'll keep trying to fix up my build env Thanks for such a quick turnaround! |
Looks like it works! ❯ target/debug/uv venv test_venv
Using Python 3.12.1
Creating virtualenv at: test_venv
Activate with: source test_venv/bin/activate
❯ source test_venv/bin/activate
❯ target/debug/uv pip install aardvark-py==5.40
Resolved 1 package in 1.45s
Prepared 1 package in 48ms
Installed 1 package in 4ms
+ aardvark-py==5.40 |
Summary
uv
doesn't appear to support implicit post releases (e.g1.2.3-1
does not work, whereas1.2.3.post1
does). I poked around the source a little and found that when theversion
preceding.dist_info
has an implicit post release specifier, therstrip_once
call in this block improperly splits the string, leading to the following error message:Recreate
Environment
I was hoping I could tackle this one myself, but after I saw that version.rs may need changes, I figure'd I'd leave it to the experts 😆
EDIT: Turns out that there aren't changes needed to
version.rs
--onlymetadata.rs
.The text was updated successfully, but these errors were encountered: