Skip to content

Commit 03d409b

Browse files
committed
Merge branch 'master' into sh_merge_master
2 parents b08b849 + 14976c8 commit 03d409b

File tree

10 files changed

+334
-72
lines changed

10 files changed

+334
-72
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,24 @@ jobs:
145145
if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10-dev'))"
146146
run: cmake --build build2 --target cpptest
147147

148+
# Third build - C++17 mode with unstable ABI
149+
- name: Configure (unstable ABI)
150+
run: >
151+
cmake -S . -B build3
152+
-DPYBIND11_WERROR=ON
153+
-DDOWNLOAD_CATCH=ON
154+
-DDOWNLOAD_EIGEN=ON
155+
-DCMAKE_CXX_STANDARD=17
156+
-DPYBIND11_INTERNALS_VERSION=10000000
157+
"-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp"
158+
${{ matrix.args }}
159+
160+
- name: Build (unstable ABI)
161+
run: cmake --build build3 -j 2
162+
163+
- name: Python tests (unstable ABI)
164+
run: cmake --build build3 --target pytest
165+
148166
- name: Interface test
149167
run: cmake --build build2 --target test_cmake_build
150168

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ repos:
3232
exclude: ^noxfile.py$
3333

3434
- repo: https://github.com/asottile/pyupgrade
35-
rev: v2.25.0
35+
rev: v2.26.0
3636
hooks:
3737
- id: pyupgrade
3838

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ endif()
8989
option(PYBIND11_INSTALL "Install pybind11 header files?" ${PYBIND11_MASTER_PROJECT})
9090
option(PYBIND11_TEST "Build pybind11 test suite?" ${PYBIND11_MASTER_PROJECT})
9191
option(PYBIND11_NOPYTHON "Disable search for Python" OFF)
92+
set(PYBIND11_INTERNALS_VERSION
93+
""
94+
CACHE STRING "Override the ABI version, may be used to enable the unstable ABI.")
9295

9396
cmake_dependent_option(
9497
USE_PYTHON_INCLUDE_DIR
@@ -189,6 +192,10 @@ if(NOT TARGET pybind11_headers)
189192

190193
target_compile_features(pybind11_headers INTERFACE cxx_inheriting_constructors cxx_user_literals
191194
cxx_right_angle_brackets)
195+
if(NOT "${PYBIND11_INTERNALS_VERSION}" STREQUAL "")
196+
target_compile_definitions(
197+
pybind11_headers INTERFACE "PYBIND11_INTERNALS_VERSION=${PYBIND11_INTERNALS_VERSION}")
198+
endif()
192199
else()
193200
# It is invalid to install a target twice, too.
194201
set(PYBIND11_INSTALL OFF)

docs/advanced/pycpp/numpy.rst

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,31 @@ template parameter, and it ensures that non-conforming arguments are converted
171171
into an array satisfying the specified requirements instead of trying the next
172172
function overload.
173173

174+
There are several methods on arrays; the methods listed below under references
175+
work, as well as the following functions based on the NumPy API:
176+
177+
- ``.dtype()`` returns the type of the contained values.
178+
179+
- ``.strides()`` returns a pointer to the strides of the array (optionally pass
180+
an integer axis to get a number).
181+
182+
- ``.flags()`` returns the flag settings. ``.writable()`` and ``.owndata()``
183+
are directly available.
184+
185+
- ``.offset_at()`` returns the offset (optionally pass indices).
186+
187+
- ``.squeeze()`` returns a view with length-1 axes removed.
188+
189+
- ``.view(dtype)`` returns a view of the array with a different dtype.
190+
191+
- ``.reshape({i, j, ...})`` returns a view of the array with a different shape.
192+
``.resize({...})`` is also available.
193+
194+
- ``.index_at(i, j, ...)`` gets the count from the beginning to a given index.
195+
196+
197+
There are also several methods for getting references (described below).
198+
174199
Structured types
175200
================
176201

@@ -345,21 +370,21 @@ The returned proxy object supports some of the same methods as ``py::array`` so
345370
that it can be used as a drop-in replacement for some existing, index-checked
346371
uses of ``py::array``:
347372

348-
- ``r.ndim()`` returns the number of dimensions
373+
- ``.ndim()`` returns the number of dimensions
349374

350-
- ``r.data(1, 2, ...)`` and ``r.mutable_data(1, 2, ...)``` returns a pointer to
375+
- ``.data(1, 2, ...)`` and ``r.mutable_data(1, 2, ...)``` returns a pointer to
351376
the ``const T`` or ``T`` data, respectively, at the given indices. The
352377
latter is only available to proxies obtained via ``a.mutable_unchecked()``.
353378

354-
- ``itemsize()`` returns the size of an item in bytes, i.e. ``sizeof(T)``.
379+
- ``.itemsize()`` returns the size of an item in bytes, i.e. ``sizeof(T)``.
355380

356-
- ``ndim()`` returns the number of dimensions.
381+
- ``.ndim()`` returns the number of dimensions.
357382

358-
- ``shape(n)`` returns the size of dimension ``n``
383+
- ``.shape(n)`` returns the size of dimension ``n``
359384

360-
- ``size()`` returns the total number of elements (i.e. the product of the shapes).
385+
- ``.size()`` returns the total number of elements (i.e. the product of the shapes).
361386

362-
- ``nbytes()`` returns the number of bytes used by the referenced elements
387+
- ``.nbytes()`` returns the number of bytes used by the referenced elements
363388
(i.e. ``itemsize()`` times ``size()``).
364389

365390
.. seealso::

docs/changelog.rst

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,127 @@ Starting with version 1.8.0, pybind11 releases use a `semantic versioning
99
v2.8.0 (WIP)
1010
------------
1111

12+
New features:
13+
14+
* Added ``py::raise_from`` to enable chaining exceptions.
15+
`#3215 <https://github.com/pybind/pybind11/pull/3215>`_
16+
1217
* Allow exception translators to be optionally registered local to a module
1318
instead of applying globally across all pybind11 modules. Use
1419
``register_local_exception_translator(ExceptionTranslator&& translator)``
1520
instead of ``register_exception_translator(ExceptionTranslator&&
1621
translator)`` to keep your exception remapping code local to the module.
1722
`#2650 <https://github.com/pybind/pybind11/pull/2650>`_
1823

24+
* Add ``make_simple_namespace`` function for instantiating Python
25+
``SimpleNamespace`` objects.
26+
`#2840 <https://github.com/pybind/pybind11/pull/2840>`_
27+
28+
* ``pybind11::scoped_interpreter`` and ``initialize_interpreter`` have new
29+
arguments to allow ``sys.argv`` initialization.
30+
`#2341 <https://github.com/pybind/pybind11/pull/2341>`_
31+
32+
* Allow Python builtins to be used as callbacks in CPython.
33+
`#1413 <https://github.com/pybind/pybind11/pull/1413>`_
34+
35+
* Added ``view`` to view arrays with a different datatype.
36+
`#987 <https://github.com/pybind/pybind11/pull/987>`_
37+
38+
* Implemented ``reshape`` on arrays.
39+
`#984 <https://github.com/pybind/pybind11/pull/984>`_
40+
41+
42+
Changes:
43+
44+
* Set ``__file__`` constant when running ``eval_file`` in an embedded interpreter.
45+
`#3233 <https://github.com/pybind/pybind11/pull/3233>`_
46+
47+
* The pybind11 proxy types ``str``, ``bytes``, ``bytearray``, ``tuple``,
48+
``list`` now consistently support passing ``ssize_t`` values for sizes and
49+
indexes. Previously, only ``size_t`` was accepted in several interfaces.
50+
`#3219 <https://github.com/pybind/pybind11/pull/3219>`_
51+
52+
53+
Fixes:
54+
55+
* Bug fix: enum value's ``__int__`` returning non-int when underlying type is bool or of char type.
56+
`#1334 <https://github.com/pybind/pybind11/pull/1334>`_
57+
58+
* Fixes bug in setting error state in Capsule's pointer methods.
59+
`#3261 <https://github.com/pybind/pybind11/pull/3261>`_
60+
61+
* A long-standing memory leak in ``py::cpp_function::initialize`` was fixed.
62+
`#3229 <https://github.com/pybind/pybind11/pull/3229>`_
63+
64+
* Fixes thread safety for some ``pybind11::type_caster`` which require lifetime extension, such as for ``std::string_view``.
65+
`#3237 <https://github.com/pybind/pybind11/pull/3237>`_
66+
67+
* Restore compatibility with gcc 4.8.4 as distributed by ubuntu-trusty, linuxmint-17.
68+
`#3270 <https://github.com/pybind/pybind11/pull/3270>`_
69+
70+
71+
Build system improvements:
72+
73+
* Fix regression in CMake Python package config: improper use of absolute path.
74+
`#3144 <https://github.com/pybind/pybind11/pull/3144>`_
75+
76+
* Specified UTF8-encoding in setup.py calls of open().
77+
`#3137 <https://github.com/pybind/pybind11/pull/3137>`_
78+
79+
80+
Backend and tidying up:
81+
82+
* Optimize NumPy array construction with additional moves.
83+
`#3183 <https://github.com/pybind/pybind11/pull/3183>`_
84+
85+
* Conversion to ``std::string`` and ``std::string_view`` now avoids making an
86+
extra copy of the data on Python >= 3.3.
87+
`#3257 <https://github.com/pybind/pybind11/pull/3257>`_
88+
89+
* Remove const modifier from certain C++ methods on Python collections
90+
(``list``, ``set``, ``dict``) such as (``clear()``, ``append()``,
91+
``insert()``, etc...) and annotated them with ``py-non-const``.
92+
93+
* Enable readability ``clang-tidy-const-return`` and remove useless consts.
94+
`#3254 <https://github.com/pybind/pybind11/pull/3254>`_
95+
`#3194 <https://github.com/pybind/pybind11/pull/3194>`_
96+
97+
* The clang-tidy ``google-explicit-constructor`` option was enabled.
98+
`#3250 <https://github.com/pybind/pybind11/pull/3250>`_
99+
100+
* Mark a pytype move constructor as noexcept (perf).
101+
`#3236 <https://github.com/pybind/pybind11/pull/3236>`_
102+
103+
* Enable clang-tidy check to guard against inheritance slicing.
104+
`#3210 <https://github.com/pybind/pybind11/pull/3210>`_
105+
106+
* Legacy warning suppression pragma were removed from eigen.h. On Unix
107+
platforms, please use -isystem for Eigen include directories, to suppress
108+
compiler warnings originating from Eigen headers. Note that CMake does this
109+
by default. No adjustments are needed for Windows.
110+
`#3198 <https://github.com/pybind/pybind11/pull/3198>`_
111+
112+
* Format pybind11 with isort consistent ordering of imports
113+
`#3195 <https://github.com/pybind/pybind11/pull/3195>`_
114+
115+
* The warnings-suppression "pragma clamp" at the top/bottom of pybind11 was
116+
removed, clearing the path to refactoring and IWYU cleanup.
117+
`#3186 <https://github.com/pybind/pybind11/pull/3186>`_
118+
119+
* Enable most bugprone checks in clang-tidy and fix the found potential bugs
120+
and poor coding styles.
121+
`#3166 <https://github.com/pybind/pybind11/pull/3166>`_
122+
123+
* Add ``clang-tidy-readability`` rules to make boolean casts explicit improving
124+
code readability. Also enabled other misc and readability clang-tidy checks.
125+
`#3148 <https://github.com/pybind/pybind11/pull/3148>`_
126+
127+
* Move object in ``.pop()`` for list.
128+
`#3116 <https://github.com/pybind/pybind11/pull/3116>`_
129+
130+
131+
132+
19133
v2.7.1 (Aug 3, 2021)
20134
---------------------
21135

0 commit comments

Comments
 (0)