Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3947351

Browse filesBrowse files
authored
Merge pull request #30291 from QuLogic/pybind3
Migrate to Pybind11 v3
2 parents bc664b3 + 9f40a15 commit 3947351
Copy full SHA for 3947351

13 files changed

+197-236Lines changed: 197 additions & 236 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎ci/mypy-stubtest-allowlist.txt‎

Copy file name to clipboardExpand all lines: ci/mypy-stubtest-allowlist.txt
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ matplotlib\.ticker\.LogitLocator\.nonsingular
2929
# Stdlib/Enum considered inconsistent (no fault of ours, I don't think)
3030
matplotlib\.backend_bases\._Mode\.__new__
3131

32+
# pybind11 internals
33+
matplotlib\..*\.__pybind11_native_enum__
34+
3235
# 3.6 Pending deprecations
3336
matplotlib\.figure\.Figure\.set_constrained_layout
3437
matplotlib\.figure\.Figure\.set_constrained_layout_pads
Collapse file

‎doc/api/next_api_changes/development/31740_REC.rst‎

Copy file name to clipboardExpand all lines: doc/api/next_api_changes/development/31740_REC.rst
+2Lines changed: 2 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ bumped:
1313
+-------------+-----------------+----------------+
1414
| Contourpy | 1.0.1 | 1.2.1 |
1515
+-------------+-----------------+----------------+
16+
| Pybind11 | 2.13.2 | 3.0.0 |
17+
+-------------+-----------------+----------------+
1618

1719
This is consistent with our :ref:`min_deps_policy` and `SPEC0
1820
<https://scientific-python.org/specs/spec-0000/>`__
Collapse file

‎meson.build‎

Copy file name to clipboardExpand all lines: meson.build
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ py_mod = import('python')
4646
py3 = py_mod.find_installation(pure: false)
4747
py3_dep = py3.dependency()
4848

49-
pybind11_dep = dependency('pybind11', version: '>=2.13.2')
49+
pybind11_dep = dependency('pybind11', version: '>=3')
5050

5151
subdir('extern')
5252
subdir('src')
Collapse file

‎pyproject.toml‎

