Skip to content

Commit d6ae0e1

Browse files
committed
Merge branch 'v3.0' into stable
2 parents eef24d6 + f5fbe86 commit d6ae0e1

43 files changed

Lines changed: 500 additions & 214 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/nightlies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
needs: [build_wheel]
4545
runs-on: ubuntu-latest
4646
steps:
47-
- uses: actions/download-artifact@v4
47+
- uses: actions/download-artifact@v5
4848
with:
4949
name: Packages
5050
path: dist

.github/workflows/pip.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ jobs:
100100

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

105105
- name: Generate artifact attestation for sdist and wheel
106106
uses: actions/attest-build-provenance@v2

.github/workflows/tests-cibw.yml

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,20 @@ jobs:
2222
submodules: true
2323
fetch-depth: 0
2424

25-
- uses: pypa/cibuildwheel@v3.0
25+
- uses: pypa/cibuildwheel@v3.1
2626
env:
2727
PYODIDE_BUILD_EXPORTS: whole_archive
2828
with:
2929
package-dir: tests
3030
only: cp312-pyodide_wasm32
3131

3232
build-ios:
33-
name: iOS wheel
34-
runs-on: macos-latest
33+
name: iOS wheel ${{ matrix.runs-on }}
34+
runs-on: ${{ matrix.runs-on }}
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
runs-on: [macos-14, macos-13]
3539
steps:
3640
- uses: actions/checkout@v4
3741
with:
@@ -40,8 +44,43 @@ jobs:
4044

4145
- run: brew upgrade cmake
4246

43-
- uses: pypa/cibuildwheel@v3.0
47+
- uses: pypa/cibuildwheel@v3.1
4448
env:
4549
CIBW_PLATFORM: ios
50+
CIBW_SKIP: cp314-* # https://github.com/pypa/cibuildwheel/issues/2494
51+
with:
52+
package-dir: tests
53+
54+
build-android:
55+
name: Android wheel ${{ matrix.runs-on }}
56+
runs-on: ${{ matrix.runs-on }}
57+
strategy:
58+
fail-fast: false
59+
matrix:
60+
runs-on: [macos-latest, macos-13, ubuntu-latest]
61+
steps:
62+
- uses: actions/checkout@v4
63+
with:
64+
submodules: true
65+
fetch-depth: 0
66+
67+
# GitHub Actions can't currently run the Android emulator on macOS.
68+
- name: Skip Android tests on macOS
69+
if: contains(matrix.runs-on, 'macos')
70+
run: echo "CIBW_TEST_COMMAND=" >> "$GITHUB_ENV"
71+
72+
# https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/
73+
- name: Enable KVM for Android emulator
74+
if: contains(matrix.runs-on, 'ubuntu')
75+
run: |
76+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
77+
sudo udevadm control --reload-rules
78+
sudo udevadm trigger --name-match=kvm
79+
80+
- run: pipx install patchelf
81+
82+
- uses: pypa/cibuildwheel@v3.1
83+
env:
84+
CIBW_PLATFORM: android
4685
with:
4786
package-dir: tests

.pre-commit-config.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ repos:
2525

2626
# Clang format the codebase automatically
2727
- repo: https://github.com/pre-commit/mirrors-clang-format
28-
rev: "v20.1.5"
28+
rev: "v20.1.8"
2929
hooks:
3030
- id: clang-format
3131
types_or: [c++, c, cuda]
3232

3333
# Ruff, the Python auto-correcting linter/formatter written in Rust
3434
- repo: https://github.com/astral-sh/ruff-pre-commit
35-
rev: v0.11.12
35+
rev: v0.12.7
3636
hooks:
37-
- id: ruff
37+
- id: ruff-check
3838
args: ["--fix", "--show-fixes"]
3939
- id: ruff-format
4040

4141
# Check static types with mypy
4242
- repo: https://github.com/pre-commit/mirrors-mypy
43-
rev: "v1.16.0"
43+
rev: "v1.17.1"
4444
hooks:
4545
- id: mypy
4646
args: []
@@ -95,7 +95,7 @@ repos:
9595

