Skip to content

Commit 8c8d2f1

Browse files
Kevin Boydcopybara-github
Kevin Boyd
authored andcommitted
Fast cc proto support
* Changed some c++ direct module imports to not reference google internals * Used pybind11_bazel config to provide python_headers lib * open source protobuf build file is patched to give the library we need public visibility PiperOrigin-RevId: 393445960
1 parent 9aa816f commit 8c8d2f1

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

WORKSPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ git_repository(
5353
name = "com_google_protobuf",
5454
remote = "https://github.com/protocolbuffers/protobuf.git",
5555
tag = "v3.18.0-rc1",
56+
patches = ["com_google_protobuf_build.patch"],
5657
)
5758

5859
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
@@ -71,5 +72,5 @@ grpc_deps()
7172

7273
bind(
7374
name = "python_headers",
74-
actual = "@com_google_protobuf//util/python:python_headers",
75+
actual = "@local_config_python//:python_headers",
7576
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- BUILD
2+
+++ BUILD
3+
@@ -889,6 +889,8 @@
4+
"//conditions:default": [],
5+
":use_fast_cpp_protos": ["//external:python_headers"],
6+
}),
7+
+
8+
+ visibility = ["//visibility:public"],
9+
)
10+
11+
config_setting(

pybind11_protobuf/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ pybind_library(
7070
"@com_google_absl//absl/strings",
7171
"@com_google_protobuf//:proto_api",
7272
"@com_google_protobuf//:protobuf",
73+
"@com_google_protobuf//:python/google/protobuf/pyext/_message.so", # fixdeps: keep
7374
],
7475
)
7576

pybind11_protobuf/proto_cast_util.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const GlobalState* GetGlobalState() {
5353

5454
PyErr_Clear();
5555
try {
56-
py::module_::import("google3.net.proto2.python.internal.cpp._message");
56+
py::module_::import("google.protobuf.pyext._message");
5757
} catch (...) {
5858
// TODO(pybind11-infra): narrow down to expected exception(s).
5959
// Ignore any errors; they will appear immediately when the capsule
@@ -68,7 +68,7 @@ const GlobalState* GetGlobalState() {
6868
// When not using fast protos, we may construct protos from the default
6969
// pool.
7070
try {
71-
auto m = py::module_::import("google3.net.proto2.python.public");
71+
auto m = py::module_::import("google.protobuf");
7272
state->global_pool = m.attr("descriptor_pool").attr("Default")();
7373
state->factory = m.attr("message_factory")
7474
.attr("MessageFactory")(state->global_pool);

0 commit comments

Comments
 (0)