otio_imath.cpp fails to compile with the latest Imath/pybind11

Open Beginner friendly
#2,037 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
build-system

Research direction

Start with src/py-opentimelineio/opentimelineio-bindings/otio_imath.cpp and reproduce the reported build using current Imath and pybind11. Review the existing patch and verify that the OpenTimelineIO bindings compile successfully, including the V2d and Box2d methods shown in the issue.

Written by the indexing model from the issue text.

Description

There is a patch for 0.18.1 but it fails to apply to master due to other changes.

---errors---

[ 96%] Building CXX object src/py-opentimelineio/opentimelineio-bindings/CMakeFiles/_otio.dir/otio_tests.cpp.o
/wrkdirs/usr/ports/multimedia/py-opentimelineio/work-py312/OpenTimelineIO-0.18.1/src/py-opentimelineio/opentime-bindings/opentime_rationalTime.cpp:109:62: warning: 'is_valid_timecode_rate' is deprecated: Use is_smpte_timecode_rate() instead [-Wdeprecated-declarations]
  109 |         .def_static("is_valid_timecode_rate", &RationalTime::is_valid_timecode_rate, "rate"_a,
      |                                                              ^
/wrkdirs/usr/ports/multimedia/py-opentimelineio/work-py312/OpenTimelineIO-0.18.1/src/opentime/rationalTime.h:169:7: note: 'is_valid_timecode_rate' has been explicitly marked deprecated here
  169 |     [[deprecated("Use is_smpte_timecode_rate() instead")]]
      |       ^
/wrkdirs/usr/ports/multimedia/py-opentimelineio/work-py312/OpenTimelineIO-0.18.1/src/py-opentimelineio/opentime-bindings/opentime_rationalTime.cpp:113:67: warning: 'nearest_valid_timecode_rate' is deprecated: Use nearest_smpte_timecode_rate() instead [-Wdeprecated-declarations]
  113 |         .def_static("nearest_valid_timecode_rate", &RationalTime::nearest_valid_timecode_rate, "rate"_a,
      |                                                                   ^
/wrkdirs/usr/ports/multimedia/py-opentimelineio/work-py312/OpenTimelineIO-0.18.1/src/opentime/rationalTime.h:176:7: note: 'nearest_valid_timecode_rate' has been explicitly marked deprecated here
  176 |     [[deprecated("Use nearest_smpte_timecode_rate() instead")]]
      |       ^
2 warnings generated.
[ 98%] Linking CXX shared module _opentime.cpython-312.so
[ 98%] Built target _opentime
/wrkdirs/usr/ports/multimedia/py-opentimelineio/work-py312/OpenTimelineIO-0.18.1/src/py-opentimelineio/opentimelineio-bindings/otio_imath.cpp:79:10: error: no matching member function for call to 'def'
   30 |         .def(py::self + py::self)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~
   31 |         .def(py::self * py::self)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~
   32 |         .def(py::self / py::self)
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~
   33 |         .def("equalWithAbsError", [](IMATH_NAMESPACE::V2d* v, IMATH_NAMESPACE::V2d const & v2, double e) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   34 |                 return v->equalWithAbsError(v2, e);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   35 |             })
      |             ~~
   36 |         .def("equalWithRelError", [](IMATH_NAMESPACE::V2d* v, IMATH_NAMESPACE::V2d const & v2, double e) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   37 |                 return v->equalWithRelError(v2, e);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   38 |             })
      |             ~~
   39 |         .def("dot", [](IMATH_NAMESPACE::V2d* v, IMATH_NAMESPACE::V2d const & v2) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   40 |                 return v->dot(v2);
      |                 ~~~~~~~~~~~~~~~~~~
   41 |             })
      |             ~~
   42 |         .def("cross", [](IMATH_NAMESPACE::V2d* v, IMATH_NAMESPACE::V2d const & v2) {
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   43 |                 return v->cross(v2);
      |                 ~~~~~~~~~~~~~~~~~~~~
   44 |             })
      |             ~~
   45 |         .def("length", &IMATH_NAMESPACE::V2d::length)
      |         ~^~~
/wrkdirs/usr/ports/multimedia/py-opentimelineio/work-py312/OpenTimelineIO-0.18.1/src/deps/pybind11/include/pybind11/pybind11.h:1620:13: note: candidate template ignored: couldn't infer template argument 'Func'
 1620 |     class_ &def(const char *name_, Func &&f, const Extra &...extra) {
      |             ^
/wrkdirs/usr/ports/multimedia/py-opentimelineio/work-py312/OpenTimelineIO-0.18.1/src/deps/pybind11/include/pybind11/pybind11.h:1645:13: note: candidate template ignored: substitution failure [with T = char[7]]: deduced incomplete pack <(no value)> for template parameter 'Extra'
 1644 |     template <typename T, typename... Extra, detail::enable_if_t<T::op_enable_if_hook, int> = 0>

----patch----

$ cat files/patch-src_py-opentimelineio_opentimelineio-bindings_otio_imath.cpp 
-- Fix build with newer pybind11/Imath by avoiding member function pointer
-- bindings that trigger template deduction failures due to IMATH_HOSTDEVICE
-- attributes on the member functions.
-- Reference: local poudriere build failure for 0.18.1 on FreeBSD 15-amd64.

--- src/py-opentimelineio/opentimelineio-bindings/otio_imath.cpp.orig
+++ src/py-opentimelineio/opentimelineio-bindings/otio_imath.cpp
@@ -76,14 +76,30 @@
         .def("cross", [](IMATH_NAMESPACE::V2d* v, IMATH_NAMESPACE::V2d const & v2) {
                 return v->cross(v2);
             })
-        .def("length", &IMATH_NAMESPACE::V2d::length)
-        .def("length2", &IMATH_NAMESPACE::V2d::length2)
-        .def("normalize", &IMATH_NAMESPACE::V2d::normalize)
-        .def("normalizeExc", &IMATH_NAMESPACE::V2d::normalizeExc)
-        .def("normalizeNonNull", &IMATH_NAMESPACE::V2d::normalizeNonNull)
-        .def("normalized", &IMATH_NAMESPACE::V2d::normalized)
-        .def("normalizedExc", &IMATH_NAMESPACE::V2d::normalizedExc)
-        .def("normalizedNonNull", &IMATH_NAMESPACE::V2d::normalizedNonNull)
+        .def("length", [](IMATH_NAMESPACE::V2d const& v) {
+                return v.length();
+            })
+        .def("length2", [](IMATH_NAMESPACE::V2d const& v) {
+                return v.length2();
+            })
+        .def("normalize", [](IMATH_NAMESPACE::V2d& v) {
+                return v.normalize();
+            })
+        .def("normalizeExc", [](IMATH_NAMESPACE::V2d& v) {
+                return v.normalizeExc();
+            })
+        .def("normalizeNonNull", [](IMATH_NAMESPACE::V2d& v) {
+                return v.normalizeNonNull();
+            })
+        .def("normalized", [](IMATH_NAMESPACE::V2d const& v) {
+                return v.normalized();
+            })
+        .def("normalizedExc", [](IMATH_NAMESPACE::V2d const& v) {
+                return v.normalizedExc();
+            })
+        .def("normalizedNonNull", [](IMATH_NAMESPACE::V2d const& v) {
+                return v.normalizedNonNull();
+            })
         .def_static("baseTypeLowest", []() {
                 return IMATH_NAMESPACE::V2d::baseTypeLowest();
             })
@@ -112,7 +128,9 @@
         .def("__ne__", [](IMATH_NAMESPACE::Box2d lhs, py::object const& rhs) {
             return lhs != _type_checked<IMATH_NAMESPACE::Box2d>(rhs, "!=");
         })
-        .def("center", &IMATH_NAMESPACE::Box2d::center)
+        .def("center", [](IMATH_NAMESPACE::Box2d const& box) {
+                return box.center();
+            })
         .def("extendBy", [](IMATH_NAMESPACE::Box2d* box, IMATH_NAMESPACE::V2d const& point ) {
             return box->extendBy(point);
         })
Dominant language
C++
Stars
2k
Forks
356
Avg merge
3d 1h
Merged PRs (30d)
2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AcademySoftwareFoundation/OpenTimelineIO

All issues in AcademySoftwareFoundation/OpenTimelineIO

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.