multiple modules from single c extension

E

Eric Frederich

I have an extension to some C library that I created using the guide
found here...

http://docs.python.org/extending/extending.html

I am starting to have A LOT of functions being wrapped.

The library that I'm creating bindings for is organized into modules.
In fact, all of their function calls start with a prefix like
ABC_do_something, XYZ_something_else.

I'd like to start putting the bindings for each module into a separate
C file and have each set of bindings end up in its own Python module
as well.

Is this possible to do using a single .dll / .pyd file so that I can
use a single Visual Studio project for these bindings?

Is it just a matter of initializing more than one module in the
initspam function?

PyMODINIT_FUNC
initspam(void)
{
(void) Py_InitModule("spam", SpamMethods);
// can I do this?
(void) Py_InitModule("spam.ABC", SpamABCMethods);
}

Would this even work?
How would I get a hold of SpamABCMethods now that its in a different file?
I tried creating a .h file for the ABC functions which had the
prototypes defined as well as the static PyMethodDef SpamABCMethods[]
array.
This way I could include SpamABC.h which had the array.
When I try doing that though, I get link errors saying things like
functions are declared but not defined.
The example online has everything in a single C file.
If I split things up into a .h and a .c file... what should be
declared as staic?, should anything be declared as extern?
This is where I'm stuck.

Thanks,
~Eric
 

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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top