embedded python in dll with C

M

Mick Duprez

Hi All,
I can't quite get my head around embedding Python in a C app and I
have a few questions if I may, here is the background.
I want to create a dll plugin that has the Python interpreter embedded
in it for use in scripting an established application. So far I have
created the interface dll and py module using swig. So far so good,
now some questions -

1) Would it be best to combine my swig generated .c file into the same
dll as my plugin dll or leave it seperate, in other words should I
just embed the interpreter into the C 'plugin' dll and create the
interface module and dll seperately to import into python scripts?

2) Once I have done this would it be appropriate just to use something
like this in my C code -

PyRun_SimpleString("import my_plugin_script");
PyRun_SimpleString("init_func_from_script()");

where 'init_func_from_script' establishes callbacks for C to use from
the script using the new interface module/dll? The C application has
it's own functions for registering callbacks by passing in a list of
the functions, I'm hoping this will work.

I'll give it a go in the mean time, just looking for the right/better
way to do this, thanks.
 

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,999
Messages
2,570,243
Members
46,836
Latest member
login dogas

Latest Threads

Top