Embedding pure python statically -- possibly a newbie question

G

Geoff Wedig

I have inherited a project with an embedded python interpretter, and
don't know much about it, but have been given the task of porting it to
a new compiler/OS and have run into some problems.

I seem to have got the embedded interpretter part of it working, and
have worked out how to add c modules to extend it. My problem is
embedding pure python code so that I don't have to have external .py
files to my application.

What I mean is, if I have a module, foo.py, I'd like to somehow have its
code as part of my application executable, so when the application does,
for example,

PyImport_ImportModule("foo");

it won't look for a foo.py, but use the internal static version. The C
style modules do this, so I imagine it can be done with pure python as
well, but I've not figured out *how*. I can a C wrapper to do this
(embedding python in C in python in....), but I figure there has to be
another way.

I've been going over the docs, and haven't gotten very far, so it's
possible this is answered there. If so, just give me a nudge/push/shove
in the right direction.

Thanks for any help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top