-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Create proxies for pip, wheel, etc. to get around problems with long paths #1004
Create proxies for pip, wheel, etc. to get around problems with long paths #1004
Conversation
Related to #994 |
…paths and spaces in paths
9593971
to
55e3441
Compare
os.rename(script, hidden_destination) | ||
|
||
with open(script, "w") as script_proxy: | ||
text = "#!/usr/bin/env sh" |
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.
Should this not force an appropriate encoding? What if the venv name contains non-ASCII characters?
The change should be in distlib instead of virtualenv.
|
@yan12125 Oh, this is not applied to packages installed by the new virtualenv. That's bad. Either I extend the code to do the replacement on every installed executable starting with a shebang. Or we find some way to put the code deeper into the system like distlib. |
@HaraldNordgren I assumed that it was a deliberate to only target the wrappers virtualenv itself installs. If it wasn't, then yes it would need to go into distlib at a minimum so that anything installed by pip would be handled. And technically into any other tool that people might use to install wrappers stuff into the virtualenv (like easy_install/setuptools). Ultimately, as it's a workaround for an OS limitation, it's up to you how far you want to go patching the various tools. |
I created a pull request for the corresponding changes in For development, I modified SCRIPT = textwrap.dedent("""
import sys
import pkgutil
import tempfile
import os
import sys
sys.path.insert(0, '/home/harald/git-repos/pip')
import pip
... to get
And after creating and activating the env, I also run this in the terminal export PYTHONPATH=/home/harald/git-repos/pip before trying for example Hopefully this won't have to be done in production, if we can get these changes into an actual release on distlib. |
@HaraldNordgren Did you test your PR on Windows? Because I saw it and had a quick look, and it doesn't look like it limits the change to Windows. I'd comment on the PR itself, but I don't have access to bitbucket right at the moment,,, |
It has not been tested on Windows, only Ubuntu 16.04. I was hoping that the |
Hmm, OK. Someone will have to test on Windows, I guess. |
Maybe here is an even better solution, based on an idea from a Mach bootstrap script: |
IMO, this is an immensely complex (and hence difficult to maintain) workaround to an OS limitation of certain Unix systems, that comes up relatively rarely. While I agree that it fails in a pretty unpleasant way, and it would be good to do something, I'd rather any workaround be limited to cases where it's needed - which is of course hard to determine precisely because it's an OS issue rather than a pip/distlib/virtualenv issue. On the other hand, I don't have any direct interest in the solution, as I am a Windows user and this issue doesn't occur on Windows, so if the Unix developers are happy with the proposed solution, I won't object (as long as it is only a Unix solution, and Windows behaviour remains as it currently is). |
I think you have a point that we could limit the fix to the situations where it breaks. I tried to change the Bitbucket PR to achieve that. So only pad the shebang when it would otherwise break. That also highlights the need for the PR -- without it Since we are dealing with shebangs, I am fairly certain that it won't affect Windows. |
Just FYI: py.exe on Windows (PC\launcher.c) uses shebangs. |
Ok, good to know. I'll keep working on this. I don't think Vinay Sajip at Distlib will accept the change there, but he pointed me to |
This will move
pip
to.pip
after installation, then creates a newpip
file containingThis eliminates the problems with long paths that stem from limitations of the shebang on Unix. This should also solve the problems with spaces in path names.
(See #997 for more discussion)