Skip to content

Commit 0103ed1

Browse files
committed
Merge branch 'master' into sh_merge_master
2 parents a5b0cdc + eeac2f4 commit 0103ed1

File tree

19 files changed

+109
-62
lines changed

19 files changed

+109
-62
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ jobs:
7373
- uses: actions/checkout@v4
7474

7575
- name: Setup Python ${{ matrix.python }}
76-
uses: actions/setup-python@v4
76+
uses: actions/setup-python@v5
7777
with:
7878
python-version: ${{ matrix.python }}
79-
allow-prereleases: true
8079

8180
- name: Setup Boost (Linux)
8281
# Can't use boost + define _
@@ -740,7 +739,7 @@ jobs:
740739
steps:
741740
- uses: actions/checkout@v4
742741

743-
- uses: actions/setup-python@v4
742+
- uses: actions/setup-python@v5
744743
with:
745744
python-version: "3.x"
746745

@@ -793,7 +792,7 @@ jobs:
793792
- uses: actions/checkout@v4
794793

795794
- name: Setup Python ${{ matrix.python }}
796-
uses: actions/setup-python@v4
795+
uses: actions/setup-python@v5
797796
with:
798797
python-version: ${{ matrix.python }}
799798
architecture: x86
@@ -846,7 +845,7 @@ jobs:
846845
- uses: actions/checkout@v4
847846

848847
- name: Setup Python ${{ matrix.python }}
849-
uses: actions/setup-python@v4
848+
uses: actions/setup-python@v5
850849
with:
851850
python-version: ${{ matrix.python }}
852851
architecture: x86
@@ -894,7 +893,7 @@ jobs:
894893
- uses: actions/checkout@v4
895894

896895
- name: Setup Python ${{ matrix.python }}
897-
uses: actions/setup-python@v4
896+
uses: actions/setup-python@v5
898897
with:
899898
python-version: ${{ matrix.python }}
900899

@@ -974,7 +973,10 @@ jobs:
974973
- name: Configure C++11
975974
# LTO leads to many undefined reference like
976975
# `pybind11::detail::function_call::function_call(pybind11::detail::function_call&&)
977-
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build
976+
run: >-
977+
cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
978+
-DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)")
979+
-S . -B build
978980
979981
- name: Build C++11
980982
run: cmake --build build -j 2
@@ -992,7 +994,10 @@ jobs:
992994
run: git clean -fdx
993995

994996
- name: Configure C++14
995-
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build2
997+
run: >-
998+
cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
999+
-DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)")
1000+
-S . -B build2
9961001
9971002
- name: Build C++14
9981003
run: cmake --build build2 -j 2
@@ -1010,7 +1015,10 @@ jobs:
10101015
run: git clean -fdx
10111016

10121017
- name: Configure C++17
1013-
run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build3
1018+
run: >-
1019+
cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON
1020+
-DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)")
1021+
-S . -B build3
10141022
10151023
- name: Build C++17
10161024
run: cmake --build build3 -j 2
@@ -1046,7 +1054,7 @@ jobs:
10461054
uses: egor-tensin/setup-clang@v1
10471055

10481056
- name: Setup Python ${{ matrix.python }}
1049-
uses: actions/setup-python@v4
1057+
uses: actions/setup-python@v5
10501058
with:
10511059
python-version: ${{ matrix.python }}
10521060

.github/workflows/configure.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- uses: actions/checkout@v4
5454

5555
- name: Setup Python 3.7
56-
uses: actions/setup-python@v4
56+
uses: actions/setup-python@v5
5757
with:
5858
python-version: 3.7
5959
architecture: ${{ matrix.arch }}

.github/workflows/format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- uses: actions/checkout@v4
30-
- uses: actions/setup-python@v4
30+
- uses: actions/setup-python@v5
3131
with:
3232
python-version: "3.x"
3333
- name: Add matchers

.github/workflows/pip.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- uses: actions/checkout@v4
3333

3434
- name: Setup 🐍 3.6
35-
uses: actions/setup-python@v4
35+
uses: actions/setup-python@v5
3636
with:
3737
python-version: 3.6
3838

@@ -54,7 +54,7 @@ jobs:
5454
- uses: actions/checkout@v4
5555

5656
- name: Setup 🐍 3.8
57-
uses: actions/setup-python@v4
57+
uses: actions/setup-python@v5
5858
with:
5959
python-version: 3.8
6060

@@ -74,13 +74,13 @@ jobs:
7474
run: twine check dist/*
7575

7676
- name: Save standard package
77-
uses: actions/upload-artifact@v3
77+
uses: actions/upload-artifact@v4
7878
with:
7979
name: standard
8080
path: dist/pybind11-*
8181

8282
- name: Save global package
83-
uses: actions/upload-artifact@v3
83+
uses: actions/upload-artifact@v4
8484
with:
8585
name: global
8686
path: dist/pybind11_global-*
@@ -95,12 +95,12 @@ jobs:
9595
needs: [packaging]
9696

9797
steps:
98-
- uses: actions/setup-python@v4
98+
- uses: actions/setup-python@v5
9999
with:
100100
python-version: "3.x"
101101

102102
# Downloads all to directories matching the artifact names
103-
- uses: actions/download-artifact@v3
103+
- uses: actions/download-artifact@v4
104104

105105
- name: Publish standard package
106106
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/upstream.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ concurrency:
1313

1414
env:
1515
PIP_BREAK_SYSTEM_PACKAGES: 1
16-
PIP_ONLY_BINARY: ":all:"
1716
# For cmake:
1817
VERBOSE: 1
1918

2019
jobs:
2120
standard:
22-
name: "🐍 3.12 latest • ubuntu-latest • x64"
21+
name: "🐍 3.13 latest • ubuntu-latest • x64"
2322
runs-on: ubuntu-latest
2423
# Only runs when the 'python dev' label is selected
2524
if: "contains(github.event.pull_request.labels.*.name, 'python dev')"
2625

2726
steps:
2827
- uses: actions/checkout@v4
2928

30-
- name: Setup Python 3.12
31-
uses: actions/setup-python@v4
29+
- name: Setup Python 3.13
30+
uses: actions/setup-python@v5
3231
with:
33-
python-version: "3.12-dev"
32+
python-version: "3.13"
33+
allow-prereleases: true
3434

3535
- name: Setup Boost
3636
run: sudo apt-get install libboost-dev

CMakeLists.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ endif()
1212

1313
cmake_minimum_required(VERSION 3.5)
1414

15-
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
15+
# The `cmake_minimum_required(VERSION 3.5...3.27)` syntax does not work with
1616
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
1717
# the behavior using the following workaround:
18-
if(${CMAKE_VERSION} VERSION_LESS 3.26)
18+
if(${CMAKE_VERSION} VERSION_LESS 3.27)
1919
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
2020
else()
21-
cmake_policy(VERSION 3.26)
21+
cmake_policy(VERSION 3.27)
2222
endif()
2323

2424
if(_pybind11_cmp0148)
@@ -92,9 +92,15 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
9292
set(pybind11_system "")
9393

9494
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
95+
if(CMAKE_VERSION VERSION_LESS "3.18")
96+
set(_pybind11_findpython_default OFF)
97+
else()
98+
set(_pybind11_findpython_default ON)
99+
endif()
95100
else()
96101
set(PYBIND11_MASTER_PROJECT OFF)
97102
set(pybind11_system SYSTEM)
103+
set(_pybind11_findpython_default OFF)
98104
endif()
99105

100106
# Options
@@ -116,9 +122,18 @@ cmake_dependent_option(
116122
"Install pybind11 headers in Python include directory instead of default installation prefix"
117123
OFF "PYBIND11_INSTALL" OFF)
118124

119-
cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" OFF
125+
cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" ${_pybind11_findpython_default}
120126
"NOT CMAKE_VERSION VERSION_LESS 3.12" OFF)
121127

128+
# Allow PYTHON_EXECUTABLE if in FINDPYTHON mode and building pybind11's tests
129+
# (makes transition easier while we support both modes).
130+
if(PYBIND11_MASTER_PROJECT
131+
AND PYBIND11_FINDPYTHON
132+
AND DEFINED PYTHON_EXECUTABLE
133+
AND NOT DEFINED Python_EXECUTABLE)
134+
set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}")
135+
endif()
136+
122137
# NB: when adding a header don't forget to also add it to setup.py
123138
set(PYBIND11_HEADERS
124139
include/pybind11/detail/class.h

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.26)
21+
cmake_minimum_required(VERSION 3.5...3.27)
2222
project(example)
2323
2424
find_package(pybind11 REQUIRED) # or `add_subdirectory(pybind11)`

docs/compiling.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ extension module can be created with just a few lines of code:
241241

242242
.. code-block:: cmake
243243
244-
cmake_minimum_required(VERSION 3.5...3.26)
244+
cmake_minimum_required(VERSION 3.5...3.27)
245245
project(example LANGUAGES CXX)
246246
247247
add_subdirectory(pybind11)
@@ -498,7 +498,7 @@ You can use these targets to build complex applications. For example, the
498498

499499
.. code-block:: cmake
500500
501-
cmake_minimum_required(VERSION 3.5...3.26)
501+
cmake_minimum_required(VERSION 3.5...3.27)
502502
project(example LANGUAGES CXX)
503503
504504
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)
@@ -556,7 +556,7 @@ information about usage in C++, see :doc:`/advanced/embedding`.
556556

557557
.. code-block:: cmake
558558
559-
cmake_minimum_required(VERSION 3.5...3.26)
559+
cmake_minimum_required(VERSION 3.5...3.27)
560560
project(example LANGUAGES CXX)
561561
562562
find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11)

include/pybind11/detail/class.h

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,16 @@ inline PyTypeObject *make_static_property_type() {
8686
type->tp_descr_get = pybind11_static_get;
8787
type->tp_descr_set = pybind11_static_set;
8888

89-
if (PyType_Ready(type) < 0) {
90-
pybind11_fail("make_static_property_type(): failure in PyType_Ready()!");
91-
}
92-
9389
# if PY_VERSION_HEX >= 0x030C0000
94-
// PRE 3.12 FEATURE FREEZE. PLEASE REVIEW AFTER FREEZE.
9590
// Since Python-3.12 property-derived types are required to
9691
// have dynamic attributes (to set `__doc__`)
9792
enable_dynamic_attributes(heap_type);
9893
# endif
9994

95+
if (PyType_Ready(type) < 0) {
96+
pybind11_fail("make_static_property_type(): failure in PyType_Ready()!");
97+
}
98+
10099
setattr((PyObject *) type, "__module__", str("pybind11_builtins"));
101100
PYBIND11_SET_OLDPY_QUALNAME(type, name_obj);
102101

@@ -522,8 +521,12 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass) {
522521

523522
/// dynamic_attr: Allow the garbage collector to traverse the internal instance `__dict__`.
524523
extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *arg) {
524+
#if PY_VERSION_HEX >= 0x030D0000
525+
PyObject_VisitManagedDict(self, visit, arg);
526+
#else
525527
PyObject *&dict = *_PyObject_GetDictPtr(self);
526528
Py_VISIT(dict);
529+
#endif
527530
// https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_traverse
528531
#if PY_VERSION_HEX >= 0x03090000
529532
Py_VISIT(Py_TYPE(self));
@@ -533,8 +536,12 @@ extern "C" inline int pybind11_traverse(PyObject *self, visitproc visit, void *a
533536

534537
/// dynamic_attr: Allow the GC to clear the dictionary.
535538
extern "C" inline int pybind11_clear(PyObject *self) {
539+
#if PY_VERSION_HEX >= 0x030D0000
540+
PyObject_ClearManagedDict(self);
541+
#else
536542
PyObject *&dict = *_PyObject_GetDictPtr(self);
537543
Py_CLEAR(dict);
544+
#endif
538545
return 0;
539546
}
540547

tests/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
cmake_minimum_required(VERSION 3.5)
99

10-
# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with
10+
# The `cmake_minimum_required(VERSION 3.5...3.27)` syntax does not work with
1111
# some versions of VS that have a patched CMake 3.11. This forces us to emulate
1212
# the behavior using the following workaround:
13-
if(${CMAKE_VERSION} VERSION_LESS 3.26)
13+
if(${CMAKE_VERSION} VERSION_LESS 3.27)
1414
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
1515
else()
16-
cmake_policy(VERSION 3.26)
16+
cmake_policy(VERSION 3.27)
1717
endif()
1818

1919
# Filter out items; print an optional message if any items filtered. This ignores extensions.

0 commit comments

Comments
 (0)