This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Joshua.Cogliati
Recipients Arfrever, Joshua.Cogliati, benjamin.peterson, eric.araujo, georg.brandl, loewis, pitrou
Date 2012-07-05.18:53:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> Joshua, if you are embedding Python, why don't you simply call Py_SetPath to set the search path appropriately? Or is it not enough? (I've lost memory of the mazy details of how we calculate paths :-S).

Setting Py_SetPath manually would basically require me to replicate the work done in Modules/getpath.c to figure out where the python libraries are.  I already set PYTHONPATH to get it to find my own modules.  (Note that there is a big difference between setting PYTHONPATH the environmental variable and calling Py_SetPath, Py_SetPath assumes that you are setting the python library module paths as well.)

The basic problem is that in function calculate_path (inside of Modules/getpath.c ) it has the following code:

char *_path = getenv("PATH");
wchar_t *prog = Py_GetProgramName();
 while (1) {
            joinpath(progpath, prog);
            if (isxfile(progpath))

which goes through the path and tries to find an executable with the same name as returned by Py_GetProgramName()

So if I do a """Py_SetProgramName(L"python3");""" that method works because prog="python3" but if I don't then the method fails because prog="python".  

Basically, to fix this bug, somehow, "wchar_t *prog =" in calculate_path needs to get the actual python executable for this version of python.
Date User Action Args
2012-07-05 18:53:41Joshua.Cogliatisetrecipients: + Joshua.Cogliati, loewis, georg.brandl, pitrou, benjamin.peterson, eric.araujo, Arfrever
2012-07-05 18:53:41Joshua.Cogliatisetmessageid: <>
2012-07-05 18:53:40Joshua.Cogliatilinkissue15020 messages
2012-07-05 18:53:40Joshua.Cogliaticreate