-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mgr: add site package paths in PyModuleRegistry
before this change, we add the paths of site packages to sys.path when starting subinterpretors for each of the mgr modules. this works just fine. but in Python 3.11, it deprecates `PySys_SetPath()` in favor of PyConfig machinary, which sets the module search paths in PyConfig, before calling `Py_InitializeFromConfig()`. so, to set the module search paths with the new machinary, we need to do this in `PyModuleRegistry`, where we initialize the global Python interpretor using the new PyConfig machinary. and since we've switched to the new PyConfig machinary when compiling with Python 3.8 and up. in this change, to unify the implementation of pre and post Python 3.8, we set the module search paths in PyModuleRegistry. because PyConfig imports the site packages by default, and we are allowed to append a new path to the existing search paths, we just append the configured `mgr_module_path` when compiling with Python 3.8 and up. and when it comes to lower versions of Python, the existing behavior is preserved. this change should silence the compiling warning like: ``` /var/ssd/ceph/src/mgr/PyModule.cc:368:20: warning: ‘void PySys_SetPath(const wchar_t*)’ is deprecated [-Wdeprecated-declarations] 368 | PySys_SetPath(const_cast<wchar_t*>(sys_path.c_str())); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/python3.12/sysmodule.h:15:38: note: declared here 15 | Py_DEPRECATED(3.11) PyAPI_FUNC(void) PySys_SetPath(const wchar_t *); | ^~~~~~~~~~~~~ ``` Signed-off-by: Kefu Chai <[email protected]>
- Loading branch information
Showing
4 changed files
with
87 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters