Questions on embedding Python
kenneth.m.mcdonald at sbcglobal.net
Tue Nov 22 22:13:43 CET 2005
We're looking at embedding Python into our product to provide users
with the ability to write scripts for the programming. My knowledge
of Python is excellent, I'm familiar with the concepts of converting
back and forth between C and Python datatypes, but my knowledge of
compiling and linking is almost nonexistent. So if I could get advice
on the following, it would be most appreciated. The program currently
runs on Mac and Windows.
1) When Python is embedded, is it typically compiled statically into
the program, or provided as a dynamic library?
2) If provided as a dynamic library, does/should Python be recompiled
into a tweaked dynamic library, or do we just use the python
executable 'straight up', so to speak.
3) We would of course want to make sure that 'our' Python (so to
speak) would have access only to 'our' library of Python code (which
would include most of the standard Python libraries), so that it
can't be confused by the presence of some other version of Python on
the system. Is this normally done by compiling in the Python search
path, making it relative to the main application?
4) I've never done this myself, but I understand that Python can
import code from zip files in much the same way that Java can import
from jar files. Is it possible to lump all of the python code we
provide for use with the embedded Python into one big zip file, or
would that cause problems such as slow loading when a module is
imported? This would be nice because the fewer files we distribute,
More information about the Python-list