diff --git a/GaudiPython/src/Services/PythonScriptingSvc.cpp b/GaudiPython/src/Services/PythonScriptingSvc.cpp index a97357976c0266b1a3385485319d59d1974cf024..504e84b2763237427595489f905630aeda55bf13 100644 --- a/GaudiPython/src/Services/PythonScriptingSvc.cpp +++ b/GaudiPython/src/Services/PythonScriptingSvc.cpp @@ -9,17 +9,7 @@ * or submit itself to any jurisdiction. * \***********************************************************************************/ #include "Python.h" - -// Python 3 compatibility -#if PY_MAJOR_VERSION >= 3 - -# define PySys_SetArgv_Char_t wchar_t - -#else - -# define PySys_SetArgv_Char_t char - -#endif +#include <cpython/initconfig.h> // Include Files #include "GaudiKernel/ISvcLocator.h" @@ -75,17 +65,19 @@ StatusCode PythonScriptingSvc::initialize() } } - // Python 3 compatibility -#if PY_MAJOR_VERSION >= 3 wchar_t* progName[] = { const_cast<wchar_t*>( L"GaudiPython" ) }; -#else - char* progName[] = { const_cast<char*>( "GaudiPython" ) }; -#endif - // Initialize the Python interpreter. Required. - Py_Initialize(); + PyStatus status; + + PyConfig config; + PyConfig_InitPythonConfig( &config ); + + status = PyConfig_SetString( &config, &config.program_name, progName[0] ); // Set argv for Tkinter (needs program name) - PySys_SetArgv( 1, progName ); + status = PyConfig_SetArgv( &config, 1, progName ); + status = Py_InitializeFromConfig( &config ); + PyConfig_Clear( &config ); + // Get the Python version std::string fullversion = Py_GetVersion(); std::string version( fullversion, 0, fullversion.find_first_of( ' ' ) );