exporting multiple modules from one dll?

Farshid Lashkari lashkariNO at SPAMworldviz.com
Thu Jan 26 13:16:27 EST 2006


> I have a dll that contains all kinds of services (input, audio, video, 
> etc..), and I would like to export these to Python as separate modules. 
> Now, if I call Py_InitModule with a name that's different than the dll 
> name, I get an error. So what can I do?


I believe you can export different modules from one dll, but you *MUST* 
at least export a module that has the same name as the dll. If the name 
of your dll is mymodule.dll then your init function should look like the 
following:

void initmymodule()
{
     Py_InitModule("mymodule", mymoduleMethods);
     Py_InitModule("audio", audioMethods);
     Py_InitModule("video", videoMethods);
     Py_InitModule("input", inputMethods);
}

At the python level you would have to do the following:

import mymodule #Must be import before audio,video, and input
import audio
import video
import input

I've never actually tried this, but I don't see why it wouldn't work. 
Let me know how it goes.

-Farshid



More information about the Python-list mailing list