On windows, vex foo python runs system Python
pfmoore opened this issue · comments
>vex foo python -c "import sys; print(sys.executable)"
C:\Apps\Python34\python.exe
I suspect this is because the wrapper vex.exe
runs python.exe
to run the vex code, and then that runs the command python
with an updated PATH
. But Windows always looks in the directory of the executable before searching PATH
, and so find the system python.exe
rather than the one in the virtualenv (see http://msdn.microsoft.com/en-gb/library/windows/desktop/ms682425(v=vs.85).aspx for details).
I don't know of an easy fix for this, other than manually parsing the command line and doing the PATH
search explicitly, instead of letting Windows do it.
The same problem will occur with executables stored alongside the system Python: vex foo pip list
lists what's installed in the system Python, not what's in the virtualenv :-(
Ugh. Forget trying to guess a sophisticated diagnosis. It looks like Windows Popen is simply disregarding the PATH given in env. There's no way I'm going to manually do a PATH search duplicating Windows' own functionality. Anyway, this should be worked around; try the new version on PyPI or origin/master
It's not so much disregarding the PATH
- it's more that Windows has different rules on the search directory which mean that PATH
isn't a sufficient answer there.
The problem seems to be fixed, although I'd like to see some more testing before I'd be willing to rely on it (as it seems to be special-casing the Python executable, which isn't the only thing potentially affected).
Huh? What is the problem?
There is a workaround for Windows PATH brokenness using distutils.spawn.find_executable. https://github.com/sashahart/vex/blob/master/vex/run.py#L74
That workaround ISN'T special-casing the Python executable.
What exactly are you asking for?
Ah, sorry - I misread the change. My mistake. However, as I said, I'd need to do some more testing - distutils.spawn.find_executable
only looks for .exe
files (if I'm reading that code correctly!) so there may be corner cases where you are trying to run a Python script, or a .bat
file or similar. I'm not saying there are, and I'm not asking for anything more, just noting that it's not so much that Windows is "broken" as that the corner cases work differently on Windows and Unix. The "more testing" I mentioned was really more that I would want to try out cases like bat
files at some point. Sorry if what I said read like I was saying there was still a specific issue, or that I wanted you to do something.
By the way, there's a separate issue at https://github.com/sashahart/vex/blob/master/vex/run.py#L47 - this needs to use Scripts
on Windows rather than bin
.