pybind / pybind11_protobuf

Pybind11 bindings for Google's Protocol Buffers
Other
56 stars 34 forks source link

How to integrate with protobuf 3.15.3? #75

Open dongqixu opened 2 years ago

dongqixu commented 2 years ago

Thanks for the great work!

I was using protobuf 3.15.3 and encountered the following error message. 'const struct google::protobuf::python::PyProto_API' has no member named 'DescriptorPool_FromPool'

I checked https://github.com/protocolbuffers/protobuf/blob/v3.15.3/python/google/protobuf/proto_api.h and found there is no such an API in protobuf 3.15.3. Is is possible to integrate the project with the given version? Thanks.

amauryfa commented 2 years ago

Indeed, this API has been added to version 3.18.0. You need this version of protobuf to compile pybind11_protobuf as is.

But, it appears that this call is only needed to support custom descriptor pools: usually, internal Python structures have not been set up in this case. You could try removing the 5 lines around the call to DescriptorPool_FromPool. If your messages come from a standard pb2 module, this won't make a difference.

rwgk commented 2 years ago

@dongqixu If you need to keep using versions prior to 3.18.0, could you please try out #ifdef around the 5 lines pointed out by @amauryfa and post the diff here? I'll apply that to our internal version, which then gets exported back here.