From 93f38703abeb073bccab842d23642838b329e5d1 Mon Sep 17 00:00:00 2001 From: pybind11_protobuf authors Date: Sat, 30 Dec 2023 11:21:04 -0800 Subject: [PATCH] Expose new python wrappers for C++ proto descriptor classes. PiperOrigin-RevId: 594634311 --- pybind11_protobuf/BUILD | 3 +++ pybind11_protobuf/proto_cast_util.cc | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pybind11_protobuf/BUILD b/pybind11_protobuf/BUILD index 528db9e..a03fab4 100644 --- a/pybind11_protobuf/BUILD +++ b/pybind11_protobuf/BUILD @@ -59,6 +59,9 @@ pybind_library( deps = [ ":check_unknown_fields", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/log", + "@com_google_absl//absl/log:check", + "@com_google_absl//absl/memory", "@com_google_absl//absl/strings", "@com_google_absl//absl/types:optional", "@com_google_protobuf//:protobuf", diff --git a/pybind11_protobuf/proto_cast_util.cc b/pybind11_protobuf/proto_cast_util.cc index a634429..f05936a 100644 --- a/pybind11_protobuf/proto_cast_util.cc +++ b/pybind11_protobuf/proto_cast_util.cc @@ -9,28 +9,33 @@ #include #include #include -#include #include +#include #include "google/protobuf/descriptor.pb.h" -#include "google/protobuf/descriptor.h" -#include "google/protobuf/dynamic_message.h" -#include "google/protobuf/message.h" -#include "python/google/protobuf/proto_api.h" #include "absl/container/flat_hash_map.h" -#include "absl/strings/numbers.h" +#include "absl/log/check.h" +#include "absl/log/log.h" +#include "absl/memory/memory.h" #include "absl/strings/str_replace.h" -#include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "absl/types/optional.h" +#include "google/protobuf/descriptor.h" +#include "google/protobuf/descriptor_database.h" +#include "google/protobuf/dynamic_message.h" +#include "python/google/protobuf/proto_api.h" #include "pybind11_protobuf/check_unknown_fields.h" +#if defined(GOOGLE_PROTOBUF_VERSION) +#include "absl/strings/numbers.h" +#include "absl/strings/str_split.h" +#endif + namespace py = pybind11; using ::google::protobuf::Descriptor; using ::google::protobuf::DescriptorDatabase; using ::google::protobuf::DescriptorPool; -using ::google::protobuf::DescriptorProto; using ::google::protobuf::DynamicMessageFactory; using ::google::protobuf::FileDescriptor; using ::google::protobuf::FileDescriptorProto;