Julien Lamy pushed to branch master at Debian Med / odil


Commits:
24d4cd41 by Julien Lamy at 2021-12-22T09:12:11+01:00
Fix building with new pybind API

- - - - -


3 changed files:

- debian/changelog
- + debian/patches/new-pybind-api.patch
- debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+odil (0.12.1-4) UNRELEASED; urgency=medium
+
+  * Backport code from upstream to adapt to new pybind API
+    (Closes: #1002134)
+
+ -- Julien Lamy <l...@unistra.fr>  Wed, 22 Dec 2021 09:11:01 +0100
+
 odil (0.12.1-3) unstable; urgency=medium
 
   * Remove network-related unit tests (Closes: #1001614)


=====================================
debian/patches/new-pybind-api.patch
=====================================
@@ -0,0 +1,72 @@
+Description: Use new Pybind API (backport from upstream)
+Author: Julien Lamy <l...@unistra.fr>
+Forwarded: not-needed
+--- a/wrappers/python/ElementsDictionary.cpp
++++ b/wrappers/python/ElementsDictionary.cpp
+@@ -54,8 +54,8 @@ void wrap_ElementsDictionary(pybind11::module & m)
+         .def_readwrite("vr", &ElementsDictionaryEntry::vr)
+         .def_readwrite("vm", &ElementsDictionaryEntry::vm)
+     ;
+-
+-    bind_map<ElementsDictionary>(m, "ElementsDictionary")
++    
++    auto ElementsDictionary_cl = bind_map<ElementsDictionary>(m, 
"ElementsDictionary")
+         .def("__getitem__",
+             [](ElementsDictionary & container, Tag const & key)
+             {
+@@ -77,10 +77,26 @@ void wrap_ElementsDictionary(pybind11::module & m)
+                 }
+                 return iterator->second;
+             }
++        );
++#if PYBIND11_VERSION_HEX >= 0x02080000    
++    // WARNING: pybind11 2.8.0 adds a fallback to __contains__ when the type
++    // of the searched item does not match the key type of the dictionary.
++    // Remove *all* __contains__ overloads and rewrap
++    delattr(ElementsDictionary_cl, "__contains__");
++    ElementsDictionary_cl
++        .def(
++            "__contains__",
++            [](ElementsDictionary & container, ElementsDictionaryKey const & 
key)
++            {
++                return container.find(key) != container.end();
++            }
+         )
++#else
++    ElementsDictionary_cl
++#endif
+         .def(
+             "__contains__",
+-            [](ElementsDictionary const & container, Tag const & key)
++            [](ElementsDictionary & container, Tag const & key)
+             {
+                 return container.find(key) != container.end();
+             }
+--- a/wrappers/python/Value.cpp
++++ b/wrappers/python/Value.cpp
+@@ -250,6 +250,7 @@ void wrap_Value(pybind11::module & m)
+         detail::vector_modifiers<Vector, Class_>(cl);
+ 
+         // vector_accessor
++        using T = typename Vector::value_type;
+         using SizeType = long; //typename Vector::size_type;
+         using ItType   = typename Vector::iterator;
+ 
+@@ -265,9 +266,14 @@ void wrap_Value(pybind11::module & m)
+         cl.def(
+             "__iter__",
+             [](Vector &v) {
+-                typedef detail::iterator_state<
+-                    ItType, ItType, false, return_value_policy::copy> state;
+-
++#if PYBIND11_VERSION_HEX < 0x02080000
++                using state = detail::iterator_state<
++                    ItType, ItType, false, return_value_policy::copy>;
++#else
++                using state = detail::iterator_state<
++                    detail::iterator_access<ItType>,
++                    return_value_policy::copy, ItType, ItType, T>;
++#endif
+                 if (!detail::get_type_info(typeid(state), false))
+                 {
+                     class_<state>(handle(), "iterator", 
pybind11::module_local())


=====================================
debian/patches/series
=====================================
@@ -3,3 +3,4 @@ remove_boost_exception.patch
 fix-interpreter-path.patch
 upgrade_cxx_standard.patch
 remove-network-unit-tests.patch
+new-pybind-api.patch



View it on GitLab: 
https://salsa.debian.org/med-team/odil/-/commit/24d4cd41fbdf07c6a97de5499d890dedeac7a8dc

-- 
View it on GitLab: 
https://salsa.debian.org/med-team/odil/-/commit/24d4cd41fbdf07c6a97de5499d890dedeac7a8dc
You're receiving this email because of your account on salsa.debian.org.


_______________________________________________
debian-med-commit mailing list
debian-med-com...@alioth-lists.debian.net
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/debian-med-commit

Reply via email to