[Python bindings] Compilation fails with Python 3.11
Installing dune-common
fails when using Python 3.11, seemingly due to issues in the pybind11
code. The error messages I get are very similar to those reported here and fixing it is seemingly related to using a newer version of cython which supports Python 3.11. E.g.,
FAILED: python/dune/typeregistry/CMakeFiles/_typeregistry.dir/_typeregistry.cc.o
/usr/bin/g++-12 -DENABLE_GMP=1 -DENABLE_MPI=1 -DENABLE_QUADMATH=1 -DHAVE_CONFIG_H -D_GLIBCXX_USE_FLOAT128 -D_typeregistry_EXPORTS -I/tmp/pip-install-enwkyj4j/dune-common_30d26d5c16504f4cadc30ff0c9fb6446/_skbuild/linux-x86_64-3.11/cmake-build -I/tmp/pip-install-enwkyj4j/dune-common_30d26d5c16504f4cadc30ff0c9fb6446 -I/home/valentina/mambaforge/envs/richards-swe/include/python3.11 -std=c++17 -O3 -DNDEBUG -O3 -DNDEBUG -fPIC -fext-numeric-literals -MD -MT python/dune/typeregistry/CMakeFiles/_typeregistry.dir/_typeregistry.cc.o -MF python/dune/typeregistry/CMakeFiles/_typeregistry.dir/_typeregistry.cc.o.d -o python/dune/typeregistry/CMakeFiles/_typeregistry.dir/_typeregistry.cc.o -c /tmp/pip-install-enwkyj4j/dune-common_30d26d5c16504f4cadc30ff0c9fb6446/python/dune/typeregistry/_typeregistry.cc
In file included from /tmp/pip-install-enwkyj4j/dune-common_30d26d5c16504f4cadc30ff0c9fb6446/dune/python/pybind11/attr.h:13,
from /tmp/pip-install-enwkyj4j/dune-common_30d26d5c16504f4cadc30ff0c9fb6446/dune/python/pybind11/pybind11.h:45,
from /tmp/pip-install-enwkyj4j/dune-common_30d26d5c16504f4cadc30ff0c9fb6446/dune/python/common/typeregistry.hh:21,
from /tmp/pip-install-enwkyj4j/dune-common_30d26d5c16504f4cadc30ff0c9fb6446/python/dune/typeregistry/_typeregistry.cc:8:
/tmp/pip-install-enwkyj4j/dune-common_30d26d5c16504f4cadc30ff0c9fb6446/dune/python/pybind11/cast.h: In function ‘std::string pybind11::detail::error_string()’:
/tmp/pip-install-enwkyj4j/dune-common_30d26d5c16504f4cadc30ff0c9fb6446/dune/python/pybind11/cast.h:446:36: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
446 | " " + handle(frame->f_code->co_filename).cast<std::string>() +
See the attached file for the full error output: dune_common_output.txt
Note: This issue will most probably apply to dune-grid
, dune-fem
, etc. I have decided to open it here since this seems to be the baseline package for all of the others.
Here is some information about my system:
-
g++-12 --version
: 12.3.0 -
python3 --version
: Python 3.11.4
Full conda environment:
# Name Version Build Channel
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 2_gnu conda-forge
bzip2 1.0.8 h7f98852_4 conda-forge
ca-certificates 2023.7.22 hbcca054_0 conda-forge
ld_impl_linux-64 2.40 h41732ed_0 conda-forge
libexpat 2.5.0 hcb278e6_1 conda-forge
libffi 3.4.2 h7f98852_5 conda-forge
libgcc-ng 13.1.0 he5830b7_0 conda-forge
libgomp 13.1.0 he5830b7_0 conda-forge
libnsl 2.0.0 h7f98852_0 conda-forge
libsqlite 3.42.0 h2797004_0 conda-forge
libuuid 2.38.1 h0b41bf4_0 conda-forge
libzlib 1.2.13 hd590300_5 conda-forge
ncurses 6.4 hcb278e6_0 conda-forge
openssl 3.1.2 hd590300_0 conda-forge
pip 23.2.1 pyhd8ed1ab_0 conda-forge
python 3.11.4 hab00c5b_0_cpython conda-forge
readline 8.2 h8228510_1 conda-forge
setuptools 68.1.2 pyhd8ed1ab_0 conda-forge
tk 8.6.12 h27826a3_0 conda-forge
tzdata 2023c h71feb2d_0 conda-forge
wheel 0.41.2 pyhd8ed1ab_0 conda-forge
xz 5.2.6 h166bdaf_0 conda-forge
Let me know if you need any additional information!
Best,
Valentina