|
From: Christopher B. <Chr...@no...> - 2008-01-29 17:44:29
|
William S Fulton wrote:
> I've got a similar problem. I have a few hundred .i files and each one
> corresponds to a separate invocation of swig and each has a unique module name.
> I'd like to put all the modules in one package as suggested here.
This is certainly possible, though I'm not sure how to do it with SWIG.
I did this in the past with a hand-written extension package though.
Here's the relevant code:
TAP_ext is the name of the package, and I'm putting a few modules in it.
Each of those modules has their own initModuleName function.
From this, maybe you can figure out how to get SWIG to do it.
void initTAP_ext(void)
{
PyObject* module;
PyObject* package = Py_InitModule("TAP_ext", noMethods);
if(!package) return;
/* add package attributes, if any */
/*PyModule_AddStringConstant(package, "foo", "bar");*/
module = PyImport_AddModule("TAP_ext.check_receptors");
if(!module) return;
if(PyModule_AddObject(package, "check_receptors", module))
return;
Py_INCREF(module);
initcheck_receptors();
module = PyImport_AddModule("TAP_ext.CalcPolygons");
if(!module) return;
if(PyModule_AddObject(package, "CalcPolygons", module))
return;
Py_INCREF(module);
initCalcPolygons();
module = PyImport_AddModule("TAP_ext.NumericExtras");
if(!module) return;
if(PyModule_AddObject(package, "NumericExtras", module))
return;
Py_INCREF(module);
initNumericExtras();
}
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
|