pybind: make Cluster and ClusterVector bindings module-local
Build on RHEL8 / build (push) Successful in 2m52s
Build on RHEL9 / build (push) Successful in 3m15s
Run tests using data on local RHEL8 / build (push) Successful in 3m47s

- After upgrading to pybind11 3, duplicate registration of cluster-related
  types across `_aare` and `_aare_cuda` started failing.
- Mark the `Cluster` and `ClusterVector` bindings as `py::module_local()` so
each extension owns its local registration.

Note: cluster objects from CPU and CUDA bindings are now distinct Python types.
This commit is contained in:
kferjaoui
2026-04-23 14:03:47 +02:00
parent 7c91ce99c2
commit 133cedf755
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ void define_Cluster(py::module &m, const std::string &typestr) {
auto class_name = fmt::format("Cluster{}", typestr);
py::class_<Cluster<Type, ClusterSizeX, ClusterSizeY, CoordType>>(
m, class_name.c_str(), py::buffer_protocol())
m, class_name.c_str(), py::buffer_protocol(), py::module_local())
.def(py::init([](CoordType x, CoordType y,
py::array_t<Type, py::array::forcecast> data) {
+2 -1
View File
@@ -31,7 +31,8 @@ void define_ClusterVector(py::module &m, const std::string &typestr) {
py::class_<ClusterVector<
Cluster<Type, ClusterSizeX, ClusterSizeY, CoordType>, void>>(
m, class_name.c_str(),
py::buffer_protocol())
py::buffer_protocol(),
py::module_local())
.def(py::init()) // TODO change!!!