[Python-bugs-list] [ python-Bugs-422686 ] sys.path initialization in embedded Pyth
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 30 Aug 2001 13:35:41 -0700
Bugs item #422686, was opened at 2001-05-09 09:14
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=422686&group_id=5470
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Frederic Giacometti (giacometti)
>Assigned to: Tim Peters (tim_one)
Summary: sys.path initialization in embedded Pyth
Initial Comment:
Context:
======
Python 2.1 final release, working with build from source (c:\program files\python does not exist),
and PYTHONHOME is set to point to the root source directory (c:\local\src\Python-2.1).
Problem shows up on Windows (other platforms?)
Problem:
======
The directory of the executable (which is not python.exe) shows up in second position in sys.path.
Ex:
==
When the process executable (__argv value) is c:\jdk1.3.0_02\bin\java.exe, I get:
sys.path = ['c:\local\src\jpe', 'c:\local\src\python-2.1\dlls', 'c:\local\src\python-2.1\lib',
'c:\local\src\python-2.1\lib\plat-win', 'c:\local\src\python-2.1\lib\lib-tk',
'c:\jdk1.3.0_02\bin', 'c:\local\src\python-2.1']
Note:
===
If PYTHONHOME is not set in the environment, I get a 'site module not found' message upon Python
initialization, and then a corrupted import behavior, with corrupted values in sys.modules.
Maybe the Python VM should exit right away when the site module cannot be imported, instead of
going on and working with a corrupted sys.modules list.
I did not have this problem on Python 1.5.2.
I looked at the sys.path initialization C code (getpath() function, windows-specific code...); the
code seems quite complex, and I could not trace easily where the executable's directory was
picked up.
By default of finding the source of the problem, an external fix could be a rule of the kind: Do not
add the executable directory to sys.path when the executable basename not in (python,
python.exe).
Frederic Giacometti
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=422686&group_id=5470