From: Kefu Chai Date: Tue, 30 Mar 2021 18:32:38 +0000 (+0800) Subject: mgr/PyModule: put mgr_module_path before Py_GetPath() X-Git-Tag: v15.2.13~13^2~17^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=450c0efa866d287a6f5509397ad5bd5798a5a6fc;p=ceph.git mgr/PyModule: put mgr_module_path before Py_GetPath() 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 (cherry picked from commit 8638f526a9d04c3dfd758073980d709165070336) Conflicts: src/mgr/PyModule.cc: trivial resolution --- diff --git a/src/mgr/PyModule.cc b/src/mgr/PyModule.cc index 6ebf2b9ad2b..14c721c3a39 100644 --- a/src/mgr/PyModule.cc +++ b/src/mgr/PyModule.cc @@ -341,10 +341,10 @@ int PyModule::load(PyThreadState *pMainThreadState) PySys_SetArgv(1, (char**)argv); #endif // Configure sys.path to include mgr_module_path - string paths = (":" + g_conf().get_val("mgr_module_path") + - ":" + get_site_packages()); + string paths = (g_conf().get_val("mgr_module_path") + ':' + + get_site_packages() + ':'); #if PY_MAJOR_VERSION >= 3 - wstring sys_path(Py_GetPath() + wstring(begin(paths), end(paths))); + wstring sys_path(wstring(begin(paths), end(paths)) + Py_GetPath()); PySys_SetPath(const_cast(sys_path.c_str())); dout(10) << "Computed sys.path '" << string(begin(sys_path), end(sys_path)) << "'" << dendl;