Embedding Python: How To Hardwire Module Search Path
Gordon McMillan
gmcm at hypernet.com
Fri Apr 7 14:05:44 EDT 2000
Robert Kiendl wrote:
>
> I've embedded python into a C++ - windows app by a
> PyImport_AppendInittab() + Py_Initialize() method.
>
> Py_Initialize() calculates a module search path from the
> windows-registry settings.
>
> I want to prevent Python from doing that and want to hardwire the search
> path to a app. relative path ("<app>/pythonmod") which points to a
> minimal python bunch to avoid the need for installing python.
>
> Does anybody know what to do prior to Py_Initialize(). Or am I
> completely wrong?
> PySys_SetPath() crashes when called before Py_Initialize().
I suggest you just rewrite getpath.c to do what you want. It
runs during Py_Initialize. Otherwise, you can undo what
getpath.c does after Py_Initialize, but there's a hole there.
- Gordon
More information about the Python-list
mailing list