Embedded Python Requirements
Eric Shorkey
eshorkey at rightbracket.com
Wed Mar 20 23:38:41 EST 2002
I think I found it.
The first three lines are generated within getpath.c. Specifically, they
show up when a directory named lib-dynload isn't found within the module
path. On a normal install it is /usr/lib/python2.2/lib-dynload. It
doesn't care if the directory is empty, just as long as it exists. I'm
going to be changing getpath.c anyhow, so this won't impact my needs at
all, but I thought I would share.
The last error "'import site' failed; use -v for traceback" shows up
when site.py fails to be properly imported. Either the file wasn't in
the module path, or there was an error in the file.
Both of these were corrected by setting the environment variale
PYTHONPATH to a directory that contained an empty site.py and an empty
lib-dynload directory.
I'll probably end up looking for the default inclusion of the 'site'
module. It's somewhere in the source, so grep and I will eventually find it.
Still, I'd like to know what the site module is supposed to provide. It
appears to do nothing but add to the search path and include a site
customization module if it exists. Really, this appears to have no real
use in an embedded environment. Truly embedding python would mean that a
local python install would not be a requirement. All extension modules
would be contained in directory separate from the usual python install
base. Most likely it would be a subdirectory of the application python
was embedded into.
I'd be really nice to get a ./configure option to kill the auto include
of the site module. Also, some functions for overiding the usual
getpath.c activities would be nice as well. Perhaps allowing the
embedding application to specify the search paths for modules before
initializing the interpreter.
Cheers,
Eric
Eric Shorkey wrote:
> I'm having a little trouble making a self reliant embedded build of
> python.
> I've looked at Demos/embed/demo.c, and I understand it just fine, but
> the python interpretter is generating errors on startup.
>
> Could not find platform independent libraries <prefix>
> Could not find platform dependent libraries <exec_prefix>
> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
> 'import site' failed; use -v for traceback
>
> This occurs seemingly regardless of how I build libpython2.2.a.
> From searching previous posts, I'm able to remove the first three
> lines by simply setting PYTHONHOME in the environment. It doesn't
> matter whether the path is valid or not. Alternatively I could
> redefine my own Py_GetPath() Py_GetPrefix() Py_GetExecPrefix() and
> Py_GetProgramFullPath(). I probably will do just that. So these are
> not really the problem.
>
> It's the last error that really has me baffled. I understand that the
> site module is always imported when the interpreter starts, but I
> really need to build my app completely self sufficient. So the site
> module will either have to be statically included, or it's necessity
> will have to be removed.
>
> Is it possible to statically link in the site module? And what exactly
> does the site module provide that is so important that it is included
> by default? I'd like to know, because I may be able to simply do away
> with it.
>
> Thanks!
>
More information about the Python-list
mailing list