embedding python without dynamically lodaed code in <prefix>

Jeff Collins jcollins at endeavors.com
Fri Apr 13 10:04:51 EDT 2001


Here are a couple of things to try:
     1.  Set the Py_NoSiteFlag = 1, a global declared in pythonrun.c
     2.  Also in pythonrun.c, search for PySys_SetPath(Py_GetPath());
	 Since you aren't importing Python modules, you can comment
	 the line out.

You might be able to accomplish the equivalent of 2. through the
freeze mechanism by freezing os.py, the landmark module.  You'll have
to manually set the global PyImport_FrozenModules with the result
generated from freeze.  See Tools/freeze.  Python/frozen.c is an
example of the type of output to expect.

I haven't tested either of these suggestions, and there are likely
better solutions.


On Thu, Apr 12, 2001 at 09:35:59PM -0700, Samuel D. Gendler wrote:
> I am using libpython.a (2.0, if you must know) in order to gain access
> to all of the nifty Python data structures.  Currently, we use ONLY the
> C api.  The application gets distributed to several thousand servers
> around the planet, none of which have any version of python installed,
> let alone 2.0, and we really have no interest in doing a python install
> to several thousand servers.  
> 
> When I call PyInitialize() on a machine that does not have python2.0
> installed, it complains like so:
> 
> 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
> 
> I don't really care that the import fails (assuming that the
> PyInitialize still succeeds. I haven't checked the source yet), but it
> would be really nice to be able to supress these error messages,
> especially if they are having a negative impact on PyInitialize.
> 
> Any suggestions would be much appreciated.  Please respond to my email
> as well as any public forum that this might arrive at.
> 
> --sam

-- 
Jeffery D. Collins, Ph.D.
Sr. Software Developer
Endeavors Technology, Inc.
http://www.endeavors.com




More information about the Python-list mailing list