diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-10-28 03:31:51 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-10-28 03:49:29 +0300 |
commit | 04c5471ceefb41c9e49bf7c86f07e9e7b8426bb3 (patch) | |
tree | 17302a73e2d0aa0399506cc9d41aaa567c68c5a7 /source/blender/python/intern/bpy_app.c | |
parent | bee5921e82eb32dfc2c64aa063f991bc36faa5c7 (diff) |
PyAPI: point sys.executable to the Python binary
`sys.executable` is documented to be a Python interpreter or None.
This was set to Blender's executable which caused the multiprocessing
module to spawn new instances of Blender instead of Python on WIN32.
See issue described in D7815.
Deprecate 'bpy.app.binary_path_python' & warn when using.
Blender's executable remains accessible via `bpy.app.binary_path`.
Diffstat (limited to 'source/blender/python/intern/bpy_app.c')
-rw-r--r-- | source/blender/python/intern/bpy_app.c | 33 |
1 files changed, 5 insertions, 28 deletions
diff --git a/source/blender/python/intern/bpy_app.c b/source/blender/python/intern/bpy_app.c index 554ab2645a7..8354e220b09 100644 --- a/source/blender/python/intern/bpy_app.c +++ b/source/blender/python/intern/bpy_app.c @@ -292,36 +292,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, |