Patched protobuf repo sufficiently for things to work.
diff --git a/python/BUILD b/python/BUILD index 68cd74a..a00b0d0 100644 --- a/python/BUILD +++ b/python/BUILD
@@ -93,10 +93,28 @@ 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, )
diff --git a/python/message.c b/python/message.c index 728b116..e486fde 100644 --- a/python/message.c +++ b/python/message.c
@@ -332,7 +332,7 @@ 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 @@ 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 =
diff --git a/python/minimal_test.py b/python/minimal_test.py index 13f1124..32b8333 100644 --- a/python/minimal_test.py +++ b/python/minimal_test.py
@@ -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 @@ 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__':
diff --git a/python/protobuf.c b/python/protobuf.c index afe92c6..09b1552 100644 --- a/python/protobuf.c +++ b/python/protobuf.c
@@ -288,7 +288,8 @@ 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; }