Patched protobuf repo sufficiently for things to work.

pull/13171/head
Joshua Haberman 3 years ago
parent 2244914ac1
commit e079f1bce5
  1. 10
      bazel/protobuf.patch
  2. 8
      bazel/workspace_deps.bzl
  3. 22
      python/BUILD
  4. 4
      python/message.c
  5. 5
      python/minimal_test.py
  6. 3
      python/protobuf.c

@ -0,0 +1,10 @@
--- BUILD
+++ BUILD
@@ -1110,6 +1110,7 @@ py_library(
":python_common_test_protos",
":python_specific_test_protos",
],
+ visibility = ["//visibility:public"],
)
internal_protobuf_py_tests(

@ -19,6 +19,14 @@ def upb_deps():
"https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz",
"https://github.com/protocolbuffers/protobuf/archive/v3.19.1.tar.gz",
],
patches = [
"//bazel:protobuf.patch",
],
patch_cmds = [
"rm python/google/protobuf/__init__.py",
"rm python/google/protobuf/pyext/__init__.py",
"rm python/google/protobuf/internal/__init__.py",
]
)
maybe(

@ -93,10 +93,28 @@ genrule(
cmd = "cp $< $@",
)
genrule(
name = "api_implementation_ext",
srcs = [":api_implementation"],
outs = ["google/protobuf/internal/_api_implementation" + EXT_SUFFIX],
cmd = "cp $< $@",
)
py_test(
name = "minimal_test",
srcs = ["minimal_test.py"],
data = [":message_ext"],
#srcs = ["minimal_test.py"],
srcs = [
"minimal_test.py",
"@com_google_protobuf//:python_tests",
],
deps = [
"@com_google_protobuf//:python_tests",
],
data = [
"@com_google_protobuf//:python_tests",
":message_ext",
":api_implementation_ext",
],
imports = ["."],
legacy_create_init = False,
)

@ -332,7 +332,7 @@ static bool PyUpb_CMessage_InitMapAttribute(PyObject* _self, PyObject* name,
return ok >= 0;
}
static bool PyUpb_CMessage_InitRepeatedAttribute() {
static bool PyUpb_CMessage_InitRepeatedAttribute(void) {
// TODO(haberman): disabled until repeated container is in.
// PyObject* repeated = PyUpb_CMessage_GetAttr(_self, name);
// PyObject* tmp = PyUpb_RepeatedContainer_Extend(repeated, value);
@ -1537,7 +1537,7 @@ static PyType_Spec PyUpb_MessageMeta_Spec = {
PyUpb_MessageMeta_Slots,
};
static PyObject* PyUpb_MessageMeta_CreateType() {
static PyObject* PyUpb_MessageMeta_CreateType(void) {
PyObject* bases = Py_BuildValue("(O)", &PyType_Type);
if (!bases) return NULL;
PyUpb_MessageMeta_Spec.basicsize =

@ -29,6 +29,7 @@
import unittest
from google.protobuf.pyext import _message
from google.protobuf.internal import api_implementation
class TestMessageExtension(unittest.TestCase):
@ -48,9 +49,11 @@ class TestMessageExtension(unittest.TestCase):
def test_lib_is_upb(self):
# Ensure we are not pulling in a different protobuf library on the
# system.
print(_message._IS_UPB)
self.assertTrue(_message._IS_UPB)
self.assertEqual(api_implementation.Type(), "cpp")
TestMessageExtension.test_descriptor_pool.__unittest_expecting_failure__ = True
#TestMessageExtension.test_descriptor_pool.__unittest_expecting_failure__ = True
if __name__ == '__main__':

@ -288,7 +288,8 @@ PyMODINIT_FUNC PyInit__message(void) {
state->obj_cache = PyUpb_WeakMap_New();
if (!PyUpb_InitDescriptorContainers(m) || !PyUpb_InitDescriptorPool(m) ||
!PyUpb_InitDescriptor(m) || !PyUpb_InitArena(m)) {
!PyUpb_InitDescriptor(m) || !PyUpb_InitArena(m) ||
!PyUpb_InitMessage(m)) {
Py_DECREF(m);
return NULL;
}

Loading…
Cancel
Save