Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ci/mypy-stubtest-allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ matplotlib\.ticker\.LogitLocator\.nonsingular
# Stdlib/Enum considered inconsistent (no fault of ours, I don't think)
matplotlib\.backend_bases\._Mode\.__new__

# pybind11 internals
matplotlib\..*\.__pybind11_native_enum__

# 3.6 Pending deprecations
matplotlib\.figure\.Figure\.set_constrained_layout
matplotlib\.figure\.Figure\.set_constrained_layout_pads
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ py_mod = import('python')
py3 = py_mod.find_installation(pure: false)
py3_dep = py3.dependency()

pybind11_dep = dependency('pybind11', version: '>=2.13.2')
pybind11_dep = dependency('pybind11', version: '>=3')

subdir('extern')
subdir('src')
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ requires = [
# meson-python 0.17.x breaks symlinks in sdists. You can remove this pin if
# you really need it and aren't using an sdist.
"meson-python>=0.13.2,!=0.17.*",
"pybind11>=2.13.2,!=2.13.3",
"pybind11>=3",
# setuptools_scm 10 breaks versioning in editable installs. You can remove this pin
# if you're a downstream distributor just building wheels or your equivalent.
"setuptools_scm>=7,<10",
Expand All @@ -80,7 +80,7 @@ build = [

# Should be the same as `[build-system] requires` above.
"meson-python>=0.13.1,!=0.17.*",
"pybind11>=2.13.2,!=2.13.3",
"pybind11>=3",
"setuptools_scm>=7,<10",
# Not required by us but setuptools_scm without a version, so _if_
# installed, then setuptools_scm 8 requires at least this version.
Expand Down
13 changes: 11 additions & 2 deletions src/_backend_agg_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include <pybind11/stl.h>
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
#include <pybind11/subinterpreter.h>
#endif

#include "mplutils.h"
#include "py_converters.h"
#include "_backend_agg.h"
Expand Down Expand Up @@ -185,9 +189,14 @@ PyRendererAgg_draw_gouraud_triangles(RendererAgg *self,
self->draw_gouraud_triangles(gc, points, colors, trans);
}

#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
PYBIND11_MODULE(_backend_agg, m,
py::mod_gil_not_used(), py::multiple_interpreters::per_interpreter_gil())
#else
PYBIND11_MODULE(_backend_agg, m, py::mod_gil_not_used())
#endif
{
py::class_<RendererAgg>(m, "RendererAgg", py::buffer_protocol())
py::classh<RendererAgg>(m, "RendererAgg", py::buffer_protocol())
.def(py::init<unsigned int, unsigned int, double>(),
"width"_a, "height"_a, "dpi"_a)

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

py::class_<BufferRegion>(m, "BufferRegion", py::buffer_protocol())
py::classh<BufferRegion>(m, "BufferRegion", py::buffer_protocol())
// BufferRegion is not constructible from Python, thus no py::init is added.
.def("set_x", &PyBufferRegion_set_x)
.def("set_y", &PyBufferRegion_set_y)
Expand Down
95 changes: 0 additions & 95 deletions src/_enums.h

This file was deleted.

14 changes: 12 additions & 2 deletions src/_image_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <pybind11/pybind11.h>
#include <pybind11/native_enum.h>
#include <pybind11/numpy.h>
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
#include <pybind11/subinterpreter.h>
#endif

#include <algorithm>

Expand Down Expand Up @@ -287,9 +291,14 @@ calculate_rms_and_diff(py::array_t<unsigned char> expected_image,
}


#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
PYBIND11_MODULE(_image, m,
py::mod_gil_not_used(), py::multiple_interpreters::per_interpreter_gil())
#else
PYBIND11_MODULE(_image, m, py::mod_gil_not_used())
#endif
{
py::enum_<interpolation_e>(m, "_InterpolationType")
py::native_enum<interpolation_e>(m, "_InterpolationType", "enum.Enum")
.value("NEAREST", NEAREST)
.value("BILINEAR", BILINEAR)
.value("BICUBIC", BICUBIC)
Expand All @@ -307,7 +316,8 @@ PYBIND11_MODULE(_image, m, py::mod_gil_not_used())
.value("SINC", SINC)
.value("LANCZOS", LANCZOS)
.value("BLACKMAN", BLACKMAN)
.export_values();
.export_values()
.finalize();

m.def("resample", &image_resample,
"input_array"_a,
Expand Down
8 changes: 8 additions & 0 deletions src/_path_wrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
#include <pybind11/subinterpreter.h>
#endif

#include <array>
#include <limits>
Expand Down Expand Up @@ -303,7 +306,12 @@ Py_is_sorted_and_has_non_nan(py::object obj)
return result;
}

#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
PYBIND11_MODULE(_path, m,
py::mod_gil_not_used(), py::multiple_interpreters::per_interpreter_gil())
#else
PYBIND11_MODULE(_path, m, py::mod_gil_not_used())
#endif
{
m.def("point_in_path", &Py_point_in_path,
"x"_a, "y"_a, "radius"_a, "path"_a, "trans"_a);
Expand Down
8 changes: 8 additions & 0 deletions src/_qhull_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
*/
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
#include <pybind11/subinterpreter.h>
#endif

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

#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
PYBIND11_MODULE(_qhull, m,
py::mod_gil_not_used(), py::multiple_interpreters::per_interpreter_gil())
#else
PYBIND11_MODULE(_qhull, m, py::mod_gil_not_used())
#endif
{
m.doc() = "Computing Delaunay triangulations.\n";

Expand Down
6 changes: 2 additions & 4 deletions src/ft2font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#define M_PI 3.14159265358979323846264338328
#endif

FT_Library _ft2Library;

FT2Image::FT2Image(unsigned long width, unsigned long height)
: m_buffer((unsigned char *)calloc(width * height, 1)), m_width(width), m_height(height)
{
Expand Down Expand Up @@ -195,9 +193,9 @@ FT2Font::~FT2Font()
close();
}

void FT2Font::open(FT_Open_Args &open_args, FT_Long face_index)
void FT2Font::open(FT_Library ft2Library, FT_Open_Args &open_args, FT_Long face_index)
{
FT_CHECK(FT_Open_Face, _ft2Library, &open_args, face_index, &face);
FT_CHECK(FT_Open_Face, ft2Library, &open_args, face_index, &face);
if (open_args.stream != nullptr) {
face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM;
}
Expand Down
4 changes: 1 addition & 3 deletions src/ft2font.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ class FT2Image
FT2Image &operator=(const FT2Image &);
};

extern FT_Library _ft2Library;

class FT2Font
{
public:
Expand All @@ -107,7 +105,7 @@ class FT2Font

FT2Font(std::vector<FT2Font *> &fallback_list, bool warn_if_used);
virtual ~FT2Font();
void open(FT_Open_Args &open_args, FT_Long face_index);
void open(FT_Library ft2Library, FT_Open_Args &open_args, FT_Long face_index);
void close();
void clear();
void set_size(double ptsize, double dpi);
Expand Down
Loading
Loading