Mark Hammond wrote:
On Windows, the directory is the directory of sys.executable.
Any chance this can be in sys.prefix, else the directory of sys.executable if sys.prefix is empty?
The reason is for embedding situations - sys.executable may not be a reasonable watermark. We recently had a bug regarding os.popen() on Windows for the exact same reason, and a patch was recently checked in that goes to great lengths to ensure sys.prefix is always valid even in these embedding situations.
Hmmm...., you are right. Sys.executable doesn't really work for embedding.
But sys.prefix is obtained from a search of the directory structure for a "landmark" file, namely os.py. When the Python library is in a zip file, it is likely that no landmark files will be found, and sys.prefix will contain garbage.
Since sys.prefix is searched for, its name is unpredictable. We need a known location for python22.zip.
How about using the full path name of pythonXX.dll with the last three characters changed to "zip"? This associates the libraries with the DLL, which is more logical than associating them with the executable. And the file name is identical but with "zip" instead of "dll".
Does this work, and solve all embedding problems?