From b0f19ea7ca5ff420a44a618a1917d7bf728115b7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 3 Jul 2009 04:38:55 +0000 Subject: 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. --- source/blender/python/intern/bpy_interface.c | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source/blender') 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 ); -- cgit v1.2.3