Skip to content

Commit 6b5674f

Browse files
authored
chore: prepare 2.12.0 (#5070)
* chore: prepare 2.12.0 Signed-off-by: Henry Schreiner <[email protected]> * docs: more info on numpy 2 Signed-off-by: Henry Schreiner <[email protected]> * docs: mention NumPy 2 in README Signed-off-by: Henry Schreiner <[email protected]> * docs: add release date Signed-off-by: Henry Schreiner <[email protected]> * docs: add 4955 Signed-off-by: Henry Schreiner <[email protected]> * Update changelog.rst * docs: address review comments Signed-off-by: Henry Schreiner <[email protected]> --------- Signed-off-by: Henry Schreiner <[email protected]>
1 parent 67c9c56 commit 6b5674f

File tree

7 files changed

+199
-18
lines changed

7 files changed

+199
-18
lines changed

README.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ with everything stripped away that isn't relevant for binding
3636
generation. Without comments, the core header files only require ~4K
3737
lines of code and depend on Python (3.6+, or PyPy) and the C++
3838
standard library. This compact implementation was possible thanks to
39-
some of the new C++11 language features (specifically: tuples, lambda
40-
functions and variadic templates). Since its creation, this library has
41-
grown beyond Boost.Python in many ways, leading to dramatically simpler
42-
binding code in many common situations.
39+
some C++11 language features (specifically: tuples, lambda functions and
40+
variadic templates). Since its creation, this library has grown beyond
41+
Boost.Python in many ways, leading to dramatically simpler binding code in many
42+
common situations.
4343

4444
Tutorial and reference documentation is provided at
4545
`pybind11.readthedocs.io <https://pybind11.readthedocs.io/en/latest>`_.
@@ -71,6 +71,7 @@ pybind11 can map the following core C++ features to Python:
7171
- Internal references with correct reference counting
7272
- C++ classes with virtual (and pure virtual) methods can be extended
7373
in Python
74+
- Integrated NumPy support (NumPy 2 requires pybind11 2.12+)
7475

7576
Goodies
7677
-------

docs/changelog.rst

+152-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,159 @@ IN DEVELOPMENT
1515

1616
Changes will be summarized here periodically.
1717

18+
Version 2.12.0 (March 27, 2025)
19+
-------------------------------
20+
21+
New Features:
22+
23+
* ``pybind11`` now supports compiling for
24+
`NumPy 2 <https://numpy.org/devdocs/numpy_2_0_migration_guide.html>`_. Most
25+
code shouldn't change (see :ref:`upgrade-guide-2.12` for details). However,
26+
if you experience issues you can define ``PYBIND11_NUMPY_1_ONLY`` to disable
27+
the new support for now, but this will be removed in the future.
28+
`#5050 <https://github.com/pybind/pybind11/pull/5050>`_
29+
30+
* ``pybind11/gil_safe_call_once.h`` was added (it needs to be included
31+
explicitly). The primary use case is GIL-safe initialization of C++
32+
``static`` variables.
33+
`#4877 <https://github.com/pybind/pybind11/pull/4877>`_
34+
35+
* Support move-only iterators in ``py::make_iterator``,
36+
``py::make_key_iterator``, ``py::make_value_iterator``.
37+
`#4834 <https://github.com/pybind/pybind11/pull/4834>`_
38+
39+
* Two simple ``py::set_error()`` functions were added and the documentation was
40+
updated accordingly. In particular, ``py::exception<>::operator()`` was
41+
deprecated (use one of the new functions instead). The documentation for
42+
``py::exception<>`` was further updated to not suggest code that may result
43+
in undefined behavior.
44+
`#4772 <https://github.com/pybind/pybind11/pull/4772>`_
45+
46+
Bug fixes:
47+
48+
* Removes potential for Undefined Behavior during process teardown.
49+
`#4897 <https://github.com/pybind/pybind11/pull/4897>`_
50+
51+
* Improve compatibility with the nvcc compiler (especially CUDA 12.1/12.2).
52+
`#4893 <https://github.com/pybind/pybind11/pull/4893>`_
53+
54+
* ``pybind11/numpy.h`` now imports NumPy's ``multiarray`` and ``_internal``
55+
submodules with paths depending on the installed version of NumPy (for
56+
compatibility with NumPy 2).
57+
`#4857 <https://github.com/pybind/pybind11/pull/4857>`_
58+
59+
* Builtins collections names in docstrings are now consistently rendered in
60+
lowercase (list, set, dict, tuple), in accordance with PEP 585.
61+
`#4833 <https://github.com/pybind/pybind11/pull/4833>`_
62+
63+
* Added ``py::typing::Iterator<T>``, ``py::typing::Iterable<T>``.
64+
`#4832 <https://github.com/pybind/pybind11/pull/4832>`_
65+
66+
* Render ``py::function`` as ``Callable`` in docstring.
67+
`#4829 <https://github.com/pybind/pybind11/pull/4829>`_
68+
69+
* Also bump ``PYBIND11_INTERNALS_VERSION`` for MSVC, which unlocks two new
70+
features without creating additional incompatibilities.
71+
`#4819 <https://github.com/pybind/pybind11/pull/4819>`_
72+
73+
* Guard against crashes/corruptions caused by modules built with different MSVC
74+
versions.
75+
`#4779 <https://github.com/pybind/pybind11/pull/4779>`_
76+
77+
* A long-standing bug in the handling of Python multiple inheritance was fixed.
78+
See PR #4762 for the rather complex details.
79+
`#4762 <https://github.com/pybind/pybind11/pull/4762>`_
80+
81+
* Fix ``bind_map`` with ``using`` declarations.
82+
`#4952 <https://github.com/pybind/pybind11/pull/4952>`_
83+
84+
* Qualify ``py::detail::concat`` usage to avoid ADL selecting one from
85+
somewhere else, such as modernjson's concat.
86+
`#4955 <https://github.com/pybind/pybind11/pull/4955>`_
87+
88+
.. fix(types)
89+
90+
* Render typed iterators for ``make_iterator``, ``make_key_iterator``,
91+
``make_value_iterator``.
92+
`#4876 <https://github.com/pybind/pybind11/pull/4876>`_
93+
94+
* Add several missing type name specializations.
95+
`#5073 <https://github.com/pybind/pybind11/pull/5073>`_
96+
97+
* Change docstring render for ``py::buffer``, ``py::sequence`` and
98+
``py::handle`` (to ``Buffer``, ``Sequence``, ``Any``).
99+
`#4831 <https://github.com/pybind/pybind11/pull/4831>`_
100+
101+
* Fixed ``base_enum.__str__`` docstring.
102+
`#4827 <https://github.com/pybind/pybind11/pull/4827>`_
103+
104+
* Enforce single line docstring signatures.
105+
`#4735 <https://github.com/pybind/pybind11/pull/4735>`_
106+
107+
* Special 'typed' wrappers now available in typing.h to annotate tuple, dict,
108+
list, set, and function.
109+
`#4259 <https://github.com/pybind/pybind11/pull/4259>`_
110+
111+
.. fix(build)
112+
113+
* Fix FindPython mode exports & avoid ``pkg_resources`` if
114+
``importlib.metadata`` available.
115+
`#4941 <https://github.com/pybind/pybind11/pull/4941>`_
116+
117+
* ``Python_ADDITIONAL_VERSIONS`` (classic search) now includes 3.12.
118+
`#4909 <https://github.com/pybind/pybind11/pull/4909>`_
119+
120+
* ``pybind11.pc`` is now relocatable by default as long as install destinations
121+
are not absolute paths.
122+
`#4830 <https://github.com/pybind/pybind11/pull/4830>`_
123+
124+
* Correctly detect CMake FindPython removal when used as a subdirectory.
125+
`#4806 <https://github.com/pybind/pybind11/pull/4806>`_
126+
127+
* Don't require the libs component on CMake 3.18+ when using
128+
PYBIND11_FINDPYTHON (fixes manylinux builds).
129+
`#4805 <https://github.com/pybind/pybind11/pull/4805>`_
130+
131+
* ``pybind11_strip`` is no longer automatically applied when
132+
``CMAKE_BUILD_TYPE`` is unset.
133+
`#4780 <https://github.com/pybind/pybind11/pull/4780>`_
134+
135+
* Support DEBUG_POSFIX correctly for debug builds.
136+
`#4761 <https://github.com/pybind/pybind11/pull/4761>`_
137+
138+
* Hardcode lto/thin lto for Emscripten cross-compiles.
139+
`#4642 <https://github.com/pybind/pybind11/pull/4642>`_
140+
141+
Documentation:
142+
143+
* Small fix to grammar in functions.rst.
144+
`#4791 <https://github.com/pybind/pybind11/pull/4791>`_
145+
146+
* Remove upper bound in example pyproject.toml for setuptools.
147+
`#4774 <https://github.com/pybind/pybind11/pull/4774>`_
148+
149+
CI:
150+
151+
* CI: Update NVHPC to 23.5 and Ubuntu 20.04.
152+
`#4764 <https://github.com/pybind/pybind11/pull/4764>`_
153+
154+
* Test on PyPy 3.10.
155+
`#4714 <https://github.com/pybind/pybind11/pull/4714>`_
156+
157+
Other:
158+
159+
* Use new PyCode API on Python 3.12+.
160+
`#4916 <https://github.com/pybind/pybind11/pull/4916>`_
161+
162+
* Use Ruff formatter instead of Black.
163+
`#4912 <https://github.com/pybind/pybind11/pull/4912>`_
164+
165+
* An ``assert()`` was added to help Coverty avoid generating a false positive.
166+
`#4817 <https://github.com/pybind/pybind11/pull/4817>`_
167+
18168

19169
Version 2.11.1 (July 17, 2023)
20-
-----------------------------
170+
------------------------------
21171

22172
Changes:
23173

@@ -32,7 +182,7 @@ Changes:
32182

33183

34184
Version 2.11.0 (July 14, 2023)
35-
-----------------------------
185+
------------------------------
36186

37187
New features:
38188

docs/release.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ If you don't have nox, you should either use ``pipx run nox`` instead, or use
3636

3737
- Run ``nox -s tests_packaging`` to ensure this was done correctly.
3838

39-
- Ensure that all the information in ``setup.cfg`` is up-to-date, like
39+
- Ensure that all the information in ``setup.cfg`` is up-to-date, like
4040
supported Python versions.
4141

42-
- Add release date in ``docs/changelog.rst`` and integrate the output of
43-
``nox -s make_changelog``.
42+
- Add release date in ``docs/changelog.rst`` and integrate the output of
43+
``nox -s make_changelog``.
4444

45-
- Note that the ``make_changelog`` command inspects
46-
`needs changelog <https://github.com/pybind/pybind11/pulls?q=is%3Apr+is%3Aclosed+label%3A%22needs+changelog%22>`_.
45+
- Note that the ``nox -s make_changelog`` command inspects
46+
`needs changelog <https://github.com/pybind/pybind11/pulls?q=is%3Apr+is%3Aclosed+label%3A%22needs+changelog%22>`_.
4747

48-
- Manually clear the ``needs changelog`` labels using the GitHub web
49-
interface (very easy: start by clicking the link above).
48+
- Manually clear the ``needs changelog`` labels using the GitHub web
49+
interface (very easy: start by clicking the link above).
5050

51-
- ``git add`` and ``git commit``, ``git push``. **Ensure CI passes**. (If it
51+
- ``git add`` and ``git commit``, ``git push``. **Ensure CI passes**. (If it
5252
fails due to a known flake issue, either ignore or restart CI.)
5353

5454
- Add a release branch if this is a new MINOR version, or update the existing

docs/upgrade.rst

+28
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,34 @@ to a new version. But it goes into more detail. This includes things like
88
deprecated APIs and their replacements, build system changes, general code
99
modernization and other useful information.
1010

11+
.. _upgrade-guide-2.12:
12+
13+
v2.12
14+
=====
15+
16+
NumPy support has been upgraded to support the 2.x series too. The two relevant
17+
changes are that:
18+
19+
* ``dtype.flags()`` is now a ``uint64`` and ``dtype.alignment()`` an
20+
``ssize_t`` (and NumPy may return an larger than integer value for
21+
``itemsize()`` in NumPy 2.x).
22+
23+
* The long deprecated NumPy function ``PyArray_GetArrayParamsFromObject``
24+
function is not available anymore.
25+
26+
Due to NumPy changes, you may experience difficulties updating to NumPy 2.
27+
Please see the [NumPy 2 migration guide](https://numpy.org/devdocs/numpy_2_0_migration_guide.html) for details.
28+
For example, a more direct change could be that the default integer ``"int_"``
29+
(and ``"uint"``) is now ``ssize_t`` and not ``long`` (affects 64bit windows).
30+
31+
If you want to only support NumPy 1.x for now and are having problems due to
32+
the two internal changes listed above, you can define
33+
``PYBIND11_NUMPY_1_ONLY`` to disable the new support for now. Make sure you
34+
define this on all pybind11 compile units, since it could be a source of ODR
35+
violations if used inconsistently. This option will be removed in the future,
36+
so adapting your code is highly recommended.
37+
38+
1139
.. _upgrade-guide-2.11:
1240

1341
v2.11

include/pybind11/detail/common.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111

1212
#define PYBIND11_VERSION_MAJOR 2
1313
#define PYBIND11_VERSION_MINOR 12
14-
#define PYBIND11_VERSION_PATCH 0.dev1
14+
#define PYBIND11_VERSION_PATCH 0
1515

1616
// Similar to Python's convention: https://docs.python.org/3/c-api/apiabiversion.html
1717
// Additional convention: 0xD = dev
18-
#define PYBIND11_VERSION_HEX 0x020C00D1
18+
#define PYBIND11_VERSION_HEX 0x020C0000
1919

2020
// Define some generic pybind11 helper macros for warning management.
2121
//

pybind11/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ def _to_int(s: str) -> Union[int, str]:
88
return s
99

1010

11-
__version__ = "2.12.0.dev1"
11+
__version__ = "2.12.0"
1212
version_info = tuple(_to_int(s) for s in __version__.split("."))

tools/make_changelog.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,11 @@
6767
for cat, msgs in cats.items():
6868
if msgs:
6969
desc = cats_descr[cat]
70-
print(f"[bold]{desc}:\n" if desc else "")
70+
print(f"[bold]{desc}:" if desc else f".. {cat}")
71+
print()
7172
for msg in msgs:
7273
print(Syntax(msg, "rst", theme="ansi_light", word_wrap=True))
74+
print()
7375
print()
7476

7577
if missing:

0 commit comments

Comments
 (0)