[Python-Dev] Embedded python module search path

Thomas Heller theller at python.net
Mon Aug 18 19:35:36 EDT 2003


Jack Jansen <Jack.Jansen at cwi.nl> writes:

> On vrijdag, aug 15, 2003, at 18:37 Europe/Amsterdam, Tom Emerson wrote:
>
>> Currently the module search path (and the related directory names set
>> as a side effect) is determined by looking at the environment that the
>> executable calling Py_Initialize() is running in. Hence if I've
>> embedded Python 2.3 and also have Python 2.3 installed in (say
>> /usr/local) it is going to use the Python paths in /usr/local/ over
>> those in my customized embedded version.
>>
>> As far as I can tell, the only way I can control this behavior is to
>> rewrite Py_GetPath and friends in my custom build.
>>
>> In my case the user of my application has a configuration file which
>> specifies the pathnames for platform (in-)dependent files, both Python
>> and other. But I cannot pass this information on to Py_Initialize()
>> and on into Py_GetPath.
>>
>> Is it worth providing an alternative initialization API that allows
>> these values to be specified explicitly instead of having them
>> computed? Or is there a reason not to do this?
>
> +1.
>

Wouldn't a Py_SetPath function do the trick, which would initially set
module_search_path (if it's not already set)?

Thomas




More information about the Python-Dev mailing list