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

Some packages can not be installed with uv contrary to pip, like ziglang #6615

Closed
Coruscant11 opened this issue Aug 25, 2024 · 0 comments · Fixed by #6616
Closed

Some packages can not be installed with uv contrary to pip, like ziglang #6615

Coruscant11 opened this issue Aug 25, 2024 · 0 comments · Fixed by #6616
Labels
bug Something isn't working compatibility Compatibility with a specification or another tool

Comments

@Coruscant11
Copy link
Contributor

Coruscant11 commented Aug 25, 2024

Hello 🙂 First let me thank you for this awesome project !! ❤️

The issue

By using uv, I somehow managed to find a strange behaviour in wheel installations.
Indeed, on Linux, I was not able to install the ziglang package with uv.
Here is the error message:

(fixeduv) root@871e96b7ad46:/uv# uv pip install ziglang
Resolved 1 package in 225ms
error: Failed to install: ziglang-0.13.0-py3-none-manylinux_2_17_aarch64.many
linux2014_aarch64.musllinux_1_1_aarch64.http.whl (ziglang==0.13.0)
  Caused by: The wheel is invalid: Line 5 of the WHEEL file is invalid

The cause

So I looked at the WHEEL file content:

Wheel-Version: 1.0
Generator: ziglang make_wheels.py
Root-Is-Purelib: false
Tag:
  py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64

Hint: the markdown syntax is email
You can reproduce the parsing error with a unit test testing this wheel content here

Meanwhile, pip can totally install it.
We can directly see that the tag value is containing a linesep and two spaces. So we could say that the wheel is indeed invalid, and uv is not to blame here. But the fact is that pip is installing the wheel without any issue...

So i looked at the source code of uv and pip. And I discovered that the parsing method was not the same.
While uv is using a simple key value text file parsing method, pip is using email.message_from_file function from the python standard library, as you can see here.

But not only uv, bdist_wheel too

So I deduced that the WHEEL and METADATA files should be generated with email headers syntax.
Furthermore, by looking at the source code of uv and pip, we can also see that the Tag field is totally useless and not read, because both are fetching the tag from the wheel filename. So this issue is only a parsing file method issue.

But then I was then wondering, what could be the reason making uv maintainers not using the same parsing method ? For sure the PEP specification fo the wheels should tell that we need to use email messages formats right ?
But the PEP is in fact only talking about basic key value format
image
I should probably contact them in order to have their opinion! 😄

Solution

I think the solution here is pretty simple : let's use the same parsing method as pip, which is parsing these file as email messages! 🚀
uv needs to be as fast as possible, so I found the mail_parser crate
And the test runs as fast as the previous parsing method, sometimes even faster.
I will linked the pull-request #6616: waiting for your opinion! 😊
I also added a unit test for this specific use case.

Here is the result:

(fixeduv) root@871e96b7ad46:/uv# uv pip install ziglang
Resolved 1 package in 225ms
error: Failed to install: ziglang-0.13.0-py3-none-manylinux_2_17_aarch64.many
linux2014_aarch64.musllinux_1_1_aarch64.http.whl (ziglang==0.13.0)
  Caused by: The wheel is invalid: Line 5 of the WHEEL file is invalid
(fixeduv) root@871e96b7ad46:/uv# ./target/release/uv pip install ziglang
Resolved 1 package in 3ms
Installed 1 package in 177ms
 + ziglang==0.13.0
(fixeduv) root@871e96b7ad46:/uv# uname -a
Linux 871e96b7ad46 6.8.11-300.fc40.aarch64 #1 SMP PREEMPT_DYNAMIC Mon May 27
15:22:03 UTC 2024 aarch64 GNU/Linux

Thanks !!! I am open to anything if needed, first contribution on this awesome project here 😄

@Coruscant11 Coruscant11 changed the title Some wheel can not be installed with uv contrary to pip, like ziglang Some packages can not be installed with uv contrary to pip, like ziglang Aug 25, 2024
@charliermarsh charliermarsh added bug Something isn't working compatibility Compatibility with a specification or another tool labels Aug 25, 2024
charliermarsh pushed a commit that referenced this issue Aug 25, 2024
## Summary

Fixes: #6615 
Currently, some packages are not installable with `uv`, like `ziglang`
on Linux.
Everything is described in the issue! 😄 

<!-- What's the purpose of the change? What does it do, and why? -->

## Test Plan

<!-- How was it tested? -->
I added a unit test for the problematic use case.
I also checked that previous unit test are still running in order to
ensure the backward compatibility.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compatibility Compatibility with a specification or another tool
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants