diff --git a/python/flatbuffers/reflection/Enum.py b/python/flatbuffers/reflection/Enum.py index 1136478d2a2..ebd79fdcbe2 100644 --- a/python/flatbuffers/reflection/Enum.py +++ b/python/flatbuffers/reflection/Enum.py @@ -42,7 +42,7 @@ def Values(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.EnumVal import EnumVal + from flatbuffers.reflection.EnumVal import EnumVal obj = EnumVal() obj.Init(self._tab.Bytes, x) return obj @@ -72,7 +72,7 @@ def UnderlyingType(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) - from reflection.Type import Type + from flatbuffers.reflection.Type import Type obj = Type() obj.Init(self._tab.Bytes, x) return obj @@ -85,7 +85,7 @@ def Attributes(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.KeyValue import KeyValue + from flatbuffers.reflection.KeyValue import KeyValue obj = KeyValue() obj.Init(self._tab.Bytes, x) return obj diff --git a/python/flatbuffers/reflection/EnumVal.py b/python/flatbuffers/reflection/EnumVal.py index 0b453b7b3d0..6ef68cacb60 100644 --- a/python/flatbuffers/reflection/EnumVal.py +++ b/python/flatbuffers/reflection/EnumVal.py @@ -47,7 +47,7 @@ def UnionType(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) - from reflection.Type import Type + from flatbuffers.reflection.Type import Type obj = Type() obj.Init(self._tab.Bytes, x) return obj @@ -80,7 +80,7 @@ def Attributes(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.KeyValue import KeyValue + from flatbuffers.reflection.KeyValue import KeyValue obj = KeyValue() obj.Init(self._tab.Bytes, x) return obj diff --git a/python/flatbuffers/reflection/Field.py b/python/flatbuffers/reflection/Field.py index cb7910681be..7c4bfcb871c 100644 --- a/python/flatbuffers/reflection/Field.py +++ b/python/flatbuffers/reflection/Field.py @@ -40,7 +40,7 @@ def Type(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) - from reflection.Type import Type + from flatbuffers.reflection.Type import Type obj = Type() obj.Init(self._tab.Bytes, x) return obj @@ -102,7 +102,7 @@ def Attributes(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.KeyValue import KeyValue + from flatbuffers.reflection.KeyValue import KeyValue obj = KeyValue() obj.Init(self._tab.Bytes, x) return obj diff --git a/python/flatbuffers/reflection/Object.py b/python/flatbuffers/reflection/Object.py index 829e1dd3e40..4dc4d72482a 100644 --- a/python/flatbuffers/reflection/Object.py +++ b/python/flatbuffers/reflection/Object.py @@ -42,7 +42,7 @@ def Fields(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.Field import Field + from flatbuffers.reflection.Field import Field obj = Field() obj.Init(self._tab.Bytes, x) return obj @@ -88,7 +88,7 @@ def Attributes(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.KeyValue import KeyValue + from flatbuffers.reflection.KeyValue import KeyValue obj = KeyValue() obj.Init(self._tab.Bytes, x) return obj diff --git a/python/flatbuffers/reflection/RPCCall.py b/python/flatbuffers/reflection/RPCCall.py index 32f9d4e505d..5bf6de7bf8f 100644 --- a/python/flatbuffers/reflection/RPCCall.py +++ b/python/flatbuffers/reflection/RPCCall.py @@ -40,7 +40,7 @@ def Request(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) - from reflection.Object import Object + from flatbuffers.reflection.Object import Object obj = Object() obj.Init(self._tab.Bytes, x) return obj @@ -51,7 +51,7 @@ def Response(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) - from reflection.Object import Object + from flatbuffers.reflection.Object import Object obj = Object() obj.Init(self._tab.Bytes, x) return obj @@ -64,7 +64,7 @@ def Attributes(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.KeyValue import KeyValue + from flatbuffers.reflection.KeyValue import KeyValue obj = KeyValue() obj.Init(self._tab.Bytes, x) return obj diff --git a/python/flatbuffers/reflection/Schema.py b/python/flatbuffers/reflection/Schema.py index c37d320b3be..2c85d4ac378 100644 --- a/python/flatbuffers/reflection/Schema.py +++ b/python/flatbuffers/reflection/Schema.py @@ -35,7 +35,7 @@ def Objects(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.Object import Object + from flatbuffers.reflection.Object import Object obj = Object() obj.Init(self._tab.Bytes, x) return obj @@ -60,7 +60,7 @@ def Enums(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.Enum import Enum + from flatbuffers.reflection.Enum import Enum obj = Enum() obj.Init(self._tab.Bytes, x) return obj @@ -97,7 +97,7 @@ def RootTable(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12)) if o != 0: x = self._tab.Indirect(o + self._tab.Pos) - from reflection.Object import Object + from flatbuffers.reflection.Object import Object obj = Object() obj.Init(self._tab.Bytes, x) return obj @@ -110,7 +110,7 @@ def Services(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.Service import Service + from flatbuffers.reflection.Service import Service obj = Service() obj.Init(self._tab.Bytes, x) return obj @@ -144,7 +144,7 @@ def FbsFiles(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.SchemaFile import SchemaFile + from flatbuffers.reflection.SchemaFile import SchemaFile obj = SchemaFile() obj.Init(self._tab.Bytes, x) return obj diff --git a/python/flatbuffers/reflection/Service.py b/python/flatbuffers/reflection/Service.py index 7b954b12698..fadb6a60baa 100644 --- a/python/flatbuffers/reflection/Service.py +++ b/python/flatbuffers/reflection/Service.py @@ -42,7 +42,7 @@ def Calls(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.RPCCall import RPCCall + from flatbuffers.reflection.RPCCall import RPCCall obj = RPCCall() obj.Init(self._tab.Bytes, x) return obj @@ -67,7 +67,7 @@ def Attributes(self, j): x = self._tab.Vector(o) x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4 x = self._tab.Indirect(x) - from reflection.KeyValue import KeyValue + from flatbuffers.reflection.KeyValue import KeyValue obj = KeyValue() obj.Init(self._tab.Bytes, x) return obj diff --git a/python/setup.py b/python/setup.py index 8bea4c78be5..f2dbe4eed23 100644 --- a/python/setup.py +++ b/python/setup.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from setuptools import setup +from setuptools import setup, find_packages setup( name='flatbuffers', @@ -26,7 +26,7 @@ '`Flatbuffers `_ ' 'serialization format.' ), - packages=['flatbuffers'], + packages=find_packages(), include_package_data=True, requires=[], description='The FlatBuffers serialization format for Python', diff --git a/tests/py_test.py b/tests/py_test.py index fb483816b85..42d048955bf 100644 --- a/tests/py_test.py +++ b/tests/py_test.py @@ -3020,6 +3020,23 @@ def test_nested_union_tables(self): ) +class TestReflectionImport(unittest.TestCase): + + def test_import_reflection(self): + """Test that flatbuffers.reflection module can be imported.""" + try: + import flatbuffers.reflection + # Some example imports to test + from flatbuffers.reflection.Schema import Schema + from flatbuffers.reflection.Object import Object + from flatbuffers.reflection.Field import Field + from flatbuffers.reflection.Type import Type + from flatbuffers.reflection.Enum import Enum + # If we got here, the import was successful + except ImportError as e: + self.fail(f"Failed to import flatbuffers.reflection: {e}") + + class TestBuilderClear(unittest.TestCase): def test_consistency(self):