]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
mgr: stop using deprecated API to initialize Python
authorKefu Chai <tchaikov@gmail.com>
Sat, 3 Feb 2024 11:22:15 +0000 (19:22 +0800)
committerKefu Chai <tchaikov@gmail.com>
Sat, 22 Jun 2024 01:21:52 +0000 (09:21 +0800)
commit4cf9b36c66fd64f2dc50f4e1acca3fe93e29b3f2
treece9c5270b5df041676098fb669ed75401978e8a7
parent51f71fc17add4a5ed7bc10d35e01fdb90ef11aa0
mgr: stop using deprecated API to initialize Python

Py_SetProgramName() is deprecated since CPython 3.11, see
https://docs.python.org/3/c-api/init_config.html .
`Py_InitializeFromConfig()` and friends were introduced by CPython 3.8,
but we still need to support CPython 3.6 which is shipped by CentOS8.
so we have to be backward compatible with the older Python versions.

so let's use new machinary to initialize the Python interpretor, since
the minimal supported Python version is now CPython 3.9 which comes with
CentOS 9.

this change addresses following compiling warning:

```
[428/753] Building CXX object src/mgr/CMakeFiles/ceph-mgr.dir/PyModuleRegistry.cc.o
/var/ssd/ceph/src/mgr/PyModuleRegistry.cc: In member function ‘void PyModuleRegistry::init()’:
/var/ssd/ceph/src/mgr/PyModuleRegistry.cc:49:20: warning: ‘void Py_SetProgramName(const wchar_t*)’ is deprecated [-Wdeprecated-declarations]
   49 |   Py_SetProgramName(const_cast<wchar_t*>(WCHAR(MGR_PYTHON_EXECUTABLE)));
      |   ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.12/Python.h:94,
                 from /var/ssd/ceph/src/mgr/PyModule.h:22,
                 from /var/ssd/ceph/src/mgr/PyModuleRegistry.h:18,
                 from /var/ssd/ceph/src/mgr/PyModuleRegistry.cc:14:
/usr/include/python3.12/pylifecycle.h:37:38: note: declared here
   37 | Py_DEPRECATED(3.11) PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
      |                                      ^~~~~~~~~~~~~~~~~`
```

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/mgr/PyModuleRegistry.cc