]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/PyModule: put mgr_module_path before Py_GetPath()
authorKefu Chai <kchai@redhat.com>
Tue, 30 Mar 2021 18:32:38 +0000 (02:32 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 30 Mar 2021 18:47:39 +0000 (02:47 +0800)
pip comes with _vendor/progress. so there is chance to import the vendored
version of "progress" module instead of the "progress" mgr module, and
fail to import the latter.

in this change, the order of paths are rearranged so the configured
`mgr_module_path` is put before the return value of `Py_GetPath()`.

Fixes: https://tracker.ceph.com/issues/50058
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/PyModule.cc

index 8756b77907eca372dfdc3c846285f2b4516fd769..28c76fe7edcdb881f08883aba65f1dd697f29b2e 100644 (file)
@@ -322,9 +322,9 @@ int PyModule::load(PyThreadState *pMainThreadState)
       const wchar_t *argv[] = {L"ceph-mgr"};
       PySys_SetArgv(1, (wchar_t**)argv);
       // Configure sys.path to include mgr_module_path
-      string paths = (":" + g_conf().get_val<std::string>("mgr_module_path") +
-                     ":" + get_site_packages());
-      wstring sys_path(Py_GetPath() + wstring(begin(paths), end(paths)));
+      string paths = (g_conf().get_val<std::string>("mgr_module_path") + ':' +
+                      get_site_packages() + ':');
+      wstring sys_path(wstring(begin(paths), end(paths)) + Py_GetPath());
       PySys_SetPath(const_cast<wchar_t*>(sys_path.c_str()));
       dout(10) << "Computed sys.path '"
               << string(begin(sys_path), end(sys_path)) << "'" << dendl;