Skip to content

Commit 205da0d

Browse files
committed
Merge branch 'master' into sh_merge_master
2 parents 47776dc + a1d0091 commit 205da0d

File tree

25 files changed

+259
-314
lines changed

25 files changed

+259
-314
lines changed

.github/CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ nox -s build
8181
### Full setup
8282

8383
To setup an ideal development environment, run the following commands on a
84-
system with CMake 3.14+:
84+
system with CMake 3.15+:
8585

8686
```bash
8787
python3 -m venv venv
@@ -96,8 +96,8 @@ Tips:
9696
* You can use `virtualenv` (faster, from PyPI) instead of `venv`.
9797
* You can select any name for your environment folder; if it contains "env" it
9898
will be ignored by git.
99-
* If you don't have CMake 3.14+, just add "cmake" to the pip install command.
100-
* You can use `-DPYBIND11_FINDPYTHON=ON` to use FindPython on CMake 3.12+
99+
* If you don't have CMake 3.15+, just add "cmake" to the pip install command.
100+
* You can use `-DPYBIND11_FINDPYTHON=ON` to use FindPython.
101101
* In classic mode, you may need to set `-DPYTHON_EXECUTABLE=/path/to/python`.
102102
FindPython uses `-DPython_ROOT_DIR=/path/to` or
103103
`-DPython_EXECUTABLE=/path/to/python`.
@@ -149,8 +149,8 @@ To run the tests, you can "build" the check target:
149149
cmake --build build --target check
150150
```
151151

152-
`--target` can be spelled `-t` in CMake 3.15+. You can also run individual
153-
tests with these targets:
152+
`--target` can be spelled `-t`. You can also run individual tests with these
153+
targets:
154154

155155
* `pytest`: Python tests only, using the
156156
[pytest](https://docs.pytest.org/en/stable/) framework

.github/workflows/configure.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ jobs:
3232
include:
3333
- runs-on: ubuntu-20.04
3434
arch: x64
35-
cmake: "3.5"
35+
cmake: "3.15"
3636

3737
- runs-on: ubuntu-20.04
3838
arch: x64
3939
cmake: "3.29"
4040

4141
- runs-on: macos-13
4242
arch: x64
43-
cmake: "3.8"
43+
cmake: "3.15"
4444

4545
- runs-on: windows-2019
4646
arch: x64 # x86 compilers seem to be missing on 2019 image

CMakeLists.txt

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,15 @@ if(NOT CMAKE_VERSION VERSION_LESS "3.27")
1010
cmake_policy(GET CMP0148 _pybind11_cmp0148)
1111
endif()
1212

13-
cmake_minimum_required(VERSION 3.5)
14-
15-
# The `cmake_minimum_required(VERSION 3.5...3.29)` syntax does not work with
16-
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
17-
# the behavior using the following workaround:
18-
if(${CMAKE_VERSION} VERSION_LESS 3.29)
19-
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
20-
else()
21-
cmake_policy(VERSION 3.29)
22-
endif()
13+
cmake_minimum_required(VERSION 3.15...3.30)
2314

2415
if(_pybind11_cmp0148)
2516
cmake_policy(SET CMP0148 ${_pybind11_cmp0148})
2617
unset(_pybind11_cmp0148)
2718
endif()
2819

2920
# Avoid infinite recursion if tests include this as a subdirectory
30-
if(DEFINED PYBIND11_MASTER_PROJECT)
31-
return()
32-
endif()
21+
include_guard(GLOBAL)
3322

3423
# Extract project version from source
3524
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/pybind11/detail/common.h"
@@ -74,14 +63,6 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
7463

7564
set(PYBIND11_MASTER_PROJECT ON)
7665

77-
if(OSX AND CMAKE_VERSION VERSION_LESS 3.7)
78-
# Bug in macOS CMake < 3.7 is unable to download catch
79-
message(WARNING "CMAKE 3.7+ needed on macOS to download catch, and newer HIGHLY recommended")
80-
elseif(WINDOWS AND CMAKE_VERSION VERSION_LESS 3.8)
81-
# Only tested with 3.8+ in CI.
82-
message(WARNING "CMAKE 3.8+ tested on Windows, previous versions untested")
83-
endif()
84-
8566
message(STATUS "CMake ${CMAKE_VERSION}")
8667

8768
if(CMAKE_CXX_STANDARD)
@@ -133,8 +114,7 @@ cmake_dependent_option(
133114
"Install pybind11 headers in Python include directory instead of default installation prefix"
134115
OFF "PYBIND11_INSTALL" OFF)
135116

136-
cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" ${_pybind11_findpython_default}
137-
"NOT CMAKE_VERSION VERSION_LESS 3.12" OFF)
117+
option(PYBIND11_FINDPYTHON "Force new FindPython" ${_pybind11_findpython_default})
138118

