diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-10-29 03:29:13 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-10-29 03:29:13 +0300 |
commit | 83f369a0b917fbf4e554d65c1d28eaa67f5a96de (patch) | |
tree | bdc33d505ed2b18c4c5078ed5d24e1150721492b /source/blender/python | |
parent | cac8a7cddb56a654145ed1c9db2add8abff12704 (diff) | |
parent | 52b38d9c3d84485385d5bc2e58f16c5acfaca9b7 (diff) |
Merge branch 'blender-v2.91-release'
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_interface.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index e3afe49b22f..bff8f0582c4 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -306,7 +306,11 @@ void BPY_python_start(bContext *C, int argc, const char **argv) PyThreadState *py_tstate = NULL; const char *py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, NULL); - /* Not essential but nice to set our name. */ + /* Needed for Python's initialization for portable Python installations. + * We could use #Py_SetPath, but this overrides Python's internal logic + * for calculating it's own module search paths. + * + * `sys.executable` is overwritten after initialization to the Python binary. */ { const char *program_path = BKE_appdir_program_path(); wchar_t program_path_wchar[FILE_MAX]; @@ -353,6 +357,23 @@ void BPY_python_start(bContext *C, int argc, const char **argv) Py_DECREF(py_argv); } + /* Setting the program name is important so the 'multiprocessing' module + * can launch new Python instances. */ + { + char program_path[FILE_MAX]; + if (BKE_appdir_program_python_search( + program_path, sizeof(program_path), PY_MAJOR_VERSION, PY_MINOR_VERSION)) { + PyObject *py_program_path = PyC_UnicodeFromByte(program_path); + PySys_SetObject("executable", py_program_path); + Py_DECREF(py_program_path); + } + else { + fprintf(stderr, + "Unable to find the python binary, " + "the multiprocessing module may not be functional!\n"); + } + } + # ifdef WITH_FLUID /* Required to prevent assertion error, see: * https://stackoverflow.com/questions/27844676 */ |