CubbyFlow / CubbyFlow

Voxel-based fluid simulation engine for computer games
https://cubbyflow.github.io/CubbyFlow/
MIT License
272 stars 33 forks source link

Build error in submodule **pybind v2.4.3** with **python 3.9 or higher** #95

Open Snowapril opened 3 years ago

Snowapril commented 3 years ago

Describe the bug I tried to build cubbyflow main branch in the manjaro linux and get a build error like below.

[ 72%] Building CXX object Sources/API/Python/CMakeFiles/pyCubbyFlow.dir/Animation/Animation.cpp.o
In file included from /home/snowapril/바탕화면/Graphics/cubbyflow/Libraries/pybind11/include/pybind11/cast.h:16,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Libraries/pybind11/include/pybind11/attr.h:13,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Libraries/pybind11/include/pybind11/pybind11.h:44,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Includes/API/Python/Animation/Animation.hpp:14,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Sources/API/Python/Animation/Animation.cpp:11:
/home/snowapril/바탕화면/Graphics/cubbyflow/Libraries/pybind11/include/pybind11/detail/internals.h: In function ‘pybind11::detail::internals& pybind11::detail::get_internals()’:
/home/snowapril/바탕화면/Graphics/cubbyflow/Libraries/pybind11/include/pybind11/detail/internals.h:263:28: error: ‘void PyEval_InitThreads()’ is deprecated [-Werror=deprecated-declarations]
  263 |         PyEval_InitThreads();
      |                            ^
In file included from /usr/include/python3.9/Python.h:145,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Libraries/pybind11/include/pybind11/detail/common.h:112,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Libraries/pybind11/include/pybind11/pytypes.h:12,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Libraries/pybind11/include/pybind11/cast.h:13,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Libraries/pybind11/include/pybind11/attr.h:13,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Libraries/pybind11/include/pybind11/pybind11.h:44,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Includes/API/Python/Animation/Animation.hpp:14,
                 from /home/snowapril/바탕화면/Graphics/cubbyflow/Sources/API/Python/Animation/Animation.cpp:11:
/usr/include/python3.9/ceval.h:130:37: note: declared here
  130 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
      |                                     ^~~~~~~~~~~~~~~~~~
/home/snowapril/바탕화면/Graphics/cubbyflow/Sources/API/Python/Animation/Animation.cpp: At top level:
cc1plus: note: unrecognized command-line option ‘-Wno-range-loop-analysis’ may have been intended to silence earlier diagnostics
cc1plus: all warnings being treated as errors
make[2]: *** [Sources/API/Python/CMakeFiles/pyCubbyFlow.dir/build.make:82: Sources/API/Python/CMakeFiles/pyCubbyFlow.dir/Animation/Animation.cpp.o] 오류 1
make[1]: *** [CMakeFiles/Makefile2:1326: Sources/API/Python/CMakeFiles/pyCubbyFlow.dir/all] 오류 2
make: *** [Makefile:149: all] 오류 2

As error message said, PyEval_InitThreads function was deprecated since python version 3.9.

To Reproduce Steps to reproduce the behavior:

  1. Build project with cmake default settings and python 3.9 or higher
  2. Get a build error in the pybind v2.4.3

Desktop (please complete the following information):

Additional context Latest pybind is modified for handling that issue. Here is before & after code of the pybind internal.h.

Before

#if defined(WITH_THREAD)
        PyEval_InitThreads();
        PyThreadState *tstate = PyThreadState_Get();

After

#if defined(WITH_THREAD)
        #if PY_VERSION_HEX < 0x03090000
                PyEval_InitThreads();
        #endif
utilForever commented 3 years ago

Thanks for report! I'll update pybind11 library. 🛩️