Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: PyPy needs to overrite broken FindPythonInterp values
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
henryiii committed Oct 20, 2022
1 parent 17c6809 commit 0e5b772
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tools/FindPythonLibsNew.cmake
Original file line number Diff line number Diff line change
@@ -95,9 +95,24 @@ if(NOT PythonLibsNew_FIND_VERSION)
set(PythonLibsNew_FIND_VERSION "3.6")
endif()

# Save variables that get set by PythonInterp
macro(_PYBIND11_PUSH_IF_DEFINED name)
if(DEFINED "${name}")
set("_PYBIND11_ORIG_${name}" "${${name}}")
endif()
endmacro()

_pybind11_push_if_defined(PYTHON_INCLUDE_DIR)
_pybind11_push_if_defined(PYTHON_MODULE_EXTENSION)
_pybind11_push_if_defined(PYTHON_IS_DEBUG)

find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} ${_pythonlibs_required}
${_pythonlibs_quiet})

unset(PYTHON_INCLUDE_DIR)
unset(PYTHON_MODULE_EXTENSION)
unset(PYTHON_IS_DEBUG)

if(NOT PYTHONINTERP_FOUND)
set(PYTHONLIBS_FOUND FALSE)
set(PythonLibsNew_FOUND FALSE)
@@ -153,7 +168,9 @@ endif()

# Can manually set values when cross-compiling
macro(_PYBIND11_GET_IF_UNDEF lst index name)
if(NOT DEFINED "${name}")
if(DEFINED "_PYBIND11_ORIG_${name}")
set("${name}" "${_PYBIND11_ORIG_${name}}")
elseif(NOT DEFINED "${name}")
list(GET "${lst}" "${index}" "${name}")
endif()
endmacro()

0 comments on commit 0e5b772

Please sign in to comment.