In general we recommend that you distribute the .proto file itself and not the generated code. As you pointed out, distributing generated code doesn't allow any user to use a different runtime. The wire format is always compatible so it doesn't matter that you are using a different version of protobuf than your users. This also lets them use your proto in any language, giving them more flexibility.
On Friday, May 27, 2022 at 9:39:32 AM UTC-7 [email protected] wrote: > I can't seem to wrap my head around a way to distribute protobuf generated > code. > I have 2 projects, A and B > B imports project As proto definition > > A and B have python and C++ generated code. > For python it seems to all work well (had issues with protoc not > generating the righ import package path, but I seem to have solved this) > > In C++ it get's complicated > > Say I build a .so from project A and I bundle the header with the librairy > (protobuf 3.17 was used). > > If The person working on B had a different version of protobuf installed, > he can't use the header or he'll get the 'error: #error This file was > generated by an older version of protoc which is' message > > So for C++ I can't bundle a library with headers, I need to share the > proto and let the users generate the code in their own build system... This > seems wrong. > > In the same line of thought, should the _pb2.py be disitributed or should > the client installing the lib locally generate (say have instructions in > setup.py) the code > > Thanks > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/9c6a68f0-be63-457f-ac3b-402f87076771n%40googlegroups.com.
