AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Mozilla Public License 2.0
2.62k stars 647 forks source link

[BUILD] Python bindings fail to build for version 3.11 #1803

Closed StefanKarlsson987 closed 4 months ago

StefanKarlsson987 commented 5 months ago

Environment

Operating System: Ubuntu 22.04 Version / Commit SHA: VDB 11.0.0 AND current ToT (sha 08409f0044afe0b188398dd2b27af7d8edb8c554)

Describe the bug

When trying to build with the python bindings, the process fails with various error messages connected to "PyFrameObject". This has been tested for python version 3.11.7 and 3.11.9.

see the make_output.log

Likely root cause: PyFrameObject has been removed from python version 3.11

To Reproduce

cmake .. -D CMAKE_INSTALL_PREFIX=$HOME/openvdb -D CMAKE_BUILD_TYPE=Release -D OPENVDB_BUILD_PYTHON_MODULE=ON -D Python_EXECUTABLE=/path/to/python/python3.11 make -j$(nproc) 2>&1 | tee make_output.log

Expected behavior

I expected no errors reported, and then have working python bindings that would work on my python 3.11 environment.

StefanKarlsson987 commented 5 months ago

The reason I do not want to revert to earlier version of python, is that I plan to use this from inside of Blender. Blender 4.1 comes shipped with python 3.11.7.

I already have a large addon created in the python API for blender, and would like to add proper VDB processing to it, which Blender currently does not have natively (unlike Maya).

StefanKarlsson987 commented 5 months ago

Closer investigation shows that this error actually occurs in the pybind11 dependency. The install instructions of OpenVDB says to get the standard pybind11 version through apt:

apt-get install pybind11-dev

I managed to fix the errors on my Ubuntu 22.04 system by building the latest pybind11 from source. here is what I did:

  1. sudo apt-get remove pybind11-dev, if another version was added using apt.
  2. install pybind11 from source, to get a version that supports newer versions of python. Repo here
  3. make certain to use cmake with the -D Python_EXECUTABLE path same as for the openVDB build
  4. in the pybind11 cloned repo: sudo make install

Have not tested openVDB python interface yet, so not sure if this will work, but seems promising. No more build errors.

Be aware that if you have other projects using pybind11, this might break those builds. A more robust solution would be to build pybind11 locally without installing, and then link it up with cmake.

Idclip commented 4 months ago

Closing this as it seems as though you managed to resolve your issue? Yes, using apt-get assumes that you're installing all your dependencies through apt-get as this is how the apt repositories are configured; the set of software they provided is tested to work together. If you instead mix dependencies, such as a newer version of Python with those fromapt, then your build solution is not guaranteed to work and you may find you need to also upgrade other dependencies too.