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

Generated wrapper scripts fail when Python executable path contains spaces #104

Closed
vsajip opened this issue Apr 15, 2018 · 18 comments
Closed
Assignees
Labels
bug Something isn't working critical

Comments

@vsajip
Copy link
Collaborator

vsajip commented Apr 15, 2018

Original report by Paul Moore (Bitbucket: pmoore, GitHub: pmoore).


See pypa/pip#5223. This is a priority issue, as it means that the wrapper pip.exe executable generated by pip 10 won't work for a Python installation in a directory containing a space (e.g. C:\Program Files)

To reproduce, create a virtualenv with a space in the name. I'm here using the copy of distlib vendored with pip 10 (which is distlib 0.2.6), as that's where the bug was first reported.

The file "a.py" below simply contains

def f():
    print("Hello from", __file__)

To reproduce the issue:

PS 13:30 {19:29.901} E:\Work\Scratch\a b                                                               
>.\Scripts\python.exe                                                                                  
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32              
Type "help", "copyright", "credits" or "license" for more information.                                 
>>> import sys                                                                                         
>>> sys.path.append(r'E:\Work\Projects\pip\src\pip\_vendor')                                           
>>> from distlib import scripts                                                                        
>>> s = scripts.ScriptMaker(r'E:\Work\Scratch\a b\x', r'E:\Work\Scratch\a b', add_launchers=True)      
>>> s.make('a=a:f')                                                                                    
['E:\\Work\\Scratch\\a b\\a.exe', 'E:\\Work\\Scratch\\a b\\a-3.6.exe']                                 

This creates a.exe, which when run, gives an error as follows:

>& 'E:\Work\Scratch\a b\a.exe'
Fatal error in launcher: Unable to create process using '""e:\work\scratch\a b\scripts\python.exe"  "E:\Work\Scratch\a b\a.exe" '
@vsajip
Copy link
Collaborator Author

vsajip commented Apr 15, 2018

Original changes by Paul Moore (Bitbucket: pmoore, GitHub: pmoore).


changed priority from "major" to "critical"

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 15, 2018

Original comment by Paul Moore (Bitbucket: pmoore, GitHub: pmoore).


Marked as critical, as this may block inclusion of pip 10 in Python 3.7.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 15, 2018

Original comment by Takayuki Shimizukawa (Bitbucket: shimizukawa, GitHub: shimizukawa).


I got a same issue. With distlib-0.2.5, generated exe works well.

  • Win10, Pytho-3.6.2

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 15, 2018

Original comment by Atsushi Odagiri (Bitbucket: aodag, GitHub: aodag).


os windows10 64bit
python 3.5.3 32bit

I removed double quotes from that shebang, and ran that executable.
That looks fine.

  • before #!"d:\aodag\works\python\pip space\venv\scripts\python.exe"
  • after #!d:\aodag\works\python\pip space\venv\scripts\python.exe

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 15, 2018

Original comment by Atsushi Odagiri (Bitbucket: aodag, GitHub: aodag).


https://bitbucket.org/pypa/distlib/annotate/3b7c16f62f93aaf408fb14388c7c29d0cb1da98b/PC/launcher.c?at=default&fileviewer=file-view-default#launcher.c-453

if the line starts with ", line was increased but result was not increased.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 15, 2018

Original comment by Paul Moore (Bitbucket: pmoore, GitHub: pmoore).


Good catch - that looks correct.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 15, 2018

Original comment by Atsushi Odagiri (Bitbucket: aodag, GitHub: aodag).


@pmoore I confirm about cli launcher on my branch https://bitbucket.org/aodag/distlib/commits/990601027056cf5c57282d58c800918f4047a7a5.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 15, 2018

Original comment by Atsushi Odagiri (Bitbucket: aodag, GitHub: aodag).


I created PR at https://bitbucket.org/pypa/distlib/pull-requests/36/fix-for-104/diff.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 15, 2018

I just saw this issue. Will cut a release as soon as I can. I won't actually merge the PR (since the actual sources which build the executable are in a separate upstream project - I'll fix it there) and then fixup distlib with the updated launchers.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 16, 2018

Aaargh. A recent Windows update seems to have borked my Visual Studio installation - it now complains that it can't find .NET Framework v4.0 (no idea why that's needed in a C/C++ project). Working on it...

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 16, 2018

Original comment by Atsushi Odagiri (Bitbucket: aodag, GitHub: aodag).


I used windows sdk for windows server 2008 and .NET Framework 3.5. https://www.microsoft.com/en-us/download/details.aspx?id=11310

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 16, 2018

I used windows sdk for windows server 2008 and .NET Framework 3.5. https://www.microsoft.com/en-us/download/details.aspx?id=11310

Sure. I hadn't consciously changed anything on my machine, but a Windows update seems to have changed something. Anyway, it looks like the problem is only with the IDE - so trying to build with MSBuild on the command line should work.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 16, 2018

I've rebuilt and updated the launchers. Please try the distlib from changeset 7f9d6a9 and report back if replacing the pip-vendored version with it solves the problem. If it does solve the problem, I can cut a release.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 16, 2018

Original comment by Takayuki Shimizukawa (Bitbucket: shimizukawa, GitHub: shimizukawa).


Thanks! It worked on my environment.

  • Win10 1803 Pro 64bit
  • Pytho-3.6.2 (32bit)
  • pip-10.0.0
  • virtualenv under C:\Users\taka\実験 D\virtualenv-pip10
  • replace C:\Users\taka\実験 D\virtualenv-pip10\Lib\site-packages\pip\_vendor\distlib with changeset 7f9d6a9

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 16, 2018

Original comment by Paul Moore (Bitbucket: pmoore, GitHub: pmoore).


Confirmed that my original reproduction script now works. I also tested use from within pip, and that too seems to work now. So I think this is sufficient for a release.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 16, 2018

OK, started on it.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 16, 2018

Should be fixed in f5fc13a.

@vsajip
Copy link
Collaborator Author

vsajip commented Apr 16, 2018

Original changes by Vinay Sajip (Bitbucket: vinay.sajip, GitHub: vsajip).


changed state from "new" to "resolved"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working critical
Projects
None yet
Development

No branches or pull requests

1 participant