9696
# Avoid directional quotes
9797
- repo: https://github.com/sirosen/texthooks
98-
rev: "0.6.8"
98+
rev: "0.7.1"
9999
hooks:
100100
- id: fix-ligatures
101101
- id: fix-smartquotes
@@ -142,7 +142,7 @@ repos:
142142

143143
# Check schemas on some of our YAML files
144144
- repo: https://github.com/python-jsonschema/check-jsonschema
145-
rev: 0.33.0
145+
rev: 0.33.2
146146
hooks:
147147
- id: check-readthedocs
148148
- id: check-github-workflows

docs/advanced/cast/custom.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ type is explicitly allowed.
108108
} // namespace pybind11
109109
110110
// Bind the negate function
111-
PYBIND11_MODULE(docs_advanced_cast_custom, m) { m.def("negate", user_space::negate); }
111+
PYBIND11_MODULE(docs_advanced_cast_custom, m, py::mod_gil_not_used()) { m.def("negate", user_space::negate); }
112112
113113
.. note::
114114

docs/advanced/cast/functional.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ trivial to generate binding code for all of these functions.
5656
5757
#include <pybind11/functional.h>
5858
59-
PYBIND11_MODULE(example, m) {
59+
PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
6060
m.def("func_arg", &func_arg);
6161
m.def("func_ret", &func_ret);
6262
m.def("func_cpp", &func_cpp);

docs/advanced/classes.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Normally, the binding code for these classes would look as follows:
4545

4646
.. code-block:: cpp
4747
48-
PYBIND11_MODULE(example, m) {
48+
PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
4949
py::class_<Animal>(m, "Animal")
5050
.def("go", &Animal::go);
5151
@@ -64,7 +64,7 @@ helper class that is defined as follows:
6464

6565
.. code-block:: cpp
6666
67-
class PyAnimal : public Animal, py::trampoline_self_life_support {
67+
class PyAnimal : public Animal, public py::trampoline_self_life_support {
6868
public:
6969
/* Inherit the constructors */
7070
using Animal::Animal;
@@ -112,7 +112,7 @@ The binding code also needs a few minor adaptations (highlighted):
112112
.. code-block:: cpp
113113
:emphasize-lines: 2,3
114114
115-
PYBIND11_MODULE(example, m) {
115+
PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
116116
py::class_<Animal, PyAnimal /* <--- trampoline */, py::smart_holder>(m, "Animal")
117117
.def(py::init<>())
118118
.def("go", &Animal::go);
@@ -262,13 +262,13 @@ override the ``name()`` method):
262262

263263
.. code-block:: cpp
264264
265-
class PyAnimal : public Animal, py::trampoline_self_life_support {
265+
class PyAnimal : public Animal, public py::trampoline_self_life_support {
266266
public:
267267
using Animal::Animal; // Inherit constructors
268268
std::string go(int n_times) override { PYBIND11_OVERRIDE_PURE(std::string, Animal, go, n_times); }
269269
std::string name() override { PYBIND11_OVERRIDE(std::string, Animal, name, ); }
270270
};
271-
class PyDog : public Dog, py::trampoline_self_life_support {
271+
class PyDog : public Dog, public py::trampoline_self_life_support {
272272
public:
273273
using Dog::Dog; // Inherit constructors
274274
std::string go(int n_times) override { PYBIND11_OVERRIDE(std::string, Dog, go, n_times); }
@@ -290,7 +290,7 @@ declare or override any virtual methods itself:
290290
.. code-block:: cpp
291291
292292
class Husky : public Dog {};
293-
class PyHusky : public Husky, py::trampoline_self_life_support {
293+
class PyHusky : public Husky, public py::trampoline_self_life_support {
294294
public:
295295
using Husky::Husky; // Inherit constructors
296296
std::string go(int n_times) override { PYBIND11_OVERRIDE_PURE(std::string, Husky, go, n_times); }
@@ -306,14 +306,14 @@ follows:
306306
.. code-block:: cpp
307307
308308
template <class AnimalBase = Animal>
309-
class PyAnimal : public AnimalBase, py::trampoline_self_life_support {
309+
class PyAnimal : public AnimalBase, public py::trampoline_self_life_support {
310310
public:
311311
using AnimalBase::AnimalBase; // Inherit constructors
312312
std::string go(int n_times) override { PYBIND11_OVERRIDE_PURE(std::string, AnimalBase, go, n_times); }
313313
std::string name() override { PYBIND11_OVERRIDE(std::string, AnimalBase, name, ); }
314314
};
315315
template <class DogBase = Dog>
316-
class PyDog : public PyAnimal<DogBase>, py::trampoline_self_life_support {
316+
class PyDog : public PyAnimal<DogBase>, public py::trampoline_self_life_support {
317317
public:
318318
using PyAnimal<DogBase>::PyAnimal; // Inherit constructors
319319
// Override PyAnimal's pure virtual go() with a non-pure one:
@@ -564,7 +564,7 @@ an alias:
564564
// ...
565565
virtual ~Example() = default;
566566
};
567-
class PyExample : public Example, py::trampoline_self_life_support {
567+
class PyExample : public Example, public py::trampoline_self_life_support {
568568
public:
569569
using Example::Example;
570570
PyExample(Example &&base) : Example(std::move(base)) {}
@@ -774,7 +774,7 @@ to Python.
774774
775775
#include <pybind11/operators.h>
776776
777-
PYBIND11_MODULE(example, m) {
777+
PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
778778
py::class_<Vector2>(m, "Vector2")
779779
.def(py::init<float, float>())
780780
.def(py::self + py::self)
@@ -1170,7 +1170,7 @@ described trampoline:
11701170
virtual int foo() const { return 42; }
11711171
};
11721172
1173-
class Trampoline : public A, py::trampoline_self_life_support {
1173+
class Trampoline : public A, public py::trampoline_self_life_support {
11741174
public:
11751175
int foo() const override { PYBIND11_OVERRIDE(int, A, foo, ); }
11761176
};

docs/advanced/misc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ could be realized as follows (important changes highlighted):
8080
.. code-block:: cpp
8181
:emphasize-lines: 8,30,31
8282
83-
class PyAnimal : public Animal, py::trampoline_self_life_support {
83+
class PyAnimal : public Animal, public py::trampoline_self_life_support {
8484
public:
8585
/* Inherit the constructors */
8686
using Animal::Animal;

docs/advanced/pycpp/numpy.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ buffer objects (e.g. a NumPy matrix).
8888
py::buffer_info info = b.request();
8989
9090
/* Some basic validation checks ... */
91-
if (info.format != py::format_descriptor<Scalar>::format())
91+
if (!info.item_type_is_equivalent_to<Scalar>())
9292
throw std::runtime_error("Incompatible format: expected a double array!");
9393
9494
if (info.ndim != 2)
@@ -217,7 +217,7 @@ expects the type followed by field names:
217217
};
218218
219219
// ...
220-
PYBIND11_MODULE(test, m) {
220+
PYBIND11_MODULE(test, m, py::mod_gil_not_used()) {
221221
// ...
222222
223223
PYBIND11_NUMPY_DTYPE(A, x, y);
@@ -351,7 +351,7 @@ simply using ``vectorize``).
351351
return result;
352352
}
353353
354-
PYBIND11_MODULE(test, m) {
354+
PYBIND11_MODULE(test, m, py::mod_gil_not_used()) {
355355
m.def("add_arrays", &add_arrays, "Add two NumPy arrays");
356356
}
357357

docs/basics.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ a file named :file:`example.cpp` with the following contents:
112112
return i + j;
113113
}
114114
115-
PYBIND11_MODULE(example, m) {
115+
PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
116116
m.doc() = "pybind11 example plugin"; // optional module docstring
117117
118118
m.def("add", &add, "A function that adds two numbers");
@@ -288,7 +288,7 @@ converted using the function ``py::cast``.
288288

289289
.. code-block:: cpp
290290
291-
PYBIND11_MODULE(example, m) {
291+
PYBIND11_MODULE(example, m, py::mod_gil_not_used()) {
292292
m.attr("the_answer") = 42;
293293
py::object world = py::cast("World");
294294
m.attr("what") = world;

0 commit comments

Comments
 (0)