From: Kefu Chai Date: Wed, 26 Apr 2017 08:00:11 +0000 (+0800) Subject: mgr: pass python interpreter's path to embedded python X-Git-Tag: v12.0.3~205^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=67072d2261a6da142e0bd3d67058f399c5c480b3;p=ceph.git mgr: pass python interpreter's path to embedded python * 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 --- diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index b536433b1e4c..a3d8bd8ffd52 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -310,4 +310,6 @@ /* Support POWER8 instructions */ #cmakedefine HAVE_POWER8 +#cmakedefine PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@" + #endif /* CONFIG_H */ diff --git a/src/mgr/PyModules.cc b/src/mgr/PyModules.cc index 45078262b650..ba8c9ba76dae 100644 --- a/src/mgr/PyModules.cc +++ b/src/mgr/PyModules.cc @@ -360,7 +360,8 @@ int PyModules::init() global_handle = this; // Set up global python interpreter - Py_Initialize(); + Py_SetProgramName(const_cast(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.