diff --git a/DDG4/include/DDG4Python/DDPython.h b/DDG4/include/DDG4Python/DDPython.h index c30a4306be6c2a82893b394c98515b71357ba1df..ad284b5dfd957578c623f48cdb374475e8358f42 100644 --- a/DDG4/include/DDG4Python/DDPython.h +++ b/DDG4/include/DDG4Python/DDPython.h @@ -65,6 +65,8 @@ namespace DD4hep { static void releaseObject(PyObject*& obj); /// Release python object static void assignObject(PyObject*& obj, PyObject* new_obj); + /// Start the interpreter in normal mode without hacks like 'pythopn.exe' does. + static int run_interpreter(int argc, char** argv); /// Copy constructor DDPython(const DDPython& ) {} diff --git a/DDG4/pyddg4.cpp b/DDG4/pyddg4.cpp index 91cae04f7ffa7d1bfc9cf07a961864da165cb315..670632d91cdeef5f721c5732a0874b879ea7f8e2 100644 --- a/DDG4/pyddg4.cpp +++ b/DDG4/pyddg4.cpp @@ -14,13 +14,9 @@ #include "TSystem.h" #include "TInterpreter.h" #include "DDG4Python/DDPython.h" -#include "Python.h" -#include <string> #include <vector> -using namespace std; -using namespace DD4hep; -static int load_libs(const vector<char*>& libs) { +static int load_libs(const std::vector<char*>& libs) { for(size_t i=0; i<libs.size(); ++i) { int ret = gSystem->Load(libs[i]); if ( 0 != ret ) { @@ -37,8 +33,8 @@ static int load_libs(const vector<char*>& libs) { int main(int argc, char** argv) { bool have_prompt = false; bool do_execute = false; - vector<char*> args; - vector<char*> libs; + std::vector<char*> args; + std::vector<char*> libs; int first_arg = 1; int ret; @@ -60,9 +56,9 @@ int main(int argc, char** argv) { if ( !have_prompt && args.size()>0 ) { libs.push_back((char*)"libDDG4Python"); if ( 0 == (ret=load_libs(libs)) ) { - DDPython::instance().setArgs(args.size(), &args[0]); - DDPython::instance().setMainThread(); - DDPython::instance().runFile(args[0]); + DD4hep::DDPython::instance().setArgs(args.size(), &args[0]); + DD4hep::DDPython::instance().setMainThread(); + DD4hep::DDPython::instance().runFile(args[0]); if ( do_execute ) return gInterpreter->ProcessLine("PyDDG4::execute()"); else @@ -72,7 +68,7 @@ int main(int argc, char** argv) { } if ( 0 == (ret=load_libs(libs)) ) { ::printf("+++ Calling now Py_Main...\n"); - ret = ::Py_Main(args.size(), &args[0]); + ret = DD4hep::DDPython::run_interpreter(args.size(), &args[0]); //::printf("+++ Return code Py_Main=%d\n",ret); } return ret; diff --git a/DDG4/src/python/Geant4PythonCall.cpp b/DDG4/src/python/Geant4PythonCall.cpp index 1dc4a5743461c0ba9baac0738b0208322ee9465c..380dc6f06ac47419d42ff6ce7e448e310439acc7 100644 --- a/DDG4/src/python/Geant4PythonCall.cpp +++ b/DDG4/src/python/Geant4PythonCall.cpp @@ -20,7 +20,6 @@ // C/C++ include files #include <stdexcept> -#include "Python.h" using namespace std; using namespace DD4hep; diff --git a/DDG4/tpython/DDPython.cpp b/DDG4/tpython/DDPython.cpp index 1092bace993783e2e4c7b857e009527e30d915b4..80bbac1db491ce3dcd328de08ca59414f331dc8a 100644 --- a/DDG4/tpython/DDPython.cpp +++ b/DDG4/tpython/DDPython.cpp @@ -298,3 +298,8 @@ void DDPython::setMainThread() { bool DDPython::isMainThread() { return _mainThread == pthread_self(); } + +/// Start the interpreter in normal mode without hacks like 'pythopn.exe' does. +int DDPython::run_interpreter(int argc, char** argv) { + return ::Py_Main(argc, argv); +}