[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46766] trunk/blender/source: patch [ #31507] site not automatically imported when using external python package

Campbell Barton ideasman42 at gmail.com
Fri May 18 12:19:49 CEST 2012


Revision: 46766
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46766
Author:   campbellbarton
Date:     2012-05-18 10:19:49 +0000 (Fri, 18 May 2012)
Log Message:
-----------
patch [#31507] site not automatically imported when using external python package

made some modificatons to normal python startup also.

Modified Paths:
--------------
    trunk/blender/source/blender/python/intern/bpy_interface.c
    trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp

Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c	2012-05-18 10:02:14 UTC (rev 46765)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c	2012-05-18 10:19:49 UTC (rev 46766)
@@ -223,6 +223,7 @@
 {
 #ifndef WITH_PYTHON_MODULE
 	PyThreadState *py_tstate = NULL;
+	const char *py_path_bundle = BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL);
 
 	/* not essential but nice to set our name */
 	static wchar_t program_path_wchar[FILE_MAX]; /* python holds a reference */
@@ -233,7 +234,7 @@
 	PyImport_ExtendInittab(bpy_internal_modules);
 
 	/* allow to use our own included python */
-	PyC_SetHomePath(BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL));
+	PyC_SetHomePath(py_path_bundle);
 
 	/* without this the sys.stdout may be set to 'ascii'
 	 * (it is on my system at least), where printing unicode values will raise
@@ -245,8 +246,12 @@
 	/* Python 3.2 now looks for '2.xx/python/include/python3.2d/pyconfig.h' to
 	 * parse from the 'sysconfig' module which is used by 'site',
 	 * so for now disable site. alternatively we could copy the file. */
-	Py_NoSiteFlag = 1;
+	if (py_path_bundle) {
+		Py_NoSiteFlag = 1;
+	}
 
+	Py_FrozenFlag = 1;
+
 	Py_Initialize();
 
 	// PySys_SetArgv(argc, argv); // broken in py3, not a huge deal

Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp	2012-05-18 10:02:14 UTC (rev 46765)
+++ trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp	2012-05-18 10:19:49 UTC (rev 46766)
@@ -1843,19 +1843,24 @@
 	 * somehow it remembers the sys.path - Campbell
 	 */
 	static bool first_time = true;
-	
+	char *py_path_bundle   = BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL);
+
 #if 0 // TODO - py3
 	STR_String pname = progname;
 	Py_SetProgramName(pname.Ptr());
 #endif
-	Py_NoSiteFlag=1;
-	Py_FrozenFlag=1;
 
+	if (py_path_bundle != NULL) {
+		Py_NoSiteFlag = 1;
+	}
+
+	Py_FrozenFlag = 1;
+
 	/* must run before python initializes */
 	PyImport_ExtendInittab(bge_internal_modules);
 
 	/* find local python installation */
-	PyC_SetHomePath(BLI_get_folder(BLENDER_SYSTEM_PYTHON, NULL));
+	PyC_SetHomePath(py_path_bundle);
 
 	Py_Initialize();
 	
@@ -1929,8 +1934,6 @@
 	STR_String pname = progname;
 	Py_SetProgramName(pname.Ptr());
 #endif
-	Py_NoSiteFlag=1;
-	Py_FrozenFlag=1;
 
 #ifdef WITH_AUDASPACE
 	/* accessing a SoundActuator's sound results in a crash if aud is not initialized... */




More information about the Bf-blender-cvs mailing list