Message273769
Windows Python determines sys.prefix (i.e. the location of the standard library, <prefix>\lib) via either the PYTHONHOME environment variable or by searching for the landmark "lib/os.py", starting in the application directory and reducing back to the root directory [1].
If it can't find the prefix directory; PYTHONPATH isn't defined; and it can't find PythonPath in the registry; then it adds the "DLLs" and "lib" directories relative to the working directory. This default PYTHONPATH is defined in PC/pyconfig.h as ".\\DLLs;.\\lib".
There is an alternative "applocal" (application local) mode. Create a file named pyvenv.cfg beside python.exe that contains the single line
applocal = true
This prevents Python from checking PYTHONHOME and PYTHONPATH, the registry, and prevents searching for the "lib/os.py" landmark. sys.prefix is set as the application directory, and the default "DLLs" and "lib" paths are expanded relative to the application directory.
Anyway, since what you're reporting is the expected behavior, I'm closing this issue. Feel free to reopen it if you feel I've misdiagnosed the problem or think the default behavior is somehow broken. I don't know what Steve Dower's plans are, if indeed he has any, to change the legacy sys.path behavior in future releases.
[1]: The reduce() function in PC/getpathp.c has a minor bug that
results in sys.prefix set as the drive-relative path "C:" if
the landmark search continues to the root and "C:/lib/os.py"
exists. This is due to the way it overwrites the path separator
with NUL to reduce the path. I think it should keep the
separator. The join() function works either way. |
|
Date |
User |
Action |
Args |
2016-08-27 09:38:05 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, zach.ware, steve.dower, josephsmeng |
2016-08-27 09:38:05 | eryksun | set | messageid: <1472290685.78.0.3828784295.issue27874@psf.upfronthosting.co.za> |
2016-08-27 09:38:05 | eryksun | link | issue27874 messages |
2016-08-27 09:38:05 | eryksun | create | |
|