Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-07-03 08:38:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-07-03 08:38:55 +0400
commitb0f19ea7ca5ff420a44a618a1917d7bf728115b7 (patch)
tree68d49dd987595827ef0af52d9615062dc1ecc0f3 /source/blender/python/intern/bpy_interface.c
parentfb5f9273eba4b30e1aa0573388367592b18bdbba (diff)
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.
Diffstat (limited to 'source/blender/python/intern/bpy_interface.c')
-rw-r--r--source/blender/python/intern/bpy_interface.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 1d18fe36ad9..2b1b72d0307 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -147,10 +147,43 @@ wchar_t* Py_GetPath(void)
}
#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 );