[Python-bugs-list] Re: [Bug #127722] getpythonregpath fails
Jack Andrews
effbiae@bigpond.com
Wed, 31 Jan 2001 18:40:40 +1100
I'm embedding Python -- it would be handy if PATH were inspected to find
python.exe and deduce PYTHONHOME.
The doco for the Python/C API says that the PATH environment variable
is examined to locate the python executable, but it appears that in the
Win version of Python2.0, PATH is ignored. Is there a reason why PATH
is
not examined in the Win version?
noreply@sourceforge.net wrote:
>
> Bug #127722, was updated on 2001-Jan-05 21:16
> Here is a current snapshot of the bug.
>
> Project: Python
> Category: Windows
> Status: Closed
> Resolution: Works For Me
> Bug Group: Platform-specific
> Priority: 5
> Submitted by: effbiae
> Assigned to : mhammond
> Summary: getpythonregpath fails
>
> Details: Hi,
>
> I'm on Win95 (regrettably).
>
> I found that while experimenting with embedding Python in C, I initialized
> the interpreter, and got the message:
> 'import site' failed; use -v for traceback
>
> If I putenv("PYTHONHOME=C:\python20"), this disappears. Also, if I put the
> executable in C:\python20, the problem disappears.
>
> Please excuse any stupidity that follows as I am a newby to the windows
> registy.
>
> in the file:
> Pc\getpathp.c
>
> in the function:
> static char *
> getpythonregpath(HKEY keyBase, int skipcore)
>
> in the call:
> rc = RegQueryInfoKey(newKey, NULL, NULL, NULL, &numKeys, NULL, NULL,
> NULL, NULL, &dataSize, NULL, NULL);
>
> numKeys is being set to 0 because in my installation of Python 2.0, the
> registry key:
> HKEY_LOCAL_MACHINE\\Software\\Python\\PythonCore\\PythonPath\
>
> has no subkeys. It has the 'default' (?) value:
>
> C:\Python20\Lib\plat-win;C:\Python20\Lib;C:\Python20\DLLs;C:\Python20\Lib\lib-tk
>
> (I do not have HKEY_CURRENT_USER\\Software\\Python\\PythonCore\\PythonPath
> -- in fact I do not have HKEY_CURRENT_USER\\Software\\Python)
>
> Anyway, it looks like the code assumes 'numKeys > 0', which is not the case
> at my run-time.
>
> It appears that the the registry editing part of the installation program
> may have changed recently, and this file has not been updated accordingly.
>
> Also, the doco for the Python/C API says that the PATH environment variable
> may be examined to locate the python executable, but it appears that in the
> Win version of Python2.0, PATH is ignored. Is there a reason why PATH is
> not examined in the Win version?
>
> Follow-Ups:
>
> Date: 2001-Jan-30 21:01
> By: mhammond
>
> Comment:
> This is "by design" - see my comments at
> https://sourceforge.net/bugs/?func=detailbug&group_id=5470&bug_id=129584
>
> Note that there is no default that uses absolute paths (ie, the "C:\..."
> you referenced). This is the Python code determining its own core, and
> thereby ignoring the registry key for the core (sub-keys are still used)
>
> I believe the code you reference is fine, and working as designed (but that
> may not be how you like <wink>). My testing shows the code working in an
> identical fashion regardless of the number of subkeys.
>
> Also, setting PYTHONHOME is working as designed - this env var tells Python
> to not search for its home, and to not use the registry key, but assume the
> directory specified is valid, and build its core path from that.
>
> Marking as "works for me" and closing.
> -------------------------------------------------------
>
> Date: 2001-Jan-09 17:13
> By: mhammond
>
> Comment:
> Happy to look at this, but it will probably need to wait until I return to
> Oz - early Feb.
> -------------------------------------------------------
>
> Date: 2001-Jan-07 21:37
> By: tim_one
>
> Comment:
> Assigned to MarkH cuz he might actually think he knows what the code is
> doing <wink..
> -------------------------------------------------------
>
> Date: 2001-Jan-07 15:48
> By: fdrake
>
> Comment:
> Assigned to Tim since this is on Windows.
> -------------------------------------------------------
>
> For detailed info, follow this link:
> http://sourceforge.net/bugs/?func=detailbug&bug_id=127722&group_id=5470