From: Jon Christopher <jon.christopher@gm...> - 2008-04-25 23:04:23
I have a C++ application which has an embedded python interpreter,
and I'm using swig to allow python to allow access some of the C++ classes.
Since I'm using an embedded interpreter, I don't need the .so files,
as the wrapped
classes are linked in to the executable.
However, I don't want to have to rely on the swig-generated .py files
either, as I'd like to just ship a single executable and not a bunch
of auxiliary files.
I'd like to compile the text of the .py files into my program and pass
it to the embeded
interpreter at initialization time so that instead of doing an
"import" statement, I'd just
pass the string to the interpreter.
I'm familiar with python's "freeze" capability for doing something
similar, but there has
to be an easier way.
As an example, the simple example code at:
and discussed at:
uses swig to wrap its MapMgr and C_Actor classes into a python module
named (confusingly enough) swig.
However, the generated executable relies on the "swig.py" file being
present at run-time.
How can I compile in the "swig.py" file?