[Python-Dev] Embedded python module search path

Tom Emerson tree at basistech.com
Fri Aug 15 13:37:21 EDT 2003

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?

I appreciate the insight.


Tom Emerson                                          Basis Technology Corp.
Software Architect                                 http://www.basistech.com
  "Beware the lollipop of mediocrity: lick it once and you suck forever"

More information about the Python-Dev mailing list