]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: pass python interpreter's path to embedded python
authorKefu Chai <kchai@redhat.com>
Wed, 26 Apr 2017 08:00:11 +0000 (16:00 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 26 Apr 2017 10:08:07 +0000 (18:08 +0800)
* also do prevent python from registering its own signal handler, it does
  not make sense in our embedded use case.
* pass python interpreter's path to embedded python before initializing
  it. python uses this path to look up the "site" modules, etc.

so it can use other interpreter if it is not intalled into $PATH,
otherwise the "python" in $PATH will always be used even the
PYTHON_EXECUTABLE in CMake's cache is pointing to another python
interpreter.

if one want to debug ceph-mgr with a customize build python, this would
be helpful.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/include/config-h.in.cmake
src/mgr/PyModules.cc

index b536433b1e4c7049daf8bf0882c445309828d94b..a3d8bd8ffd52b64e633101b4fa5db7c14a0c18ed 100644 (file)
 /* Support POWER8 instructions */
 #cmakedefine HAVE_POWER8
 
+#cmakedefine PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@"
+
 #endif /* CONFIG_H */
index 45078262b65093e79ce55909954b593d721d25c1..ba8c9ba76dae9d9e171a80e6254ae45dcd96d244 100644 (file)
@@ -360,7 +360,8 @@ int PyModules::init()
   global_handle = this;
 
   // Set up global python interpreter
-  Py_Initialize();
+  Py_SetProgramName(const_cast<char*>(PYTHON_EXECUTABLE));
+  Py_InitializeEx(0);
 
   // Some python modules do not cope with an unpopulated argv, so lets
   // fake one.  This step also picks up site-packages into sys.path.