Copy file name to clipboardExpand all lines: pyproject.toml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ requires = [
5959
# meson-python 0.17.x breaks symlinks in sdists. You can remove this pin if
6060
# you really need it and aren't using an sdist.
6161
"meson-python>=0.13.2,!=0.17.*",
62-
"pybind11>=2.13.2,!=2.13.3",
62+
"pybind11>=3",
6363
# setuptools_scm 10 breaks versioning in editable installs. You can remove this pin
6464
# if you're a downstream distributor just building wheels or your equivalent.
6565
"setuptools_scm>=7,<10",
@@ -80,7 +80,7 @@ build = [
8080

8181
# Should be the same as `[build-system] requires` above.
8282
"meson-python>=0.13.1,!=0.17.*",
83-
"pybind11>=2.13.2,!=2.13.3",
83+
"pybind11>=3",
8484
"setuptools_scm>=7,<10",
8585
# Not required by us but setuptools_scm without a version, so _if_
8686
# installed, then setuptools_scm 8 requires at least this version.
Collapse file

‎src/_backend_agg_wrapper.cpp‎

Copy file name to clipboardExpand all lines: src/_backend_agg_wrapper.cpp
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#include <pybind11/pybind11.h>
22
#include <pybind11/numpy.h>
33
#include <pybind11/stl.h>
4+
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
5+
#include <pybind11/subinterpreter.h>
6+
#endif
7+
48
#include "mplutils.h"
59
#include "py_converters.h"
610
#include "_backend_agg.h"
@@ -185,9 +189,14 @@ PyRendererAgg_draw_gouraud_triangles(RendererAgg *self,
185189
self->draw_gouraud_triangles(gc, points, colors, trans);
186190
}
187191

192+
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
193+
PYBIND11_MODULE(_backend_agg, m,
194+
py::mod_gil_not_used(), py::multiple_interpreters::per_interpreter_gil())
195+
#else
188196
PYBIND11_MODULE(_backend_agg, m, py::mod_gil_not_used())
197+
#endif
189198
{
190-
py::class_<RendererAgg>(m, "RendererAgg", py::buffer_protocol())
199+
py::classh<RendererAgg>(m, "RendererAgg", py::buffer_protocol())
191200
.def(py::init<unsigned int, unsigned int, double>(),
192201
"width"_a, "height"_a, "dpi"_a)
193202

@@ -237,7 +246,7 @@ PYBIND11_MODULE(_backend_agg, m, py::mod_gil_not_used())
237246
return py::buffer_info(renderer->pixBuffer, shape, strides);
238247
});
239248

240-
py::class_<BufferRegion>(m, "BufferRegion", py::buffer_protocol())
249+
py::classh<BufferRegion>(m, "BufferRegion", py::buffer_protocol())
241250
// BufferRegion is not constructible from Python, thus no py::init is added.
242251
.def("set_x", &PyBufferRegion_set_x)
243252
.def("set_y", &PyBufferRegion_set_y)
Collapse file

‎src/_enums.h‎

Copy file name to clipboardExpand all lines: src/_enums.h
-95Lines changed: 0 additions & 95 deletions
This file was deleted.
Collapse file

‎src/_image_wrapper.cpp‎

Copy file name to clipboardExpand all lines: src/_image_wrapper.cpp
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include <pybind11/pybind11.h>
2+
#include <pybind11/native_enum.h>
23
#include <pybind11/numpy.h>
4+
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
5+
#include <pybind11/subinterpreter.h>
6+
#endif
37

48
#include <algorithm>
59

@@ -287,9 +291,14 @@ calculate_rms_and_diff(py::array_t<unsigned char> expected_image,
287291
}
288292

289293

294+
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
295+
PYBIND11_MODULE(_image, m,
296+
py::mod_gil_not_used(), py::multiple_interpreters::per_interpreter_gil())
297+
#else
290298
PYBIND11_MODULE(_image, m, py::mod_gil_not_used())
299+
#endif
291300
{
292-
py::enum_<interpolation_e>(m, "_InterpolationType")
301+
py::native_enum<interpolation_e>(m, "_InterpolationType", "enum.Enum")
293302
.value("NEAREST", NEAREST)
294303
.value("BILINEAR", BILINEAR)
295304
.value("BICUBIC", BICUBIC)
@@ -307,7 +316,8 @@ PYBIND11_MODULE(_image, m, py::mod_gil_not_used())
307316
.value("SINC", SINC)
308317
.value("LANCZOS", LANCZOS)
309318
.value("BLACKMAN", BLACKMAN)
310-
.export_values();
319+
.export_values()
320+
.finalize();
311321

312322
m.def("resample", &image_resample,
313323
"input_array"_a,
Collapse file

‎src/_path_wrapper.cpp‎

Copy file name to clipboardExpand all lines: src/_path_wrapper.cpp
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#include <pybind11/pybind11.h>
22
#include <pybind11/stl.h>
3+
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
4+
#include <pybind11/subinterpreter.h>
5+
#endif
36

47
#include <array>
58
#include <limits>
@@ -303,7 +306,12 @@ Py_is_sorted_and_has_non_nan(py::object obj)
303306
return result;
304307
}
305308

309+
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
310+
PYBIND11_MODULE(_path, m,
311+
py::mod_gil_not_used(), py::multiple_interpreters::per_interpreter_gil())
312+
#else
306313
PYBIND11_MODULE(_path, m, py::mod_gil_not_used())
314+
#endif
307315
{
308316
m.def("point_in_path", &Py_point_in_path,
309317
"x"_a, "y"_a, "radius"_a, "path"_a, "trans"_a);
Collapse file

‎src/_qhull_wrapper.cpp‎

Copy file name to clipboardExpand all lines: src/_qhull_wrapper.cpp
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88
#include <pybind11/pybind11.h>
99
#include <pybind11/numpy.h>
10+
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
11+
#include <pybind11/subinterpreter.h>
12+
#endif
1013

1114
#ifdef _MSC_VER
1215
/* The Qhull header does not declare this as extern "C", but only MSVC seems to
@@ -284,7 +287,12 @@ delaunay(const CoordArray& x, const CoordArray& y, int verbose)
284287
return delaunay_impl(npoints, x.data(), y.data(), verbose == 0);
285288
}
286289

290+
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
291+
PYBIND11_MODULE(_qhull, m,
292+
py::mod_gil_not_used(), py::multiple_interpreters::per_interpreter_gil())
293+
#else
287294
PYBIND11_MODULE(_qhull, m, py::mod_gil_not_used())
295+
#endif
288296
{
289297
m.doc() = "Computing Delaunay triangulations.\n";
290298

Collapse file

‎src/ft2font.cpp‎

Copy file name to clipboardExpand all lines: src/ft2font.cpp
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#define M_PI 3.14159265358979323846264338328
1717
#endif
1818

19-
FT_Library _ft2Library;
20-
2119
FT2Image::FT2Image(unsigned long width, unsigned long height)
2220
: m_buffer((unsigned char *)calloc(width * height, 1)), m_width(width), m_height(height)
2321
{
@@ -195,9 +193,9 @@ FT2Font::~FT2Font()
195193
close();
196194
}
197195

198-
void FT2Font::open(FT_Open_Args &open_args, FT_Long face_index)
196+
void FT2Font::open(FT_Library ft2Library, FT_Open_Args &open_args, FT_Long face_index)
199197
{
200-
FT_CHECK(FT_Open_Face, _ft2Library, &open_args, face_index, &face);
198+
FT_CHECK(FT_Open_Face, ft2Library, &open_args, face_index, &face);
201199
if (open_args.stream != nullptr) {
202200
face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
203201
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.