hiddenSymmetries / virtual-casing

4 stars 7 forks source link

pybind11 submodule defaults to v2.9.1 incompatible with python 3.11 #7

Closed smiet closed 1 year ago

smiet commented 1 year ago

Cmake installs pybind11 in extern/pybind11, and somehow defaults to pybind11 v2.9.1.

This version of pybind is incompatible with python 3.11, and upon compilation you get the message :

/home/smiet/code/virtual-casing/extern/pybind11/include/pybind11/detail/type_caster_base.h:482:26: error: invalid use of incomplete type ‘PyFrameObject’ {aka ‘struct _frame’}
  482 |             frame = frame->f_back;
      |                          ^~
In file included from /usr/include/python3.11/Python.h:42,

(the PyFrameObject has been removed from the public C API: https://docs.python.org/3.11/whatsnew/3.11.html)

Version resolution is somehow left to GIT, as CMakelists.txt reads:

find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
# Update submodules as needed
    option(GIT_SUBMODULE "Check submodules during build" ON)
    if(GIT_SUBMODULE)
        message(STATUS "Submodule update")
        execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
                        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                        RESULT_VARIABLE GIT_SUBMOD_RESULT)
        if(NOT GIT_SUBMOD_RESULT EQUAL "0")
            message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
        endif()
    endif()
endif()

so the version is somehow resolved by git, but the .gitmodules does not specify the version number.

I have not been able to find a way to request a different version of pybind, and the only workaround I found is the following:

-> change line 74 of CMakelists.txt to : ' option(GIT_SUBMODULE "Check submodules during build" OFF)' -> run cmake (mkdir build && cd build && cmake ..) -> go to extern/pybind11/ and `checkout master' -> go to build dir and make (or go to folder root and pip install)

This solution is not future proof and very manual, but I cannot for the life of me figure out how to configure it. Changing the branch variable in the .gitmodules file did not work.

smiet commented 1 year ago

Issue addressed in [https://github.com/hiddenSymmetries/virtual-casing/pull/10].

Just needed to pull in the submodule directory and then commit in the root directory (first time working with this, and git submodule documentation is a bit.... terse).

Closing and continuing on PR.

landreman commented 1 year ago

Resolved by #10