Skip to content

Commit 25aaddf

Browse files
committed
Merge remote-tracking branch 'origin/master' into henryiii/ci/android
2 parents c137b4f + cc69a37 commit 25aaddf

23 files changed

+555
-167
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
python-version: '3.10'
137137
cmake-args: -DPYBIND11_TEST_SMART_HOLDER=ON -DCMAKE_CXX_FLAGS="/GR /EHsc"
138138
- runs-on: windows-2022
139-
python-version: '3.13.3'
139+
python-version: '3.13'
140140
cmake-args: -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL
141141
- runs-on: windows-latest
142142
python-version: '3.13t'
@@ -850,7 +850,7 @@ jobs:
850850
args: -DCMAKE_CXX_STANDARD=17
851851
- python: '3.10'
852852
args: -DCMAKE_CXX_STANDARD=20
853-
- python: '3.13.3'
853+
- python: '3.13'
854854

855855

856856
name: "🐍 ${{ matrix.python }} • MSVC 2022 • x86 ${{ matrix.args }}"
@@ -864,6 +864,9 @@ jobs:
864864
with:
865865
python-version: ${{ matrix.python }}
866866
architecture: x86
867+
# Python 3.13.4 broken on Windows
868+
check-latest: >-
869+
${{ matrix.python == '3.13' && runner.os == 'Windows' }}
867870
868871
- name: Update CMake
869872
uses: jwlawson/actions-setup-cmake@v2.0

.github/workflows/reusable-standard.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
with:
3838
python-version: ${{ inputs.python-version }}
3939
allow-prereleases: true
40+
# Python 3.13.4 broken on Windows
41+
check-latest: >-
42+
${{ inputs.python-version == '3.13' && runner.os == 'Windows' }}
4043
4144
- name: Setup Boost (Linux)
4245
if: runner.os == 'Linux'

.pre-commit-config.yaml

Lines changed: 5 additions & 5 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.7"
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.2
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.16.1"
4444
hooks:
4545
- id: mypy
4646
args: []
@@ -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

README.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
**pybind11 (v3) — Seamless interoperability between C++ and Python**
55

6-
|Latest Documentation Status| |Stable Documentation Status| |Gitter chat| |GitHub Discussions| |CI| |Build status|
6+
|Latest Documentation Status| |Stable Documentation Status| |Gitter chat| |GitHub Discussions|
7+
8+
|CI| |Build status| |SPEC 4 — Using and Creating Nightly Wheels|
79

810
|Repology| |PyPI package| |Conda-forge| |Python Versions|
911

@@ -210,3 +212,5 @@ to the terms and conditions of this license.
210212
:target: https://pypi.org/project/pybind11/
211213
.. |GitHub Discussions| image:: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github
212214
:target: https://github.com/pybind/pybind11/discussions
215+
.. |SPEC 4 — Using and Creating Nightly Wheels| image:: https://img.shields.io/badge/SPEC-4-green?labelColor=%23004811&color=%235CA038
216+
:target: https://scientific-python.org/specs/spec-0004/

docs/advanced/pycpp/numpy.rst

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,46 @@ prevent many types of unsupported structures, it is still the user's
232232
responsibility to use only "plain" structures that can be safely manipulated as
233233
raw memory without violating invariants.
234234

235+
Scalar types
236+
============
237+
238+
In some cases we may want to accept or return NumPy scalar values such as
239+
``np.float32`` or ``np.float64``. We hope to be able to handle single-precision
240+
and double-precision on the C-side. However, both are bound to Python's
241+
double-precision builtin float by default, so they cannot be processed separately.
242+
We used the ``py::buffer`` trick to implement the previous approach, which
243+
will cause the readability of the code to drop significantly.
244+
245+
Luckily, there's a helper type for this occasion - ``py::numpy_scalar``:
246+
247+
.. code-block:: cpp
248+
249+
m.def("add", [](py::numpy_scalar<float> a, py::numpy_scalar<float> b) {
250+
return py::make_scalar(a + b);
251+
});
252+
m.def("add", [](py::numpy_scalar<double> a, py::numpy_scalar<double> b) {
253+
return py::make_scalar(a + b);
254+
});
255+
256+
This type is trivially convertible to and from the type it wraps; currently
257+
supported scalar types are NumPy arithmetic types: ``bool_``, ``int8``,
258+
``int16``, ``int32``, ``int64``, ``uint8``, ``uint16``, ``uint32``,
259+
``uint64``, ``float32``, ``float64``, ``complex64``, ``complex128``, all of
260+
them mapping to respective C++ counterparts.
261+
262+
.. note::
263+
264+
``py::numpy_scalar<T>`` strictly matches NumPy scalar types. For example,
265+
``py::numpy_scalar<int64_t>`` will accept ``np.int64(123)``,
266+
but **not** a regular Python ``int`` like ``123``.
267+
268+
.. note::
269+
270+
Native C types are mapped to NumPy types in a platform specific way: for
271+
instance, ``char`` may be mapped to either ``np.int8`` or ``np.uint8``
272+
and ``long`` may use 4 or 8 bytes depending on the platform. Unless you
273+
clearly understand the difference and your needs, please use ``<cstdint>``.
274+
235275
Vectorizing functions
236276
=====================
237277

