Cleanup: use logging for "Found bundled Python" message

This was added when Python was initially bundled so any problems
finding Python could be investigated.

Move this to use logging so we can show this information when needed.
This commit is contained in:
Campbell Barton 2020-11-02 19:33:32 +11:00
parent 27acf8ced8
commit d49c71e96e
3 changed files with 23 additions and 26 deletions

@ -893,18 +893,6 @@ void PyC_MainModule_Restore(PyObject *main_mod)
*/
void PyC_SetHomePath(const char *py_path_bundle)
{
if (py_path_bundle == NULL) {
/* Common enough to have bundled *nix python but complain on OSX/Win */
# if defined(__APPLE__) || defined(_WIN32)
fprintf(stderr,
"Warning! bundled python not found and is expected on this platform. "
"(if you built with CMake: 'install' target may have not been built)\n");
# endif
return;
}
/* set the environment path */
printf("found bundled python: %s\n", 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 */
@ -915,19 +903,14 @@ void PyC_SetHomePath(const char *py_path_bundle)
}
# endif
{
/* Set the environment path. */
wchar_t py_path_bundle_wchar[1024];
/* Can't use this, on linux gives bug: T23018,
* TODO: try LANG="en_US.UTF-8" /usr/bin/blender, suggested 2008 */
/* mbstowcs(py_path_bundle_wchar, py_path_bundle, FILE_MAXDIR); */
/* 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);
// printf("found python (wchar_t) '%ls'\n", py_path_bundle_wchar);
}
}
bool PyC_IsInterpreterActive(void)

@ -35,6 +35,7 @@ void BPY_atexit_unregister(void);
extern struct CLG_LogRef *BPY_LOG_CONTEXT;
extern struct CLG_LogRef *BPY_LOG_RNA;
extern struct CLG_LogRef *BPY_LOG_INTERFACE;
#ifdef __cplusplus
}

@ -80,6 +80,7 @@
/* Logging types to use anywhere in the Python modules. */
CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_CONTEXT, "bpy.context");
CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_INTERFACE, "bpy.interface");
CLG_LOGREF_DECLARE_GLOBAL(BPY_LOG_RNA, "bpy.rna");
/* for internal use, when starting and ending python scripts */
@ -304,7 +305,6 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
{
#ifndef WITH_PYTHON_MODULE
PyThreadState *py_tstate = NULL;
const char *py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, NULL);
/* Needed for Python's initialization for portable Python installations.
* We could use #Py_SetPath, but this overrides Python's internal logic
@ -321,8 +321,21 @@ void BPY_python_start(bContext *C, int argc, const char **argv)
/* must run before python initializes */
PyImport_ExtendInittab(bpy_internal_modules);
/* allow to use our own included python */
/* Allow to use our own included Python. `py_path_bundle` may be NULL. */
{
const char *py_path_bundle = BKE_appdir_folder_id(BLENDER_SYSTEM_PYTHON, NULL);
if (py_path_bundle != NULL) {
PyC_SetHomePath(py_path_bundle);
}
else {
/* Common enough to use the system Python on Linux/Unix, warn on other systems. */
# if defined(__APPLE__) || defined(_WIN32)
fprintf(stderr,
"Bundled Python not found and is expected on this platform "
"(the 'install' target may have not been built)\n");
# endif
}
}
/* Without this the `sys.stdout` may be set to 'ascii'
* (it is on my system at least), where printing unicode values will raise