-
Notifications
You must be signed in to change notification settings - Fork 74k
/
protobuf.patch
80 lines (68 loc) · 2.48 KB
/
protobuf.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
1. Fix BUILD
2. Import MutableSequence from collections.abc on Python 3. (#6272)
Fixes https://github.com/protocolbuffers/protobuf/issues/5335.
Backport https://github.com/protocolbuffers/protobuf/commit/9d61eada0f47d7be793983638c4a29707b192d0c
Signed-off-by: Benjamin Peterson <benjamin@python.org>
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
BUILD | 4 +++-
protobuf.bzl | 2 ++
python/google/protobuf/pyext/message.cc | 6 +++++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/BUILD b/BUILD
index dbae719..87dc384 100644
--- a/BUILD
+++ b/BUILD
@@ -23,7 +23,7 @@ config_setting(
# ZLIB configuration
################################################################################
-ZLIB_DEPS = ["@zlib//:zlib"]
+ZLIB_DEPS = ["@zlib"]
################################################################################
# Protobuf Runtime Library
@@ -143,6 +143,7 @@ cc_library(
copts = COPTS,
includes = ["src/"],
linkopts = LINK_OPTS,
+ alwayslink = 1,
visibility = ["//visibility:public"],
)
@@ -213,6 +214,7 @@ cc_library(
copts = COPTS,
includes = ["src/"],
linkopts = LINK_OPTS,
+ alwayslink = 1,
visibility = ["//visibility:public"],
deps = [":protobuf_lite"] + PROTOBUF_DEPS,
)
diff --git a/protobuf.bzl b/protobuf.bzl
index e065332..92ae3b4 100644
--- a/protobuf.bzl
+++ b/protobuf.bzl
@@ -85,6 +85,8 @@ def _proto_gen_impl(ctx):
for dep in ctx.attr.deps:
import_flags += dep.proto.import_flags
deps += dep.proto.deps
+ import_flags = depset(import_flags).to_list()
+ deps = depset(deps).to_list()
if not ctx.attr.gen_cc and not ctx.attr.gen_py and not ctx.executable.plugin:
return struct(
diff --git a/python/google/protobuf/pyext/message.cc b/python/google/protobuf/pyext/message.cc
index 3530a9b..c31fa8f 100644
--- a/python/google/protobuf/pyext/message.cc
+++ b/python/google/protobuf/pyext/message.cc
@@ -2991,8 +2991,12 @@ bool InitProto2MessageModule(PyObject *m) {
reinterpret_cast<PyObject*>(
&RepeatedCompositeContainer_Type));
- // Register them as collections.Sequence
+ // Register them as MutableSequence.
+#if PY_MAJOR_VERSION >= 3
+ ScopedPyObjectPtr collections(PyImport_ImportModule("collections.abc"));
+#else
ScopedPyObjectPtr collections(PyImport_ImportModule("collections"));
+#endif
if (collections == NULL) {
return false;
}
--
2.33.0