[Python-Dev] Embedded python module search path
Jack.Jansen at cwi.nl
Sat Aug 16 01:25:42 EDT 2003
On vrijdag, aug 15, 2003, at 18:37 Europe/Amsterdam, Tom Emerson wrote:
> I have a question for those of you who have embedded Python into a
> large application concerning how you handle the module search path and
> related functions.
> 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?
There is a hack you can use nowadays, but a hack it truly is: fiddle
_environ before calling Py_Initialize().
- Jack Jansen <Jack.Jansen at oratrix.com>
- If I can't dance I don't want to be part of your revolution -- Emma
More information about the Python-Dev