Skip to content

Commit 13df148

Browse files
committed
fix: PyPy needs to overrite broken FindPythonInterp values
Signed-off-by: Henry Schreiner <[email protected]>
1 parent fab1eeb commit 13df148

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tools/FindPythonLibsNew.cmake

+18-1
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,24 @@ if(NOT PythonLibsNew_FIND_VERSION)
9595
set(PythonLibsNew_FIND_VERSION "3.6")
9696
endif()
9797

98+
# Save variables that get set by PythonInterp
99+
macro(_PYBIND11_PUSH_IF_DEFINED name)
100+
if(DEFINED "${name}")
101+
set("_PYBIND11_ORIG_${name}" "${${name}}")
102+
endif()
103+
endmacro()
104+
105+
_pybind11_push_if_defined(PYTHON_INCLUDE_DIR)
106+
_pybind11_push_if_defined(PYTHON_MODULE_EXTENSION)
107+
_pybind11_push_if_defined(PYTHON_IS_DEBUG)
108+
98109
find_package(PythonInterp ${PythonLibsNew_FIND_VERSION} ${_pythonlibs_required}
99110
${_pythonlibs_quiet})
100111

112+
unset(PYTHON_INCLUDE_DIR)
113+
unset(PYTHON_MODULE_EXTENSION)
114+
unset(PYTHON_IS_DEBUG)
115+
101116
if(NOT PYTHONINTERP_FOUND)
102117
set(PYTHONLIBS_FOUND FALSE)
103118
set(PythonLibsNew_FOUND FALSE)
@@ -153,7 +168,9 @@ endif()
153168

154169
# Can manually set values when cross-compiling
155170
macro(_PYBIND11_GET_IF_UNDEF lst index name)
156-
if(NOT DEFINED "${name}")
171+
if(DEFINED "_PYBIND11_ORIG_${name}")
172+
set("${name}" "${_PYBIND11_ORIG_${name}}")
173+
elseif(NOT DEFINED "${name}")
157174
list(GET "${lst}" "${index}" "${name}")
158175
endif()
159176
endmacro()

0 commit comments

Comments
 (0)