[Bf-blender-cvs] [95425bc] master: BGE: python API initialization cleanup

Ines Almeida noreply at git.blender.org
Tue Feb 3 16:49:07 CET 2015


Commit: 95425bc97a9d07bbb5e2396d12ffdbf3d9400d04
Author: Ines Almeida
Date:   Wed Jun 4 09:17:52 2014 +0100
Branches: master
https://developer.blender.org/rB95425bc97a9d07bbb5e2396d12ffdbf3d9400d04

BGE: python API initialization cleanup

-Removing unused parameters
-Updating some parts to match bpy_interface.c initialization

Cherry-picking 14fceb6 onto 117edbb
Conflicts:
	source/gameengine/Ketsji/KX_PythonInit.cpp

===================================================================

M	source/gameengine/Ketsji/KX_PythonInit.cpp
M	source/gameengine/Ketsji/KX_PythonInit.h

===================================================================

diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 348b84e..7819eb7 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -2082,7 +2082,7 @@ static struct _inittab bge_internal_modules[] = {
  * Python is not initialized.
  * see bpy_interface.c's BPY_python_start() which shares the same functionality in blender.
  */
-PyObject *initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie, int argc, char** argv)
+PyObject *initGamePlayerPythonScripting(Main *maggie, int argc, char** argv)
 {
 	/* Yet another gotcha in the py api
 	 * Cant run PySys_SetArgv more than once because this adds the
@@ -2093,14 +2093,20 @@ PyObject *initGamePlayerPythonScripting(const STR_String& progname, TPythonSecur
 	static bool first_time = true;
 	const char * const py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, NULL);
 
-#if 0 // TODO - py3
-	STR_String pname = progname;
-	Py_SetProgramName(pname.Ptr());
-#endif
+	/* not essential but nice to set our name */
+	static wchar_t program_path_wchar[FILE_MAX]; /* python holds a reference */
+	BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t));
+	Py_SetProgramName(program_path_wchar);
 
+	/* Update, Py3.3 resolves attempting to parse non-existing header */
+	#if 0
+	/* 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. */
 	if (py_path_bundle != NULL) {
 		Py_NoSiteFlag = 1;
 	}
+	#endif
 
 	Py_FrozenFlag = 1;
 
@@ -2186,12 +2192,12 @@ void exitGamePlayerPythonScripting()
 /**
  * Python is already initialized.
  */
-PyObject *initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level, Main *maggie)
+PyObject *initGamePythonScripting(Main *maggie)
 {
-#if 0 // XXX TODO Py3
-	STR_String pname = progname;
-	Py_SetProgramName(pname.Ptr());
-#endif
+	/* not essential but nice to set our name */
+	static wchar_t program_path_wchar[FILE_MAX]; /* python holds a reference */
+	BLI_strncpy_wchar_from_utf8(program_path_wchar, BLI_program_path(), sizeof(program_path_wchar) / sizeof(wchar_t));
+	Py_SetProgramName(program_path_wchar);
 
 #ifdef WITH_AUDASPACE
 	/* accessing a SoundActuator's sound results in a crash if aud is not initialized... */
@@ -2241,9 +2247,9 @@ void setupGamePython(KX_KetsjiEngine* ketsjiengine, KX_Scene *startscene, Main *
 	PyObject *dictionaryobject;
 
 	if (argv) /* player only */
-		dictionaryobject= initGamePlayerPythonScripting("Ketsji", psl_Lowest, blenderdata, argc, argv);
+		dictionaryobject= initGamePlayerPythonScripting(blenderdata, argc, argv);
 	else
-		dictionaryobject= initGamePythonScripting("Ketsji", psl_Lowest, blenderdata);
+		dictionaryobject= initGamePythonScripting(blenderdata);
 
 	ketsjiengine->SetPyNamespace(dictionaryobject);
 	initRasterizer(ketsjiengine->GetRasterizer(), ketsjiengine->GetCanvas());
@@ -2297,8 +2303,6 @@ PyObject *initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
 {
 	gp_Canvas = canvas;
 	gp_Rasterizer = rasty;
-
-
 	PyObject *m;
 	PyObject *d;
 
diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h
index 719a74e..e9c94a0 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.h
+++ b/source/gameengine/Ketsji/KX_PythonInit.h
@@ -47,10 +47,9 @@ extern bool gUseVisibilityTemp;
 PyObject *initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene *ketsjiscene);
 PyObject *initGameKeys();
 PyObject *initRasterizer(class RAS_IRasterizer *rasty,class RAS_ICanvas *canvas);
-PyObject *initGamePlayerPythonScripting(const STR_String &progname, TPythonSecurityLevel level,
-                                        struct Main *maggie, int argc, char **argv);
-PyObject *initVideoTexture(void); 
-PyObject *initGamePythonScripting(const STR_String &progname, TPythonSecurityLevel level, struct Main *maggie);
+PyObject *initVideoTexture(void);
+PyObject *initGamePlayerPythonScripting(struct Main *maggie, int argc, char **argv);
+PyObject *initGamePythonScripting(struct Main *maggie);
 
 void exitGamePlayerPythonScripting();
 void exitGamePythonScripting();




More information about the Bf-blender-cvs mailing list