Win64 Vim: sys.path not set correctly
As you may know, Vim has offered an embedded Python for several years. I'm updating the Win64 port of Vim and decided to make the Python interface work too.
I think I've fixed all the tedious Py_ssize_t issues, and the simple sanity test of :py print "hi" works. However, more complex examples fall over with ImportErrors. As far as I can tell, it's related to sys.path, which shows as: ['', 'd:\\Python25\\python25.zip', '.\\DLLs', '.\\lib', '.\\lib\\plat-win', '.\\lib\\lib-tk', 'D:\\vimsrc\\vim7\\src']
When I run python interactively, sys.path looks like: ['', 'd:\\Python25\\python25.zip', 'd:\\Python25\\DLLs', 'd:\\Python25\\lib', 'd:\\Python25\\lib\\plat-win', 'd:\\Python25\\lib\\lib-tk', 'd:\\Python25', 'd:\\Python25\\lib\\site-packages']
If I modify sys.path to use the fully qualified pathnames, things start working. If I build a 32-bit version of Vim, things work out of the box.
I'm loading python25.dll; i.e., Vim was compiled with -DDYNAMIC_PYTHON. The python25.dll was installed by python-2.5.1.amd64.msi.
My patches (and the complete if_python.c) can be found at http://www.georgevreilly.com/vim/vim-win64-20071028.zip
Any ideas?
Thanks.
/George V. Reilly http://www.georgevreilly.com/blog
I think I've fixed all the tedious Py_ssize_t issues, and the simple sanity test of :py print "hi" works. However, more complex examples fall over with ImportErrors. As far as I can tell, it's related to sys.path, which shows as: ['', 'd:\\Python25\\python25.zip', '.\\DLLs', '.\\lib', '.\\lib\\plat-win', '.\\lib\\lib-tk', 'D:\\vimsrc\\vim7\\src']
When I run python interactively, sys.path looks like: ['', 'd:\\Python25\\python25.zip', 'd:\\Python25\\DLLs', 'd:\\Python25\\lib', 'd:\\Python25\\lib\\plat-win', 'd:\\Python25\\lib\\lib-tk', 'd:\\Python25', 'd:\\Python25\\lib\\site-packages']
If I modify sys.path to use the fully qualified pathnames, things start working. If I build a 32-bit version of Vim, things work out of the box.
I'm loading python25.dll; i.e., Vim was compiled with -DDYNAMIC_PYTHON. The python25.dll was installed by python-2.5.1.amd64.msi.
This will be related to the registry entries being written into the 32bit part of the registry rather than the 64bit version. As a result, whenever Python is embedded in another application and needs to use the registry to locate its installation path, it fails, and uses the fallback relative values of ".\DLLs", ".\lib" etc. On the other hand, when Python is started normally, it can locate its library automatically, so the correct entries are used.
If you search the python-dev archives, you will see a discussion on this issue, and also a new copy of the installer put together by Martin V Loewis to test the fix for this issue. It is expected that the fix will also appear in Python 2.5.2.
Hope this helps,
Mark
On 10/29/07, Mark Hammond <mhammond@skippinet.com.au> wrote:
This will be related to the registry entries being written into the 32bit part of the registry rather than the 64bit version. As a result, whenever Python is embedded in another application and needs to use the registry to locate its installation path, it fails, and uses the fallback relative values of ".\DLLs", ".\lib" etc. On the other hand, when Python is started normally, it can locate its library automatically, so the correct entries are used.
If you search the python-dev archives, you will see a discussion on this issue, and also a new copy of the installer put together by Martin V Loewis to test the fix for this issue. It is expected that the fix will also appear in Python 2.5.2.
Hope this helps,
Thanks, Mark.
The mail thread at http://mail.python.org/pipermail/python-dev/2007-July/073900.html describes the problem and points to a fixed installer. In short, the official Python 2.5.1 amd64 installer sets the 'reflected' registry keys at HKLM\Software\Wow6432node\Python, instead of HKLM\Software\Python.
I installed Martin v. Löwis's private build and that fixed my problems.
/George V. Reilly http://www.georgevreilly.com/blog
participants (2)
-
George V. Reilly
-
Mark Hammond