ZeroCM / zcm

Zero Communications and Marshalling
http://zerocm.github.io/zcm/
GNU Lesser General Public License v2.1
233 stars 67 forks source link

PyEval_InitThreads is deprecated #393

Closed danielcjacobs closed 1 year ago

danielcjacobs commented 2 years ago

As of Python 3.9, PyEval_InitThreads is deprecated.

Thus, when building via:

./waf configure --use-python
./waf build

The following warning is printed:

[34/46] Compiling config/zcm.pc.in
In file included from zcm/python/zerocm.c:682:
../zcm/python/zcm-python.h: In function ‘PyEval_InitThreads_CUSTOM’:
../zcm/python/zcm-python.h:7:5: error: ‘PyEval_InitThreads’ is deprecated [-Werror=deprecated-declarations]
    7 |     PyEval_InitThreads();
      |     ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.10/Python.h:130,
                 from zcm/python/zerocm.c:6:
/usr/include/python3.10/ceval.h:122:37: note: declared here
  122 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
      |                                     ^~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

This warning can be ignored by removing the Werror flag from here, but a more permanent solution would be to remove this function and just use PyInitialize() as described in the [cython docs](https://cpython-ericholscher.readthedocs.io/en/sphinx-hoverxref/whatsnew/3.9.html#:~:text=The%20PyEval_InitThreads()%20and%20PyEval_ThreadsInitialized,Stinner%20in%20bpo%2D39877.)

jbendes commented 2 years ago

This should be as easy as modifying this file for recent python versions: zcm/python/zcm-python.h

jbendes commented 2 years ago

Pullreq to do this. Completely untested so I wont merge without confirmation it works. Don't have time to confirm right now. https://github.com/ZeroCM/zcm/pull/394