-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Handle symlinks when extracting .whl
files
#10935
Comments
Do you have a source for this information? |
Here they use https://stackoverflow.com/a/60691331 Although using You can verify this by printing the ZipInfo of the file. It should print as something like this: |
Wheels (and more importantly, I believe the standard library) don't support symlinks, This is a known limitation, and the fact that you have to maually create a wheel containing symlinks demonstrates that it's not simply a pip issue, but the whole toolchain doesn't support them. There have been discussions about how to support symlinks in wheels (and what to do about wheels containing symlinks on platforms that don't support them) but as yet there's been no conclusion. See, for example, https://discuss.python.org/t/symbolic-links-in-wheels/1945 |
Also see https://bugs.python.org/issue27318 A lot of layers need to be fixed before pip has a chance to support symlinks. |
I understand concerns about symlinks in Wheels AND if they are non-standard, then setuptools, distutils, and pip should at least warn about them and not just writing text files and let the user spend hours looking for possible reason. However, as Wheels are supposed to be binary distributions (mainly meant for a particular platform) I think it should be in the package owners responsibility to make sure that he builds working packages. So an easy extension to my proposed fix would be: if is_symlink():
if platform_supports_symlinks():
os.symlink(...)
else:
raise Exception('This platform does not support symlinks, please contact package provider...') And yes, setuptools and others don't support to add symlinks yet, which does not mean that PIP should not be the first to support them (Chicken Egg problem?). @uranusjr: yes I agree but I think that rather aims for the |
The problem is less about where the fix should go, but that any fix pip introduces would encounter the same issue faced by |
Personally, I think that the symlinks-in-wheels issue should not be solved by putting actual symlinks in the wheel (which, as has been noted, relies on functions which have various issues) but rather by having metadata in the wheel stating "installers should make these symlinks". I'm working on a proposal based on this idea. I suggest this discussion gets taken to the Discourse thread I linked previously - I don't expect pip to implement support for symlinks in wheels until it's standardised, so having the discussion here is pointless (and means that not everyone with an interest in the topic has visibility of it). |
Also, if you can't include symlinks in wheels using standard tools like setuptools or flit, adding support in pip is mostly pointless... |
You can get symlink support in wheels using https://github.com/karellen/wheel-axle For an example, please see: https://github.com/karellen/wheel-axle-example |
.whl
files
Description
PIP does not export symlinks correctly when processing WHL archives. See my proof below. Expected output should be:
But PIP creates
bla.txt.link
as a text file containing "bla.txt"Fixing this issue is rather easy. The code at
pip/_internal/operations/install/wheel.py#L388
needs to be changed to:Explanation: the 29th bit in
zipinfo.external_attr
indicates if this is a symlink. In that case, the content of the file is the link destination.Expected behavior
Symlinks should be extracted correctly and not as text files.
pip version
22.0.3
Python version
3.7
OS
Linux
How to Reproduce
Output
Code of Conduct
The text was updated successfully, but these errors were encountered: