:py import sys
:py print sys.executable
C:\Program Files (x86)\Vim\vim74\gvim.exe
Should be:
C:\Python27\python.exe
vim --version: http://pastie.org/8395257
On Oct 11, 2013 9:18 PM, "Stanislav Golovanov" <stgol...@gmail.com> wrote:
>
> Hello. I've stumbled on a problem that sys.executable python command inside Vim returns a Vim path, when it should return a Python path. Simple test case:
>
> :py import sys
> :py print sys.executable
> C:\Program Files (x86)\Vim\vim74\gvim.exe
>
> Should be:
> C:\Python27\python.exe
What makes you think so? File python.exe is not used by vim. You may remove it completely leaving relevant DLL library and vim will continue to work with +python and so will be plugins written in python. Why should output of sys.executable change if you remove irrelevant python.exe?
> vim --version: http://pastie.org/8395257
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Don't forget that ":py print sys.executable" will return the actual path to the Python interpreter (something like /usr/bin/python) on all Unix machines when run from Vim, but will return a path to Vim on Windows.
At the very least, the output of sys.executable in Vim should be consistent across platforms. It should either always return the path to Vim or to Python. I'd go with the path to Python since that's what the Python docs say it should return.
The API of Python system functions shouldn't change just because it's running inside Vim.
On Oct 11, 2013 11:36 PM, "Val Markovic" <v...@markovic.io> wrote:
>
> > What makes you think so? File python.exe is not used by vim. You may remove it completely leaving relevant DLL library and vim will continue to work with +python and so will be plugins written in python. Why should output of sys.executable change if you remove irrelevant python.exe?
>
> Don't forget that ":py print sys.executable" will return the actual path to the Python interpreter (something like /usr/bin/python) on all Unix machines when run from Vim, but will return a path to Vim on Windows.
>
> At the very least, the output of sys.executable in Vim should be consistent across platforms. It should either always return the path to Vim or to Python. I'd go with the path to Python since that's what the Python docs say it should return.
I would go with path to vim since it is the actual user of the python library. But I agree that there should not be such inconsistency. I do not think though that this problem should be directed here and not to Python issue tracker: vim has nothing in if_py* files that may look like a source of this inconsistency. At least, I have never seen something like redefining sys.executable and do not remember any platform-specific code there.
Note: the python.exe itself is just the same user of the shared library as vim is. Since all sys staff can be found in the shared library and not in the library users (except for some explicit replacements like vim having a replacement for sys.stdout) I do not see why one of the users should be preferred over the other.
> The API of Python system functions shouldn't change just because it's running inside Vim.
>