You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.9 KiB

diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx
index 05a03fe72c4d..44fc885a3dc0 100644
--- a/pyuno/source/loader/pyuno_loader.cxx
+++ b/pyuno/source/loader/pyuno_loader.cxx
@@ -105,7 +105,7 @@ static PyRef getObjectFromLoaderModule( const char * func )
return object;
}
-static void setPythonHome ( const OUString & pythonHome )
+static void setPythonHome ( const OUString & pythonHome, PyConfig * config )
{
OUString systemPythonHome;
osl_getSystemPathFromFileURL( pythonHome.pData, &(systemPythonHome.pData) );
@@ -129,9 +129,7 @@ static void setPythonHome ( const OUString & pythonHome )
PyErr_SetString(PyExc_SystemError, "python home path is too long");
return;
}
-SAL_WNODEPRECATED_DECLARATIONS_PUSH
- Py_SetPythonHome(wide); // deprecated since python 3.11
-SAL_WNODEPRECATED_DECLARATIONS_POP
+ config->home = wide;
}
static void prependPythonPath( std::u16string_view pythonPathBootstrap )
@@ -183,11 +181,13 @@ void pythonInit() {
if ( Py_IsInitialized()) // may be inited by getComponentContext() already
return;
+ PyConfig config;
OUString pythonPath;
OUString pythonHome;
OUString path( "$BRAND_BASE_DIR/" LIBO_ETC_FOLDER "/" SAL_CONFIGFILE("pythonloader.uno" ));
rtl::Bootstrap::expandMacros(path); //TODO: detect failure
rtl::Bootstrap bootstrap(path);
+ PyConfig_InitPythonConfig( &config );
// look for pythonhome
bootstrap.getFrom( "PYUNO_LOADER_PYTHONHOME", pythonHome );
@@ -196,7 +196,7 @@ void pythonInit() {
// pythonhome+pythonpath must be set before Py_Initialize(), otherwise there appear warning on the console
// sadly, there is no api for setting the pythonpath, we have to use the environment variable
if( !pythonHome.isEmpty() )
- setPythonHome( pythonHome );
+ setPythonHome( pythonHome, &config );
if( !pythonPath.isEmpty() )
prependPythonPath( pythonPath );