Message164691
| 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 |
<1341514421.21.0.770989866581.issue15020@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
> 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))
break;
...
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. |
|