Can somebody kill getpathp for me?

Tim Peters tim.one at comcast.net
Fri Mar 1 01:23:59 EST 2002


[Chris Gonnerman]
> In the PC subdir of the Python-2.1.2 build directory is a module
> called getpathp.c, which sets up the initial sys.path value.  It
> is well known by Python programmers on Windows that the sys.path
> initialization includes directories plucked from special registry
> keys... unless you are using the PythonWare version.

Or the PythonLabs distribution:  while the core installer does set up a
registry entry containing "the usual" Python path, it *normally* never uses
it.  Read the long comment block at the start of getpathp.c, and this time
believe that it means what it says <wink>.  Note that the core installer
never sets up what the comment block calls "'application paths' - that is,
sub-keys under the main PythonPath registry key".  If there aren't any
application paths, then, as the rest of the comment block says, the main
PythonPath key is ignored, unless a "Python Home" isn't given by a
PYTHONHOME envar and can't be guessed from the python.exe path.

> I thought, great, I can use this (the PythonWare version) to create
> Python runnables on CD-ROM; but now I discover a fly in the ointment.
> If the computer already has an installed Python interpreter, the
> paths set in the registry are added, and BEFORE the paths from the
> PythonWare PYROOT variable are added.

AFAIK PythonWare doesn't ship with a custom getpathp.c, and neither does
ActiveState, so AFAIK the comment block applies to all Python installations.
The "PythonWare PYROOT variable" is news to me, google hasn't heard of it
either, and I find no mention of PYROOT in my PythonWare PY21 installation.
Setting a PYROOT envar has no visible effect on sys.path when I run under
PY21 either.  That's a long-winded way of saying I think you must be
confused <wink>.

Have you tried setting PYTHONHOME?  If, e.g., I set PYTHONHOME to \Python22,
then execute python while *in* my \Python21 directory (these both referring
to PythonLabs distros), then Python 2.1.2 comes up with sys.path pointing
entirely at Python 2.2 directories.  This is insane, but shows that
PYTHONHOME works the way getpathp.c says it works.

> Gah.
>
> What I want is a version of either python.exe or python21.dll
> (whichever contains the offending getpathp.c module) with the
> registry-probing code disabled.

If that's what you really want, you'll have to edit getpathp.c and compile
your own Python.

> Ideally it should still apply the paths from PYROOT (basically in this
> case it must).

Python doesn't look at any such envar on any platform.  Maybe that's why
setting PYROOT isn't doing you any good <wink>.  Try PYTHONHOME.





More information about the Python-list mailing list