12#include <cpython/initconfig.h>
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 );
79 PyConfig_Clear( &config );
82 std::string fullversion = Py_GetVersion();
83 std::string version( fullversion, 0, fullversion.find_first_of(
' ' ) );
84 std::string vers( version, 0, version.find_first_of(
'.', version.find_first_of(
'.' ) + 1 ) );
85 info() <<
"Python version: [" << vers <<
"]" <<
endmsg;
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')" );
128 std::stringstream stream;
131 file.seekg( 0, std::ios::end );
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" );
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Implementation of property with value of concrete type.
const ValueType & value() const
bool assign(const Details::PropertyBase &source) override
get the value from another property
The IProperty is the basic interface for all components which have properties that can be set or get.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
This service handles scripting implemented using Python.
std::string m_startupScript
Startup script.
~PythonScriptingSvc() override
Destructor.
StatusCode initialize() override
Initialize the service. [IService::initialize()].
StatusCode finalize() override
Finalize the service. [IService::finalize()].
StatusCode run() override
Run the service by taking full control. [IRunable::run()].
PythonScriptingSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
StatusCode finalize() override
const std::string & name() const override
Retrieve name of the service.
Gaudi::Details::PropertyBase * declareProperty(const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
StatusCode initialize() override
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS