From 133cedf7554c3b25f7fc870da122ba358ec269f2 Mon Sep 17 00:00:00 2001 From: kferjaoui Date: Thu, 23 Apr 2026 14:03:47 +0200 Subject: [PATCH] pybind: make Cluster and ClusterVector bindings module-local - 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. --- python/src/bind_Cluster.hpp | 2 +- python/src/bind_ClusterVector.hpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/python/src/bind_Cluster.hpp b/python/src/bind_Cluster.hpp index eca0881..7907cde 100644 --- a/python/src/bind_Cluster.hpp +++ b/python/src/bind_Cluster.hpp @@ -23,7 +23,7 @@ void define_Cluster(py::module &m, const std::string &typestr) { auto class_name = fmt::format("Cluster{}", typestr); py::class_>( - 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 data) { diff --git a/python/src/bind_ClusterVector.hpp b/python/src/bind_ClusterVector.hpp index 254f96a..d4cbc3f 100644 --- a/python/src/bind_ClusterVector.hpp +++ b/python/src/bind_ClusterVector.hpp @@ -31,7 +31,8 @@ void define_ClusterVector(py::module &m, const std::string &typestr) { py::class_, void>>( m, class_name.c_str(), - py::buffer_protocol()) + py::buffer_protocol(), + py::module_local()) .def(py::init()) // TODO change!!!