File tree 4 files changed +33
-6
lines changed
4 files changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -52,17 +52,17 @@ jobs:
52
52
- runs-on : ubuntu-20.04
53
53
python : ' 3.8'
54
54
args : >
55
- -DPYBIND11_FINDPYTHON=ON
55
+ -DPYBIND11_FINDPYTHON=OFF
56
56
-DCMAKE_CXX_FLAGS="-D_=1"
57
57
exercise_D_ : 1
58
58
- runs-on : ubuntu-20.04
59
59
python : ' pypy-3.8'
60
60
args : >
61
- -DPYBIND11_FINDPYTHON=ON
61
+ -DPYBIND11_FINDPYTHON=OFF
62
62
- runs-on : windows-2019
63
63
python : ' 3.8'
64
64
args : >
65
- -DPYBIND11_FINDPYTHON=ON
65
+ -DPYBIND11_FINDPYTHON=OFF
66
66
# Inject a couple Windows 2019 runs
67
67
- runs-on : windows-2019
68
68
python : ' 3.9'
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
81
81
else ()
82
82
set (PYBIND11_MASTER_PROJECT OFF )
83
83
set (pybind11_system SYSTEM )
84
- set (_pybind11_findpython_default OFF )
84
+ set (_pybind11_findpython_default COMPAT )
85
85
endif ()
86
86
87
87
# Options
@@ -114,7 +114,9 @@ cmake_dependent_option(
114
114
"Install pybind11 headers in Python include directory instead of default installation prefix"
115
115
OFF "PYBIND11_INSTALL" OFF )
116
116
117
- option (PYBIND11_FINDPYTHON "Force new FindPython" ${_pybind11_findpython_default} )
117
+ set (PYBIND11_FINDPYTHON
118
+ ${_pybind11_findpython_default}
119
+ CACHE STRING "Force new FindPython - NEW, OLD, COMPAT" )
118
120
119
121
# Allow PYTHON_EXECUTABLE if in FINDPYTHON mode and building pybind11's tests
120
122
# (makes transition easier while we support both modes).
Original file line number Diff line number Diff line change @@ -192,7 +192,25 @@ elseif(
192
192
))
193
193
194
194
# New mode
195
- include ("${CMAKE_CURRENT_LIST_DIR} /pybind11NewTools.cmake" )
195
+ if (Python_FOUND OR Python3_FOUND)
196
+ include ("${CMAKE_CURRENT_LIST_DIR} /pybind11NewTools.cmake" )
197
+ else ()
198
+ include ("${CMAKE_CURRENT_LIST_DIR} /pybind11NewTools.cmake" )
199
+
200
+ message (
201
+ "Using compatibility mode for Python, set PYBIND11_FINDPYTHON to NEW/OLD to silence this message"
202
+ )
203
+ set (PYTHON_EXECUTABLE "${Python_EXECUTABLE} " )
204
+ set (PYTHON_INCLUDE_DIR "${Python_INCLUDE_DIR} " )
205
+ set (Python_INCLUDE_DIRS "${Python_INCLUDE_DIRS} " )
206
+ set (PYTHON_LIBRARY "${Python_LIRARY} " )
207
+ set (PYTHON_LIBRARIES "${Python_LIRARIES} " )
208
+ set (PYTHON_VERSION "${Python_VERSION} " )
209
+ set (PYTHON_VERSION_STRING "${Python_VERSION_STRING} " )
210
+ set (PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR} " )
211
+ set (PYTHON_VERSION_MINOR "${Python_VERSION_MINOR} " )
212
+ set (PYTHON_VERSION_PATCH "${Python_VERSION_PATCH} " )
213
+ endif ()
196
214
197
215
else ()
198
216
Original file line number Diff line number Diff line change @@ -67,6 +67,13 @@ from 3.12+ forward (3.15+ _highly_ recommended). If you set the minimum or
67
67
maximum version of CMake to 3.27+, then FindPython is the default (since
68
68
FindPythonInterp/FindPythonLibs has been removed via policy `CMP0148`).
69
69
70
+ Starting in pybind11 3.0, the new mode is the default, but we provide backward
71
+ compatible names (`PYTHON_*` vs. the new `Python_* names). Set the mode
72
+ explicitly to avoid the compatibility defines. You can specify this mode
73
+ explicitly by setting `PYBIND11_FINDPYTHON` to `COMPAT`, but if you are changing
74
+ your CMakeLists anyway, please just use the `ON` mode. A future release may
75
+ default to `ON`.
76
+
70
77
New FindPython mode
71
78
^^^^^^^^^^^^^^^^^^^
72
79
You can’t perform that action at this time.
0 commit comments