Lisandro Dalcin wrote:
> AFAIK, using '.pyd' (or '.so' in POSIX) ext modules inside a zip file
> requires some special support from setuptools...
probably -- I was referring to a pure python option.
>> I may be misunderstanding what the OP wants, but you CAN create single .pyd
>> (or .so, or whatever) compiled extension that is a package, with multiple
>> modules in it.
>
> Yes, but this is not "standard" practice...
I know I saw it somewhere before I did it, but I don't think it's common.
> OK. I'm definitely interested in seeing your example... Could you post a link?
It's not on the web anywhere, but I've enclosed the C file. It includes
other files, one for each module, and builds a package with those modules.
This is the key code for the package init, creating a package called
"PACKAGE", and putting module called "module1" in it:
void initPACKAGE(void)
{
PyObject* module;
PyObject* package = Py_InitModule("PACKAGE", noMethods);
if(!package) return;
/* add package attributes, if any */
/*PyModule_AddStringConstant(package, "foo", "bar");*/
/* add a module
module = PyImport_AddModule("PACKAGE.module1");
if(!module) return;
if(PyModule_AddObject(package, "module1", module))
return;
Py_INCREF(module);
initmodule1();
}
>> I also don't know how important it is, but I found it made things easy for
>> compiling and distribution (this was before setuptools, however).
>>
>
> I still fail to see the convenience... Could you elaborate a bit more?
Not really -- it seemed like a good idea at the time, but it's been five
or size years, and i dont' remember teh motivation. I think I found it
easier to distribute a single *.so and *.dll, but with a properly built
setup.y, I'm not sure why I thought it was hard? py2exe may have been a
small motivator -- it has to put dlls alingside, so it was nice to only
have one, but these days I usually use pyexe in the mode where it
doesn't bundle up all the python code anyway.
HTH,