[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54353] trunk/blender/source/blender/ python: fix for building blender as a python module,

Campbell Barton ideasman42 at gmail.com
Wed Feb 6 14:14:11 CET 2013


Revision: 54353
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54353
Author:   campbellbarton
Date:     2013-02-06 13:14:11 +0000 (Wed, 06 Feb 2013)
Log Message:
-----------
fix for building blender as a python module,
changes to internal import behavior of py3.3 broke it.

Modified Paths:
--------------
    trunk/blender/source/blender/python/generic/idprop_py_api.c
    trunk/blender/source/blender/python/intern/bpy_interface.c

Modified: trunk/blender/source/blender/python/generic/idprop_py_api.c
===================================================================
--- trunk/blender/source/blender/python/generic/idprop_py_api.c	2013-02-06 13:07:45 UTC (rev 54352)
+++ trunk/blender/source/blender/python/generic/idprop_py_api.c	2013-02-06 13:14:11 UTC (rev 54353)
@@ -1454,6 +1454,8 @@
 
 	submodule = PyModule_Create(&IDProp_types_module_def);
 
+	IDProp_Init_Types();
+
 #define MODULE_TYPE_ADD(s, t) \
 	PyModule_AddObject(s, t.tp_name, (PyObject *)&t); Py_INCREF((PyObject *)&t)
 

Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c	2013-02-06 13:07:45 UTC (rev 54352)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c	2013-02-06 13:14:11 UTC (rev 54353)
@@ -310,11 +310,33 @@
 	(void)argv;
 
 	/* must run before python initializes */
-	PyImport_ExtendInittab(bpy_internal_modules);
+	/* broken in py3.3, load explicitly below */
+	// PyImport_ExtendInittab(bpy_internal_modules);
 #endif
 
 	bpy_intern_string_init();
 
+
+#ifdef WITH_PYTHON_MODULE
+	{
+		/* Manually load all modules */
+		struct _inittab *inittab_item;
+		PyObject *sys_modules = PyImport_GetModuleDict();
+
+		for (inittab_item = bpy_internal_modules; inittab_item->name; inittab_item++) {
+			PyObject *mod = inittab_item->initfunc();
+			if (mod) {
+				PyDict_SetItemString(sys_modules, inittab_item->name, mod);
+			}
+			else {
+				PyErr_Print();
+				PyErr_Clear();
+			}
+			// Py_DECREF(mod); /* ideally would decref, but in this case we never wan't to free */
+		}
+	}
+#endif
+
 	/* bpy.* and lets us import it */
 	BPy_init_modules();
 




More information about the Bf-blender-cvs mailing list