139119
# Allow PYTHON_EXECUTABLE if in FINDPYTHON mode and building pybind11's tests
140120
# (makes transition easier while we support both modes).
@@ -188,7 +168,7 @@ set(PYBIND11_HEADERS
188168
include/pybind11/typing.h)
189169

190170
# Compare with grep and warn if mismatched
191-
if(PYBIND11_MASTER_PROJECT AND NOT CMAKE_VERSION VERSION_LESS 3.12)
171+
if(PYBIND11_MASTER_PROJECT)
192172
file(
193173
GLOB_RECURSE _pybind11_header_check
194174
LIST_DIRECTORIES false
@@ -206,10 +186,7 @@ if(PYBIND11_MASTER_PROJECT AND NOT CMAKE_VERSION VERSION_LESS 3.12)
206186
endif()
207187
endif()
208188

209-
# CMake 3.12 added list(TRANSFORM <list> PREPEND
210-
# But we can't use it yet
211-
string(REPLACE "include/" "${CMAKE_CURRENT_SOURCE_DIR}/include/" PYBIND11_HEADERS
212-
"${PYBIND11_HEADERS}")
189+
list(TRANSFORM PYBIND11_HEADERS PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
213190

214191
# Cache variable so this can be used in parent projects
215192
set(pybind11_INCLUDE_DIR
@@ -279,25 +256,11 @@ if(PYBIND11_INSTALL)
279256
tools/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
280257
INSTALL_DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR})
281258

282-
if(CMAKE_VERSION VERSION_LESS 3.14)
283-
# Remove CMAKE_SIZEOF_VOID_P from ConfigVersion.cmake since the library does
284-
# not depend on architecture specific settings or libraries.
285-
set(_PYBIND11_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
286-
unset(CMAKE_SIZEOF_VOID_P)
287-
288-
write_basic_package_version_file(
289-
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
290-
VERSION ${PROJECT_VERSION}
291-
COMPATIBILITY AnyNewerVersion)
292-
293-
set(CMAKE_SIZEOF_VOID_P ${_PYBIND11_CMAKE_SIZEOF_VOID_P})
294-
else()
295-
# CMake 3.14+ natively supports header-only libraries
296-
write_basic_package_version_file(
297-
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
298-
VERSION ${PROJECT_VERSION}
299-
COMPATIBILITY AnyNewerVersion ARCH_INDEPENDENT)
300-
endif()
259+
# CMake natively supports header-only libraries
260+
write_basic_package_version_file(
261+
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
262+
VERSION ${PROJECT_VERSION}
263+
COMPATIBILITY AnyNewerVersion ARCH_INDEPENDENT)
301264

302265
install(
303266
FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake

docs/advanced/embedding.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ information, see :doc:`/compiling`.
1818

1919
.. code-block:: cmake
2020
21-
cmake_minimum_required(VERSION 3.5...3.29)
21+
cmake_minimum_required(VERSION 3.15...3.30)
2222
project(example)
2323
2424
find_package(pybind11 REQUIRED) # or `add_subdirectory(pybind11)`

docs/changelog.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,28 @@ New Features:
2020
* Support for Python 3.7 was removed. (Official end-of-life: 2023-06-27).
2121
`#5191 <https://github.com/pybind/pybind11/pull/5191>`_
2222

23-
Support for CMake older than 3.15 and some older compilers will also be removed.
23+
* stl.h ``list|set|map_caster`` were made more user friendly: it is no longer
24+
necessary to explicitly convert Python iterables to ``tuple()``, ``set()``,
25+
or ``map()`` in many common situations.
26+
`#4686 <https://github.com/pybind/pybind11/pull/4686>`_
27+
28+
* Support for CMake older than 3.15 removed. CMake 3.15-3.30 supported.
29+
`#5304 <https://github.com/pybind/pybind11/pull/5304>`_
30+
31+
Version 2.13.4 (August 14, 2024)
32+
--------------------------------
33+
34+
Bug fixes:
35+
36+
* Fix paths with spaces, including on Windows.
37+
(Replaces regression from `#5302 <https://github.com/pybind/pybind11/pull/5302>`_)
38+
`#4874 <https://github.com/pybind/pybind11/pull/4874>`_
39+
40+
Documentation:
41+
42+
* Remove repetitive words.
43+
`#5308 <https://github.com/pybind/pybind11/pull/5308>`_
44+
2445

2546
Version 2.13.3 (August 13, 2024)
2647
--------------------------------

docs/compiling.rst

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A Python extension module can be created with just a few lines of code:
1818

1919
.. code-block:: cmake
2020
21-
cmake_minimum_required(VERSION 3.15...3.29)
21+
cmake_minimum_required(VERSION 3.15...3.30)
2222
project(example LANGUAGES CXX)
2323
2424
set(PYBIND11_FINDPYTHON ON)
@@ -319,11 +319,11 @@ Building with CMake
319319

320320
For C++ codebases that have an existing CMake-based build system, a Python
321321
extension module can be created with just a few lines of code, as seen above in
322-
the module section. Pybind11 currently supports a lower minimum if you don't
323-
use the modern FindPython, though be aware that CMake 3.27 removed the old
324-
mechanism, so pybind11 will automatically switch if the old mechanism is not
325-
available. Please opt into the new mechanism if at all possible. Our default
326-
may change in future versions. This is the minimum required:
322+
the module section. Pybind11 currently defaults to the old mechanism, though be
323+
aware that CMake 3.27 removed the old mechanism, so pybind11 will automatically
324+
switch if the old mechanism is not available. Please opt into the new mechanism
325+
if at all possible. Our default may change in future versions. This is the
326+
minimum required:
327327

328328

329329

@@ -333,6 +333,9 @@ may change in future versions. This is the minimum required:
333333
.. versionchanged:: 2.11
334334
CMake 3.5+ is required.
335335

336+
.. versionchanged:: 2.14
337+
CMake 3.15+ is required.
338+
336339

337340
Further information can be found at :doc:`cmake/index`.
338341

@@ -444,7 +447,7 @@ See the `Config file`_ docstring for details of relevant CMake variables.
444447

445448
.. code-block:: cmake
446449
447-
cmake_minimum_required(VERSION 3.4...3.18)
450+
cmake_minimum_required(VERSION 3.15...3.30)
448451
project(example LANGUAGES CXX)
449452
450453
find_package(pybind11 REQUIRED)
@@ -483,14 +486,13 @@ can refer to the same [cmake_example]_ repository for a full sample project
483486
FindPython mode
484487
---------------
485488

486-
CMake 3.12+ (3.15+ recommended, 3.18.2+ ideal) added a new module called
487-
FindPython that had a highly improved search algorithm and modern targets
488-
and tools. If you use FindPython, pybind11 will detect this and use the
489-
existing targets instead:
489+
Modern CMake (3.18.2+ ideal) added a new module called FindPython that had a
490+
highly improved search algorithm and modern targets and tools. If you use
491+
FindPython, pybind11 will detect this and use the existing targets instead:
490492

491493
.. code-block:: cmake
492494
493-
cmake_minimum_required(VERSION 3.15...3.22)
495+
cmake_minimum_required(VERSION 3.15...3.30)
494496
project(example LANGUAGES CXX)
495497
496498
find_package(Python 3.8 COMPONENTS Interpreter Development REQUIRED)
@@ -541,7 +543,7 @@ available in all modes. The targets provided are:
541543
Just the "linking" part of pybind11:module
542544

543545
``pybind11::module``
544-
Everything for extension modules - ``pybind11::pybind11`` + ``Python::Module`` (FindPython CMake 3.15+) or ``pybind11::python_link_helper``
546+
Everything for extension modules - ``pybind11::pybind11`` + ``Python::Module`` (FindPython) or ``pybind11::python_link_helper``
545547

546548
``pybind11::embed``
547549
Everything for embedding the Python interpreter - ``pybind11::pybind11`` + ``Python::Python`` (FindPython) or Python libs
@@ -568,7 +570,7 @@ You can use these targets to build complex applications. For example, the
568570

569571
.. code-block:: cmake
570572
571-
cmake_minimum_required(VERSION 3.5...3.29)
573+
cmake_minimum_required(VERSION 3.15...3.30)
572574
project(example LANGUAGES CXX)
573575
574576
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
@@ -626,7 +628,7 @@ information about usage in C++, see :doc:`/advanced/embedding`.
626628

627629
.. code-block:: cmake
628630
629-
cmake_minimum_required(VERSION 3.5...3.29)
631+
cmake_minimum_required(VERSION 3.15...3.30)
630632
project(example LANGUAGES CXX)
631633
632634
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)

docs/faq.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ CMake configure line. (Replace ``$(which python)`` with a path to python if
258258
your prefer.)
259259

260260
You can alternatively try ``-DPYBIND11_FINDPYTHON=ON``, which will activate the
261-
new CMake FindPython support instead of pybind11's custom search. Requires
262-
CMake 3.12+, and 3.15+ or 3.18.2+ are even better. You can set this in your
263-
``CMakeLists.txt`` before adding or finding pybind11, as well.
261+
new CMake FindPython support instead of pybind11's custom search. Newer CMake,
262+
like, 3.18.2+, is recommended. You can set this in your ``CMakeLists.txt``
263+
before adding or finding pybind11, as well.
264264

265265
Inconsistent detection of Python version in CMake and pybind11
266266
==============================================================
@@ -281,11 +281,11 @@ There are three possible solutions:
281281
from CMake and rely on pybind11 in detecting Python version. If this is not
282282
possible, the CMake machinery should be called *before* including pybind11.
283283
2. Set ``PYBIND11_FINDPYTHON`` to ``True`` or use ``find_package(Python
284-
COMPONENTS Interpreter Development)`` on modern CMake (3.12+, 3.15+ better,
285-
3.18.2+ best). Pybind11 in these cases uses the new CMake FindPython instead
286-
of the old, deprecated search tools, and these modules are much better at
287-
finding the correct Python. If FindPythonLibs/Interp are not available
288-
(CMake 3.27+), then this will be ignored and FindPython will be used.
284+
COMPONENTS Interpreter Development)`` on modern CMake ( 3.18.2+ best).
285+
Pybind11 in these cases uses the new CMake FindPython instead of the old,
286+
deprecated search tools, and these modules are much better at finding the
287+
correct Python. If FindPythonLibs/Interp are not available (CMake 3.27+),
288+
then this will be ignored and FindPython will be used.
289289
3. Set ``PYBIND11_NOPYTHON`` to ``TRUE``. Pybind11 will not search for Python.
290290
However, you will have to use the target-based system, and do more setup
291291
yourself, because it does not know about or include things that depend on

0 commit comments

Comments
 (0)