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>2020-10-28 03:52:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-28 03:52:15 +0300
commit9dac5456b9b7315c21b51703c67e317f90dbbe13 (patch)
tree45a51f2ad9703602dc2b468b5bd52008a5dded84 /source/blender/python
parentd28676d89a79e02745ebced89152f25dbfd71285 (diff)
parent04c5471ceefb41c9e49bf7c86f07e9e7b8426bb3 (diff)
Merge branch 'blender-v2.91-release'
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_app.c33
-rw-r--r--source/blender/python/intern/bpy_interface.c20
2 files changed, 20 insertions, 33 deletions
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c
index a580b4f10f0..02ab001dbf6 100644
--- a/source/blender/python/intern/bpy_app.c
+++ b/source/blender/python/intern/bpy_app.c
@@ -295,36 +295,13 @@ static int bpy_app_global_flag_set__only_disable(PyObject *UNUSED(self),
return bpy_app_global_flag_set(NULL, value, closure);
}
-#define BROKEN_BINARY_PATH_PYTHON_HACK
-
PyDoc_STRVAR(bpy_app_binary_path_python_doc,
- "String, the path to the python executable (read-only)");
-static PyObject *bpy_app_binary_path_python_get(PyObject *self, void *UNUSED(closure))
+ "String, the path to the python executable (read-only). "
+ "Deprecated! Use ``sys.executable`` instead.");
+static PyObject *bpy_app_binary_path_python_get(PyObject *UNUSED(self), void *UNUSED(closure))
{
- /* refcount is held in BlenderAppType.tp_dict */
- static PyObject *ret = NULL;
-
- if (ret == NULL) {
- /* only run once */
- char fullpath[1024];
- BKE_appdir_program_python_search(
- fullpath, sizeof(fullpath), PY_MAJOR_VERSION, PY_MINOR_VERSION);
- ret = PyC_UnicodeFromByte(fullpath);
-#ifdef BROKEN_BINARY_PATH_PYTHON_HACK
- Py_INCREF(ret);
- UNUSED_VARS(self);
-#else
- PyDict_SetItem(
- BlenderAppType.tp_dict,
- /* XXX BAAAADDDDDD! self is not a PyDescr at all! it's bpy.app!!! */ PyDescr_NAME(self),
- ret);
-#endif
- }
- else {
- Py_INCREF(ret);
- }
-
- return ret;
+ PyErr_Warn(PyExc_RuntimeWarning, "Use 'sys.executable' instead of 'binary_path_python'!");
+ return Py_INCREF_RET(PySys_GetObject("executable"));
}
PyDoc_STRVAR(bpy_app_debug_value_doc,
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index c4523363a91..894a9a69198 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -306,12 +306,22 @@ 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. */
+ /* Setting the program name is important so the 'multiprocessing' module
+ * can launch new Python instances. */
{
- const char *program_path = BKE_appdir_program_path();
- wchar_t program_path_wchar[FILE_MAX];
- BLI_strncpy_wchar_from_utf8(program_path_wchar, program_path, ARRAY_SIZE(program_path_wchar));
- Py_SetProgramName(program_path_wchar);
+ char program_path[FILE_MAX];
+ if (BKE_appdir_program_python_search(
+ program_path, sizeof(program_path), PY_MAJOR_VERSION, PY_MINOR_VERSION)) {
+ wchar_t program_path_wchar[FILE_MAX];
+ BLI_strncpy_wchar_from_utf8(
+ program_path_wchar, program_path, ARRAY_SIZE(program_path_wchar));
+ Py_SetProgramName(program_path_wchar);
+ }
+ else {
+ fprintf(stderr,
+ "Unable to find the python binary, "
+ "the multiprocessing module may not be functional!\n");
+ }
}
/* must run before python initializes */