flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

[Python] `flatbuffers.reflection` not being packaged

Open emaheuxPEREN opened this issue 6 months ago • 2 comments

Is there a reason why reflection utils for flatbuffers is not part of the official flatbuffers Python package? (we can manually download reflection.fbs from repo and regenerate Python code from schema, but it's not that convenient isn't it?)

Versions tested: v23-25

emaheuxPEREN avatar Jun 05 '25 17:06 emaheuxPEREN

I had a quick look into this on i guess on a technical level the reason is that ./reflection/reflection.fbs is just outside of the python package directory.

Im not very familiar with the usage of the Flexbuffer / reflection.fbs setup. Can you describe how you used it? And what would you expect to be packaged? Just the reflection.fbs or also some python files generated out of it?

fliiiix avatar Aug 08 '25 07:08 fliiiix

For instance, I would expect something like this to work out of the box :

from flatbuffers.reflection.Schema import Schema

my_schema = Schema.GetRootAs(Path("my_schema.bfbs").read_bytes())
assert my_schema.FileIdent() == b"XXXX"

But since reflection sub-package is not exported in flatbuffers Python package, before doing something like this, we have to manually :

  1. download reflection.fbs from this repo
  2. run flatc to generate corresponding Python code

It thought it would be possible right out of the box since Python code corresponding to reflection.fbs is part of the repo, but the problem is that it is not exported in Python package (misconfiguration of packaging?).

emaheuxPEREN avatar Aug 28 '25 12:08 emaheuxPEREN