MPI-IS / mesh

MPI-IS Mesh Processing Library
Other
670 stars 154 forks source link

mesh/src/aabb_normals.cpp doesn't compile with python 3.10 (or 3.9) but does work with python 3.8 #104

Open cga-cmu opened 4 months ago

cga-cmu commented 4 months ago
Error message during compilation (see gcc command line below) mesh/src/aabb_normals.cpp: In function ‘PyObject aabbtree_normals_nearest(PyObject, PyObject)’: mesh/src/aabb_normals.cpp:118:37: error: cannot convert ‘PyObject’ {aka ‘_object’} to ‘const PyArrayObject’ {aka ‘const tagPyArrayObject_fields*’} 118 npy_intp* v_dims = PyArray_DIMS(py_v); ^~~~
                                                                           PyObject* {aka _object*}

Versions (gcc and python, turns out python version matters during this compilation) gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 python 3.10.12

gcc -pthread -B /home/cga/anaconda3/envs/mesh/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /home/cga/anaconda3/envs/mesh/include -fPIC -O2 -isystem /home/cga/anaconda3/envs/mesh/include -fPIC -DNDEBUG=1 -DCGAL_NDEBUG=1 -DMESH_CGAL_AVOID_COMPILED_VERSION=1 -DCGAL_HAS_NO_THREADS=1 -DCGAL_NO_AUTOLINK_CGAL=1 -Imesh/src -I/tmp/pip-build-env-gglkafvb/normal/lib/python3.10/site-packages/numpy/_core/include -I/home/cga/tools/misc/mesh/build/temp.linux-x86_64-cpython-310/CGAL-4.7/include -I/home/cga/anaconda3/envs/mesh/include/python3.10 -c mesh/src/aabb_normals.cpp -o build/temp.linux-x86_64-cpython-310/mesh/src/aabb_normals.o -O3 -fopenmp

The same problem occurs in spatialsearchmodule.cpp, py_visibility.cpp, and py_loadobj.cpp

I tried casting all the calls that caused this error (PyArray_DIMS and PyArray_DATA), for example: npy_intp v_dims = PyArray_DIMS(py_v); -> npy_intp v_dims = PyArray_DIMS((const PyArrayObject*) py_v);

and closest_point=reinterpret_cast<array<double,3>>(PyArray_DATA(result2)); -> closest_point=reinterpret_cast<array<double,3>>(PyArray_DATA((const PyArrayObject*) result2));

Which allowed the gcc compile to complete successfully, but then I got this error when I tried to use mesh:

File "/home/cga/tools/vision/hands/mano-cga/webuser/hello_world/MANO___render.py", line 55, in from opendr.renderer import ColoredRenderer File "/home/cga/.local/lib/python3.10/site-packages/opendr/renderer.py", line 25, in from .contexts.ctx_mesa import OsContext File "opendr/contexts/ctx_mesa.pyx", line 1, in init opendr.contexts.ctx_mesa ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

cga-cmu commented 4 months ago

Python 3.8.19 seems to work without modifying any files in mesh. Here is what I did:

sudo apt-get install libboost-dev conda create --name mesh python=3.8 conda activate mesh

edit Makefile --install-option -> --config-settings

BOOST_INCLUDE_DIRS=/usr/include/boost make all

Zielon commented 3 months ago

@vchoutas, @jcpassy it would be nice to update Makefile indeed.