Skip to content

Commit d80b5a6

Browse files
Version bump pybind11 -> 3.0.2 (#1849)
* Bump Pybind11 to 3.0.2 * Use cpp_function for defining properties
1 parent d52bb8a commit d80b5a6

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

cmake/dependencies/pybind11.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ function(find_pybind11)
5151
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_FETCHEDpybind11)
5252
elseif(NOT openPMD_USE_INTERNAL_PYBIND11)
5353
if(openPMD_USE_PYTHON STREQUAL AUTO)
54-
find_package(pybind11 2.13.0 CONFIG)
54+
find_package(pybind11 3.0.0 CONFIG)
5555
elseif(openPMD_USE_PYTHON)
56-
find_package(pybind11 2.13.0 CONFIG REQUIRED)
56+
find_package(pybind11 3.0.0 CONFIG REQUIRED)
5757
endif()
5858
if(TARGET pybind11::module)
5959
message(STATUS "pybind11: Found version '${pybind11_VERSION}'")
@@ -67,18 +67,18 @@ set(openPMD_pybind11_src ""
6767
"Local path to pybind11 source directory (preferred if set)")
6868

6969
# tarball fetcher
70-
set(openPMD_pybind11_tar "https://github.com/pybind/pybind11/archive/refs/tags/v2.13.6.tar.gz"
70+
set(openPMD_pybind11_tar "https://github.com/pybind/pybind11/archive/refs/tags/v3.0.2.tar.gz"
7171
CACHE STRING
7272
"Remote tarball link to pull and build pybind11 from if(openPMD_USE_INTERNAL_PYBIND11)")
73-
set(openPMD_pybind11_tar_hash "SHA256=e08cb87f4773da97fa7b5f035de8763abc656d87d5773e62f6da0587d1f0ec20"
73+
set(openPMD_pybind11_tar_hash "SHA256=2f20a0af0b921815e0e169ea7fec63909869323581b89d7de1553468553f6a2d"
7474
CACHE STRING
7575
"Hash checksum of the tarball of pybind11 if(openPMD_USE_INTERNAL_PYBIND11)")
7676

7777
# Git fetcher
7878
set(openPMD_pybind11_repo "https://github.com/pybind/pybind11.git"
7979
CACHE STRING
8080
"Repository URI to pull and build pybind11 from if(openPMD_USE_INTERNAL_PYBIND11)")
81-
set(openPMD_pybind11_branch "v2.13.6"
81+
set(openPMD_pybind11_branch "v3.0.2"
8282
CACHE STRING
8383
"Repository branch for openPMD_pybind11_repo if(openPMD_USE_INTERNAL_PYBIND11)")
8484

src/binding/python/Iteration.cpp

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,18 +94,22 @@ void init_Iteration(py::module &m)
9494
.def("set_dt", &Iteration::setDt<double>)
9595
.def("set_time_unit_SI", &Iteration::setTimeUnitSI)
9696

97-
.def_readwrite(
97+
.def_property_readonly(
9898
"meshes",
99-
&Iteration::meshes,
100-
py::return_value_policy::copy,
101-
// garbage collection: return value must be freed before Iteration
102-
py::keep_alive<1, 0>())
103-
.def_readwrite(
99+
py::cpp_function(
100+
[](Iteration &i) { return i.meshes; },
101+
py::return_value_policy::copy,
102+
// garbage collection: return value must be freed before
103+
// Iteration
104+
py::keep_alive<1, 0>()))
105+
.def_property_readonly(
104106
"particles",
105-
&Iteration::particles,
106-
py::return_value_policy::copy,
107-
// garbage collection: return value must be freed before Iteration
108-
py::keep_alive<1, 0>());
107+
py::cpp_function(
108+
[](Iteration &i) { return i.particles; },
109+
py::return_value_policy::copy,
110+
// garbage collection: return value must be freed before
111+
// Iteration
112+
py::keep_alive<1, 0>()));
109113

110114
add_pickle(
111115
cl, [](openPMD::Series series, std::vector<std::string> const &group) {

src/binding/python/ParticleSpecies.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ void init_ParticleSpecies(py::module &m)
4848
return stream.str();
4949
})
5050

51-
.def_readwrite(
51+
.def_property_readonly(
5252
"particle_patches",
53-
&ParticleSpecies::particlePatches,
54-
py::return_value_policy::copy,
55-
// garbage collection: return value must be freed before Series
56-
py::keep_alive<1, 0>());
53+
py::cpp_function(
54+
[](ParticleSpecies &ps) { return ps.particlePatches; },
55+
py::return_value_policy::copy,
56+
// garbage collection: return value must be freed before Series
57+
py::keep_alive<1, 0>()));
5758
add_pickle(
5859
cl, [](openPMD::Series series, std::vector<std::string> const &group) {
5960
uint64_t const n_it = std::stoull(group.at(1));

src/binding/python/Series.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,13 @@ this method.
497497
.def("set_iteration_format", &Series::setIterationFormat)
498498
.def("set_name", &Series::setName)
499499

500-
.def_readwrite(
500+
.def_property_readonly(
501501
"iterations",
502-
&Series::iterations,
503-
py::return_value_policy::copy,
504-
// garbage collection: return value must be freed before Series
505-
py::keep_alive<1, 0>())
502+
py::cpp_function(
503+
[](Series &s) { return s.iterations; },
504+
py::return_value_policy::copy,
505+
// garbage collection: return value must be freed before Series
506+
py::keep_alive<1, 0>()))
506507
.def(
507508
"read_iterations",
508509
[](Series &s) {

0 commit comments

Comments
 (0)