From 6f71c403a0df287851f484141a916a805d2eb831 Mon Sep 17 00:00:00 2001 From: Marcel Martin Date: Wed, 5 Jun 2024 15:01:33 +0200 Subject: [PATCH] Make Python bindings work with nanobind 2+ Nanobind changelog (https://nanobind.readthedocs.io/en/latest/changelog.html#version-2-0-0-may-23-2024): > The nb::enum_() binding declaration is now a wrapper that creates either > a enum.Enum or enum.IntEnum-derived type. Previously, nanobind relied on a > custom enumeration base class that was a frequent source of friction for > users. > > This change may break code that casts entries to integers, which now only > works for arithmetic (enum.IntEnum-derived) enumerations. --- src/python/strobealign.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python/strobealign.cpp b/src/python/strobealign.cpp index 0d5cf4e8..3d753bb1 100644 --- a/src/python/strobealign.cpp +++ b/src/python/strobealign.cpp @@ -54,7 +54,7 @@ NB_MODULE(strobealign_extension, m_) { nb::module_ m = nb::module_::import_("strobealign"); m.doc() = "strobealign aligns short reads using dynamic seed size with strobemers"; - nb::enum_(m, "LOG_LEVELS") + nb::enum_(m, "LOG_LEVELS", nb::is_arithmetic()) .value("LOG_DEBUG", LOG_LEVELS::LOG_DEBUG) .value("LOG_INFO", LOG_LEVELS::LOG_INFO) .value("LOG_WARNING", LOG_LEVELS::LOG_WARNING)