12 #include <cpython/initconfig.h>
25 #if defined( __linux )
38 declareProperty(
"StartupScript", m_startupScript =
"" );
60 tmp.
assign( prpMgr->getProperty(
"JobOptionsType" ) );
61 if ( tmp.
value() ==
"NONE" ) {
62 tmp.
assign( prpMgr->getProperty(
"JobOptionsPath" ) );
68 wchar_t* progName[] = {
const_cast<wchar_t*
>(
L"GaudiPython" ) };
73 PyConfig_InitPythonConfig( &
config );
75 status = PyConfig_SetString( &
config, &
config.program_name, progName[0] );
77 status = PyConfig_SetArgv( &
config, 1, progName );
78 status = Py_InitializeFromConfig( &
config );
82 std::string fullversion = Py_GetVersion();
83 std::string
version( fullversion, 0, fullversion.find_first_of(
' ' ) );
85 info() <<
"Python version: [" << vers <<
"]" <<
endmsg;
87 #if defined( __linux )
91 std::string libname =
"libpython" + vers +
".so";
92 dlopen( libname.c_str(), RTLD_GLOBAL | RTLD_LAZY );
96 PyRun_SimpleString(
"from gaudimodule import *" );
97 PyRun_SimpleString(
"g = AppMgr()" );
99 PyRun_SimpleString(
"theApp = g" );
100 PyRun_SimpleString(
"def Service(n): return g.service(n)" );
101 PyRun_SimpleString(
"def Algorithm(n): return g.algorithm(n)" );
102 PyRun_SimpleString(
"def Property(n): return g.service(n)" );
104 PyRun_SimpleString(
"import rlcompleter" );
105 PyRun_SimpleString(
"rlcompleter.readline.parse_and_bind('tab: complete')" );
132 buffer.reserve( file.tellg() );
133 file.seekg( 0, std::ios::beg );
134 buffer.assign( ( std::istreambuf_iterator<char>{ file } ), std::istreambuf_iterator<char>{} );
136 PyRun_SimpleString( buffer.c_str() );
141 PyRun_InteractiveLoop( stdin,
"\0" );