[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21334] branches/blender2.5/blender/source /blender/python/intern/bpy_interface.c: set the PYTHONPATH to BLI_gethome_folder("python") if it exists.
Campbell Barton
ideasman42 at gmail.com
Fri Jul 3 06:38:59 CEST 2009
Revision: 21334
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21334
Author: campbellbarton
Date: 2009-07-03 06:38:55 +0200 (Fri, 03 Jul 2009)
Log Message:
-----------
set the PYTHONPATH to BLI_gethome_folder("python") if it exists.
This lets us distribute blender with our own python module directory (next to ui and io), and avoids the need for a shell script to start blender.
Modified Paths:
--------------
branches/blender2.5/blender/source/blender/python/intern/bpy_interface.c
Modified: branches/blender2.5/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- branches/blender2.5/blender/source/blender/python/intern/bpy_interface.c 2009-07-03 04:24:19 UTC (rev 21333)
+++ branches/blender2.5/blender/source/blender/python/intern/bpy_interface.c 2009-07-03 04:38:55 UTC (rev 21334)
@@ -147,10 +147,43 @@
}
#endif
+
+/* must be called before Py_Initialize */
+void BPY_start_python_path(void)
+{
+ char *py_path_bundle= BLI_gethome_folder("python");
+
+ if(py_path_bundle==NULL)
+ return;
+
+ /* set the environment path */
+ printf("found bundled python: %s\n", py_path_bundle);
+
+#if (defined(WIN32) || defined(WIN64))
+#if defined(FREE_WINDOWS)
+ sprintf(py_path, "PYTHONPATH=%s", py_path_bundle)
+ putenv(py_path);
+#else
+ _putenv_s("PYTHONPATH", py_path_bundle);
+#endif
+#else
+#ifdef __sgi
+ sprintf(py_path, "PYTHONPATH=%s", py_path_bundle)
+ putenv(py_path);
+#else
+ setenv("PYTHONPATH", py_path_bundle, 1); /* initializing the video driver can cause crashes on some systems - Campbell */
+#endif
+#endif
+
+}
+
+
void BPY_start_python( int argc, char **argv )
{
PyThreadState *py_tstate = NULL;
+ BPY_start_python_path(); /* allow to use our own included python */
+
Py_Initialize( );
//PySys_SetArgv( argc_copy, argv_copy );
More information about the Bf-blender-cvs
mailing list