use PyImport_ExtendInittab for py module initialization rather then adding to sys.modules directly, no functional change.
This commit is contained in:
@@ -195,12 +195,7 @@ void BPy_init_modules( void )
|
||||
printf("bpy: couldnt find 'scripts/modules', blender probably wont start.\n");
|
||||
}
|
||||
/* stand alone utility modules not related to blender directly */
|
||||
Mathutils_Init();
|
||||
Noise_Init();
|
||||
BGL_Init();
|
||||
BLF_Init();
|
||||
IDProp_Init_Types();
|
||||
AUD_initPython();
|
||||
IDProp_Init_Types(); /* not actually a submodule, just types */
|
||||
|
||||
mod = PyModule_New("_bpy");
|
||||
|
||||
|
||||
@@ -196,6 +196,22 @@ void BPY_set_context(bContext *C)
|
||||
BPy_SetContext(C);
|
||||
}
|
||||
|
||||
/* init-tab */
|
||||
extern PyObject *BPyInit_noise(void);
|
||||
extern PyObject *BPyInit_mathutils(void);
|
||||
extern PyObject *BPyInit_bgl(void);
|
||||
extern PyObject *BPyInit_blf(void);
|
||||
extern PyObject *AUD_initPython(void);
|
||||
|
||||
static struct _inittab bpy_internal_modules[]= {
|
||||
{"noise", BPyInit_noise},
|
||||
{"mathutils", BPyInit_mathutils},
|
||||
{"bgl", BPyInit_bgl},
|
||||
{"blf", BPyInit_blf},
|
||||
{"aud", AUD_initPython},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
/* call BPY_set_context first */
|
||||
void BPY_start_python( int argc, char **argv )
|
||||
{
|
||||
@@ -206,6 +222,9 @@ void BPY_start_python( int argc, char **argv )
|
||||
utf8towchar(bprogname_wchar, bprogname);
|
||||
Py_SetProgramName(bprogname_wchar);
|
||||
|
||||
/* builtin modules */
|
||||
PyImport_ExtendInittab(bpy_internal_modules);
|
||||
|
||||
BPY_start_python_path(); /* allow to use our own included python */
|
||||
|
||||
Py_Initialize( );
|
||||
|
||||
@@ -313,14 +313,8 @@ static struct PyModuleDef bpy_ops_module = {
|
||||
PyObject *BPY_operator_module(void)
|
||||
{
|
||||
PyObject *submodule;
|
||||
|
||||
submodule= PyModule_Create(&bpy_ops_module);
|
||||
PyDict_SetItemString(PyImport_GetModuleDict(), bpy_ops_module.m_name, submodule);
|
||||
|
||||
/* INCREF since its its assumed that all these functions return the
|
||||
* module with a new ref like PyDict_New, since they are passed to
|
||||
* PyModule_AddObject which steals a ref */
|
||||
Py_INCREF(submodule);
|
||||
submodule= PyModule_Create(&bpy_ops_module);
|
||||
|
||||
return submodule;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user