docs/changelog.md

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@ versioning](http://semver.org) policy.
1212
Changes will be added here periodically from the "Suggested changelog
1313
entry" block in pull request descriptions.
1414

15-
## 3.0.0 (RC 3) (June 4, 2025)
16-
17-
Since this is a large release, we are providing a release candidate to give
18-
projects time to test! We also now provide
19-
[SPEC 4](https://scientific-python.org/specs/spec-0004/) nightly wheels. We
20-
are hoping to split up `std.h`; that work is approved to be added during the
21-
RC phase if it's ready in time. We expect the RC phase to last around a week.
15+
## Version 3.0.0 (July 10, 2025)
2216

2317
Pybind11 3.0 includes an ABI bump, the first required bump in many years
2418
on Unix (Windows has had required bumps more often). This release contains
@@ -42,6 +36,18 @@ New Features:
4236
trampoline objects, and `std::enable_shared_from_this`.
4337
[#5542](https://github.com/pybind/pybind11/pull/5542)
4438

39+
- Added support for `std::shared_ptr<const T>` in `py::init()` when using
40+
`py::smart_holder`, complementing existing support for
41+
`std::unique_ptr<const T>`.
42+
[#5731](https://github.com/pybind/pybind11/pull/5731)
43+
44+
- Support const-only smart pointers.
45+
[#5718](https://github.com/pybind/pybind11/pull/5718)
46+
47+
- Eliminate cross-DSO RTTI reliance from `trampoline_self_life_support` functionality, `smart_holder` deleter detection, and other
48+
`smart_holder` bookkeeping. Resolves platform-specific issues on macOS related to cross-DSO `dynamic_cast` and `typeid` mismatches.
49+
[#5728](https://github.com/pybind/pybind11/pull/5728) (replaces [#5700](https://github.com/pybind/pybind11/pull/5700))
50+
4551
- Changed `PYBIND11_MODULE` macro implementation to perform multi-phase
4652
module initialization (PEP 489) behind the scenes.
4753
[#5574](https://github.com/pybind/pybind11/pull/5574) and avoid destruction
@@ -64,6 +70,9 @@ New Features:
6470
- Modify internals pointer-to-pointer implementation to not use `thread_local` (better iOS support).
6571
[#5709](https://github.com/pybind/pybind11/pull/5709)
6672

73+
- Support implementations without subinterpreter support.
74+
[#5732](https://github.com/pybind/pybind11/pull/5732)
75+
6776
- Changed `PYBIND11_EMBEDDED_MODULE` macro implementation to perform
6877
multi-phase module initialization (PEP 489) behind the scenes and to
6978
support `py::mod_gil_not_used()`,
@@ -85,6 +94,9 @@ New Features:
8594
- Fix signature for functions with a `native_enum` in the signature.
8695
[#5619](https://github.com/pybind/pybind11/pull/5619)
8796

97+
- Support `py::numpy_scalar<>` / `py::make_scalar()` for NumPy types.
98+
[#5726](https://github.com/pybind/pybind11/pull/5726)
99+
88100
- A `py::release_gil_before_calling_cpp_dtor` option (for `py::class_`)
89101
was added to resolve the long-standing issue \#1446.
90102
[#5522](https://github.com/pybind/pybind11/pull/5522)
@@ -111,8 +123,10 @@ New Features:
111123

112124
- `pybind11/conduit/pybind11_platform_abi_id.h` was factored out, to
113125
maximize reusability of `PYBIND11_PLATFORM_ABI_ID` (for other
114-
Python/C++ binding systems).
115-
[#5375](https://github.com/pybind/pybind11/pull/5375)
126+
Python/C++ binding systems). Separately, a note was added to explain
127+
that the conduit feature only covers from-Python-to-C++ conversions.
128+
[#5375](https://github.com/pybind/pybind11/pull/5375) \|
129+
[#5740](https://github.com/pybind/pybind11/pull/5740)
116130

117131
- Added support for finding pybind11 using pkgconf distributed on pypi.
118132
[#5552](https://github.com/pybind/pybind11/pull/5552)
@@ -124,7 +138,7 @@ New Features:
124138
update example for `pybind11::custom_type_setup` in documentation.
125139
[#5669](https://github.com/pybind/pybind11/pull/5669)
126140

127-
* Added `py::scoped_critical_section` to support free-threaded mode.
141+
- Added `py::scoped_critical_section` to support free-threaded mode.
128142
[#5684](https://github.com/pybind/pybind11/pull/5684) \|
129143
[#5706](https://github.com/pybind/pybind11/pull/5706)
130144

@@ -216,12 +230,6 @@ Bug fixes:
216230
[#5381](https://github.com/pybind/pybind11/pull/5381)
217231
- Disable false-positive GCC 12 Bound Check warning.
218232
[#5355](https://github.com/pybind/pybind11/pull/5355)
219-
- fix: using `__cpp_nontype_template_args` instead of
220-
`__cpp_nontype_template_parameter_class`.
221-
[#5330](https://github.com/pybind/pybind11/pull/5330)
222-
- Properly translate C++ exception to Python exception when creating
223-
Python buffer from wrapped object.
224-
[#5324](https://github.com/pybind/pybind11/pull/5324)
225233
- Update the dict when restoring pickles, instead of assigning a
226234
replacement dict.
227235
[#5658](https://github.com/pybind/pybind11/pull/5658)
@@ -232,8 +240,6 @@ Bug fixes:
232240
- Change the behavior of the default constructor of `py::slice` to be
233241
equivalent to `::` in Python.
234242
[#5620](https://github.com/pybind/pybind11/pull/5620)
235-
- Expose required symbol when using clang.
236-
[#5700](https://github.com/pybind/pybind11/pull/5700)
237243

238244
Bug fixes and features (CMake):
239245

@@ -254,10 +260,9 @@ Bug fixes and features (CMake):
254260
- Add support for running pybind11's tests via presets in CMake 3.25+.
255261
[#5655](https://github.com/pybind/pybind11/pull/5655) and support `--fresh`.
256262
[#5668](https://github.com/pybind/pybind11/pull/5668)
257-
- Restructure venv support to support `--fresh`, make in build folder.
258-
[#5668](https://github.com/pybind/pybind11/pull/5668)
259-
260-
* Presets now generate `compile_commands.json`.
263+
- Experimental CMake support for Android.
264+
[#5733](https://github.com/pybind/pybind11/pull/5733)
265+
- Presets now generate `compile_commands.json`.
261266
[#5685](https://github.com/pybind/pybind11/pull/5685)
262267

263268
Bug fixes (free-threading):
@@ -282,7 +287,7 @@ Internals:
282287
that it can easily be reused.
283288
[#5614](https://github.com/pybind/pybind11/pull/5614)
284289

285-
* Use CPython macros to construct `PYBIND11_VERSION_HEX`.
290+
- Use CPython macros to construct `PYBIND11_VERSION_HEX`.
286291
[#5683](https://github.com/pybind/pybind11/pull/5683)
287292

288293
Documentation:
@@ -293,10 +298,6 @@ Documentation:
293298
- A new "Double locking, deadlocking, GIL" document was added.
294299
[#5394](https://github.com/pybind/pybind11/pull/5394)
295300

296-
- Adds an answer (FAQ) for "What is a highly conclusive and simple way
297-
to find memory leaks?".
298-
[#5340](https://github.com/pybind/pybind11/pull/5340)
299-
300301
- Add documenting for free-threading and subinterpreters.
301302
[#5659](https://github.com/pybind/pybind11/pull/5659)
302303

@@ -309,20 +310,20 @@ Tests:
309310
compiling using `clang` on Linux with the `-funsigned-char` flag.
310311
[#5545](https://github.com/pybind/pybind11/pull/5545)
311312

312-
- Test PyPy3.11 in CI.
313-
[#5534](https://github.com/pybind/pybind11/pull/5534)
314-
315313
- CI testing now includes
316314
`-Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls`
317315
in some jobs.
318316
[#5523](https://github.com/pybind/pybind11/pull/5523)
319317

320-
* Add nightly wheels to scientific-python's nightly wheelhouse.
318+
- Add nightly wheels to scientific-python's nightly wheelhouse.
321319
[#5675](https://github.com/pybind/pybind11/pull/5675)
322320

323-
* Expect free-threaded warning when loading a non-free-threaded module.
321+
- Expect free-threaded warning when loading a non-free-threaded module.
324322
[#5680](https://github.com/pybind/pybind11/pull/5680)
325323

324+
- Run pytest under Python devmode.
325+
[#5715](https://github.com/pybind/pybind11/pull/5715)
326+
326327
New and removed platforms:
327328

328329
- Support Python 3.14 (beta 1+).
@@ -337,15 +338,18 @@ New and removed platforms:
337338

338339
- Support for PyPy 3.11 added.
339340
[#5508](https://github.com/pybind/pybind11/pull/5508)
341+
And test in ci.
342+
[#5534](https://github.com/pybind/pybind11/pull/5534)
340343

341344
- Support for PyPy 3.8 and 3.9 was dropped.
342345
[#5578](https://github.com/pybind/pybind11/pull/5578)
343346

344347
- Support for Python 3.7 was removed. (Official end-of-life:
345-
2023-06-27). [#5191](https://github.com/pybind/pybind11/pull/5191)
348+
2023-06-27).
349+
[#5191](https://github.com/pybind/pybind11/pull/5191)
346350

347351
- Support for CMake older than 3.15 removed. CMake 3.15-4.0 supported.
348-
[#5304](https://github.com/pybind/pybind11/pull/5304) and fix regression [#5688](https://github.com/pybind/pybind11/pull/5688).
352+
[#5304](https://github.com/pybind/pybind11/pull/5304) and fix regression [#5691](https://github.com/pybind/pybind11/pull/5691).
349353

350354
- Use scikit-build-core for the build backend for the PyPI `pybind11`.
351355
The CMake generation has been moved to the sdist-\>wheel step.
@@ -362,7 +366,6 @@ New and removed platforms:
362366
- Support Windows C++20 and Linux C++23 in tests.
363367
[#5707](https://github.com/pybind/pybind11/pull/5707)
364368

365-
366369
## Version 2.13.6 (September 13, 2024)
367370

368371
New Features:

docs/release.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ If you don't have nox, you should either use ``pipx run nox`` instead, or use
5050
- Add a release branch if this is a new MINOR version, or update the existing
5151
release branch if it is a patch version
5252

53-
- New branch: ``git checkout -b vX.Y``, ``git push -u origin vX.Y``
53+
- NOTE: This documentation assumes your ``upstream`` is ``https://github.com/pybind/pybind11.git``
54+
55+
- New branch: ``git checkout -b vX.Y``, ``git push -u upstream vX.Y``
5456

5557
- Update branch: ``git checkout vX.Y``, ``git merge <release branch>``, ``git push``
5658

@@ -63,7 +65,7 @@ If you don't have nox, you should either use ``pipx run nox`` instead, or use
6365

6466
- Last-minute consistency check: same as tag?
6567

66-
- ``git push --tags``
68+
- Push the new tag: ``git push upstream vX.Y.Z``
6769

6870
- Update stable
6971

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ sphinxcontrib-serializinghtml==1.1.10
8585
# via sphinx
8686
sphinxcontrib-svg2pdfconverter==1.2.2
8787
# via -r requirements.in
88-
urllib3==2.2.2
88+
urllib3==2.5.0
8989
# via requests
9090
zipp==3.23.0
9191
# via importlib-metadata

include/pybind11/conduit/pybind11_conduit_v1.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
77
* including pybind11 versions with different PYBIND11_INTERNALS_VERSION's.
88
9+
* NOTE: The conduit feature
10+
only covers from-Python-to-C++ conversions, it
11+
does not cover from-C++-to-Python conversions.
12+
(For the latter, a different feature would have to be added.)
13+
914
The naming of the feature is a bit misleading:
1015
1116
* The feature is in no way tied to pybind11 internals.

include/pybind11/detail/common.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
/* -- start version constants -- */
2020
#define PYBIND11_VERSION_MAJOR 3
2121
#define PYBIND11_VERSION_MINOR 0
22-
#define PYBIND11_VERSION_MICRO 0
22+
#define PYBIND11_VERSION_MICRO 1
2323
// ALPHA = 0xA, BETA = 0xB, GAMMA = 0xC (release candidate), FINAL = 0xF (stable release)
2424
// - The release level is set to "alpha" for development versions.
2525
// Use 0xA0 (LEVEL=0xA, SERIAL=0) for development versions.
2626
// - For stable releases, set the serial to 0.
27-
#define PYBIND11_VERSION_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA
28-
#define PYBIND11_VERSION_RELEASE_SERIAL 3
27+
#define PYBIND11_VERSION_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA
28+
#define PYBIND11_VERSION_RELEASE_SERIAL 0
2929
// String version of (micro, release level, release serial), e.g.: 0a0, 0b1, 0rc1, 0
30-
#define PYBIND11_VERSION_PATCH 0rc3
30+
#define PYBIND11_VERSION_PATCH 1a0
3131
/* -- end version constants -- */
3232

3333
#if !defined(Py_PACK_FULL_VERSION)
@@ -490,7 +490,8 @@ PyModuleDef_Init should be treated like any other PyObject (so not shared across
490490
491491
- ``mod_gil_not_used()``
492492
- ``multiple_interpreters::per_interpreter_gil()``
493-
- ``multiple_interpreters::per_interprshareeter_gil()``
493+
- ``multiple_interpreters::shared_gil()``
494+
- ``multiple_interpreters::not_supported()``
494495
495496
.. code-block:: cpp
496497

0 commit comments

Comments
 (0)