From 2d3f89435b687f1a060ac26b72f7f76de6527c5b Mon Sep 17 00:00:00 2001
From: Markus Frank <markus.frank@cern.ch>
Date: Fri, 4 Dec 2015 08:07:20 +0000
Subject: [PATCH] Remove some of the nightly build warnings

---
 DDG4/include/DDG4Python/DDPython.h   |  2 ++
 DDG4/pyddg4.cpp                      | 18 +++++++-----------
 DDG4/src/python/Geant4PythonCall.cpp |  1 -
 DDG4/tpython/DDPython.cpp            |  5 +++++
 4 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/DDG4/include/DDG4Python/DDPython.h b/DDG4/include/DDG4Python/DDPython.h
index c30a4306b..ad284b5df 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 91cae04f7..670632d91 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 1dc4a5743..380dc6f06 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 1092bace9..80bbac1db 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);
+}
-- 
GitLab