diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-02-12 00:08:17 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2021-02-12 00:10:12 +0300 |
commit | cafd6b519c5f5c4b67d0dfe3d453cd4223b38716 (patch) | |
tree | 718586fcff881f45360155c518a4b92c726c52e5 /source/blender/python/generic/py_capi_utils.c | |
parent | aa43e2ec29a9f73918b12001c6e4f4b4c63fd9c9 (diff) |
PyAPI: Use PyPreConfig & PyConfig for Python initialization
Use Python 3.8's API for setting the initial configuration.
This replaces a mix of our logic and direct calls to the Python API
and has no user visible changes.
Using the Python API makes the logic easier to follow and provides
utilities such as `PyConfig_SetBytesArgv`
that wasn't available in previous releases.
Note that this uses Python's utf8/wchar_t conversions,
which used to cause problems (see T31506).
Since `Py_UTF8Mode` was set, the systems locale isn't used for decoding,
allowing us to use Python's utility functions that call
`Py_DecodeLocale` internally.
Ref D10382
Diffstat (limited to 'source/blender/python/generic/py_capi_utils.c')
-rw-r--r-- | source/blender/python/generic/py_capi_utils.c | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index ec6b8c54ac0..1eb4a51c392 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -879,40 +879,6 @@ void PyC_MainModule_Restore(PyObject *main_mod) Py_XDECREF(main_mod); } -/** \} */ - -/* -------------------------------------------------------------------- */ -/** \name #Py_SetPythonHome Wrapper - * \{ */ - -/** - * - Must be called before #Py_Initialize. - * - Expects output of `BKE_appdir_folder_id(BLENDER_PYTHON, NULL)`. - * - Note that the `PYTHONPATH` environment variable isn't reliable, see T31506. - * Use #Py_SetPythonHome instead. - */ -void PyC_SetHomePath(const char *py_path_bundle) -{ -# ifdef __APPLE__ - /* OSX allow file/directory names to contain : character (represented as / in the Finder) - * but current Python lib (release 3.1.1) doesn't handle these correctly */ - if (strchr(py_path_bundle, ':')) { - fprintf(stderr, - "Warning! Blender application is located in a path containing ':' or '/' chars\n" - "This may make python import function fail\n"); - } -# endif - - /* Set the environment path. */ - wchar_t py_path_bundle_wchar[1024]; - - /* Can't use `mbstowcs` on linux gives bug: T23018. */ - BLI_strncpy_wchar_from_utf8( - py_path_bundle_wchar, py_path_bundle, ARRAY_SIZE(py_path_bundle_wchar)); - - Py_SetPythonHome(py_path_bundle_wchar); -} - bool PyC_IsInterpreterActive(void) { /* instead of PyThreadState_Get, which calls Py_FatalError */ |