-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix 'uv pip install' handling of gzip'd response and PEP 691 #1978
Conversation
@@ -459,6 +459,10 @@ impl RegistryClient { | |||
.client | |||
.uncached() | |||
.head(url.clone()) | |||
.header( | |||
"accept-encoding", | |||
http::HeaderValue::from_static("identity"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iiinteresting, so when the server returned a gzipped response here, we effectively lost the headers that are required for the range request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is related: #1754.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, that issue suggests that Content-Type
is preserved, nevermind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep they get stripped because they're not accurate after decompression seanmonstar/reqwest#294
@@ -38,7 +38,7 @@ fn sorted_simple_json_files<'de, D: Deserializer<'de>>(d: D) -> Result<Vec<File> | |||
#[serde(rename_all = "kebab-case")] | |||
pub struct File { | |||
// Non-PEP 691-compliant alias used by PyPI. | |||
#[serde(alias = "data_dist_info_metadata")] | |||
#[serde(alias = "data-dist-info-metadata")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow that's a huge oversight, thank you! This could make a big difference in cold resolution time actually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
I'm gonna benchmark this real quick. |
The bad news is that we missed that typo and it's embarrassing. The good news is that it makes cold resolution like 30-40% faster for free:
|
Thanks for the great find! I'll release this in the morning. |
Thank you! This is great work |
Thank you for writing
uv
! We're already using it internally on some container image builds and finding that it's noticeably faster 💯Summary
I was attempting to use
uv
alongside modal's internal PyPi mirror and ran into some issues. The first issue was the following error:This error was coming from within
RegistryClient::wheel_metadata_no_pep658
. By logging requests on the client (uv) and server (internal mirror) sides I've concluded that it's occurring becauseuv
is sending a header suggesting that it can accept a gzip'd response, but decompressing the gzip'd response strips thecontent-length
header: seanmonstar/reqwest#294.Logged request, client-side:
No headers set explicitly by
uv
.Logged request, server-side:
Server receives
"accept-encoding": "gzip, br",
.My change adding the header to the request fixed this issue. But our internal mirror is just passing through PyPI responses and PyPI responses do contain PEP 658 data, and so
wheel_metadata_no_pep658
shouldn't execute.The issue there is that the PyPi response field has dashes not underscores (https://peps.python.org/pep-0691/).
After changing the
alias
the PEP 658 codepath now runs correctly :)Test Plan
I tested by installing against both our mirror and against PyPi: