binder: static assertion failed: Holder classes are only supported for custom types
I’m having some trouble compiling bindings for my methods that take std::vector arguments. I’m using Binder commit bcc2049fdd6db671f2d8834df4d468c32cb08c02 and the associated RosettaCommons/pybind11 commit 4f72ef846fe8453596230ac285eeaa0ce3278bb4. Here’s an example error:
In file included from /z/home/anovak/workspace/vg/deps/libbdsg/pybind11/include/pybind11/attr.h:13:0,
from /z/home/anovak/workspace/vg/deps/libbdsg/pybind11/include/pybind11/pybind11.h:44,
from /z/home/anovak/workspace/vg/deps/libbdsg/cmake_bindings/std/stl_vector_1.cpp:7:
/z/home/anovak/workspace/vg/deps/libbdsg/pybind11/include/pybind11/cast.h: In instantiation of ‘struct pybind11::detail::copyable_holder_caster<std::vector<handlegraph::path_handle_t>, std::shared_ptr<std::vector<handlegraph::path_handle_t> > >’:
/z/home/anovak/workspace/vg/deps/libbdsg/pybind11/include/pybind11/cast.h:1557:7: required from ‘class pybind11::detail::type_caster<std::shared_ptr<std::vector<handlegraph::path_handle_t> >, void>’
/usr/include/c++/7/type_traits:1512:12: required from ‘struct std::is_base_of<pybind11::detail::copyable_holder_caster<std::vector<handlegraph::path_handle_t>, std::shared_ptr<std::vector<handlegraph::path_handle_t> > >, pybind11::detail::type_caster<std::shared_ptr<std::vector<handlegraph::path_handle_t> >, void> >’
/z/home/anovak/workspace/vg/deps/libbdsg/pybind11/include/pybind11/cast.h:1593:50: required from ‘struct pybind11::detail::is_holder_type<std::vector<handlegraph::path_handle_t>, std::shared_ptr<std::vector<handlegraph::path_handle_t> > >’
/z/home/anovak/workspace/vg/deps/libbdsg/pybind11/include/pybind11/detail/common.h:572:48: required from ‘constexpr const auto pybind11::detail::exactly_one<pybind11::class_<std::vector<handlegraph::path_handle_t>, std::shared_ptr<std::vector<handlegraph::path_handle_t, std::allocator<handlegraph::path_handle_t> > > >::is_holder, std::unique_ptr<std::vector<handlegraph::path_handle_t>, std::default_delete<std::vector<handlegraph::path_handle_t> > >, std::shared_ptr<std::vector<handlegraph::path_handle_t, std::allocator<handlegraph::path_handle_t> > > >::found’
/z/home/anovak/workspace/vg/deps/libbdsg/pybind11/include/pybind11/detail/common.h:572:27: required from ‘struct pybind11::detail::exactly_one<pybind11::class_<std::vector<handlegraph::path_handle_t>, std::shared_ptr<std::vector<handlegraph::path_handle_t, std::allocator<handlegraph::path_handle_t> > > >::is_holder, std::unique_ptr<std::vector<handlegraph::path_handle_t>, std::default_delete<std::vector<handlegraph::path_handle_t> > >, std::shared_ptr<std::vector<handlegraph::path_handle_t, std::allocator<handlegraph::path_handle_t> > > >’
/z/home/anovak/workspace/vg/deps/libbdsg/pybind11/include/pybind11/detail/common.h:582:76: required by substitution of ‘template<template<class> class Predicate, class Default, class ... Ts> using exactly_one_t = typename pybind11::detail::exactly_one::type [with Predicate = pybind11::class_<std::vector<handlegraph::path_handle_t>, std::shared_ptr<std::vector<handlegraph::path_handle_t, std::allocator<handlegraph::path_handle_t> > > >::is_holder; Default = std::unique_ptr<std::vector<handlegraph::path_handle_t>, std::default_delete<std::vector<handlegraph::path_handle_t> > >; Ts = {std::shared_ptr<std::vector<handlegraph::path_handle_t, std::allocator<handlegraph::path_handle_t> > >}]’
/z/home/anovak/workspace/vg/deps/libbdsg/pybind11/include/pybind11/pybind11.h:1057:92: required from ‘class pybind11::class_<std::vector<handlegraph::path_handle_t>, std::shared_ptr<std::vector<handlegraph::path_handle_t, std::allocator<handlegraph::path_handle_t> > > >’
/z/home/anovak/workspace/vg/deps/libbdsg/cmake_bindings/std/stl_vector_1.cpp:28:122: required from here
/z/home/anovak/workspace/vg/deps/libbdsg/pybind11/include/pybind11/cast.h:1483:5: error: static assertion failed: Holder classes are only supported for custom types
static_assert(std::is_base_of<base, type_caster<type>>::value,
^~~~~~~~~~~~~
My config.cfg looks like this:
+include <pybind11/stl.h>
+include <pybind11/stl_bind.h>
+include <pybind11/functional.h>
+include <fstream>
-namespace bdsg::sqvarint
-namespace bdsg::msbvarint
-class std::basic_ios
-class std::ios_base
-class std::basic_ostream
-class std::ostream
-class std::basic_istream
-class std::istream
-class std::streambuf
-class bdsg::node_t
-function bdsg::node_t::update_path_last_bytes
-function bdsg::ODGI::get_ordinal_rank_of_step
-function bdsg::ODGI::insert_step
If I add in -class std::vector then the bindings will compile, but no bindings are made for methods that use std::vector arguments.
This is a bit related to #71, but I’m working with vectors of actual (and genuinely custom) objects; handlegraph::path_handle_t is a struct.
Does anyone have any advice about what “Holder classes are only supported for custom types” actually means? What is a holder class? How is Binder instructing Pybind11 to use one, and what doesn’t Pybind11 like about it? Is there anything I need to know about the Right Way to bind std::vector that I’m not doing here?
I’ll see if I can distill this down to a test case as suggested in #71.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 27 (18 by maintainers)
Thank you for detailed info @kerim371 ! I was able to reproduce this locally. The issue is extra include
+include <pybind11/stl.h>directive. It should not be used along with custom binders forstd::vectortype. So removing this line from config fixed this for me.@adamnovak i am 99% sure that your case similar cause. So please double check that your Binder config does not have
+include <pybind11/stl.h>directive. Thanks,Hi @adamnovak https://gitlab.cern.ch/hepmc/HepMC3/blob/master/python/src/pyHepMC3.binder maybe this helps.
Best regards, Andrii