This package allows for automatic recompilation of protocol buffers on import.
Create a directory with all your protocol buffer definitions in it, like proto/
.
Create proto/__init__.py
with the following contents:
from import_proto import import_proto
import_proto(__file__)
Now, if you have defined a message Qux
in proto/foo/bar/baz.proto
like
// proto/foo/bar/baz.proto
message Qux {
int corge = 1;
}
you can import it like so:
from proto.foo.bar.baz_pb2 import Qux
q = Qux(corge=123)
print(q)
# => corge: 123
The protocol buffer compiler will run on each import.
https://gitlab.com/dfritzsche/create-protoc-wheel/-/issues/5
This package depends on protoc-wheel-0
for the protocol buffer compiler. The code generated by the protocol buffer compiler depends on the protobuf
package. However, different versions of the protocol buffer compiler, and thus protoc-wheel-0
, depend on different versions of the protobuf
package, but protoc-wheel-0
does not indicate which version of protobuf
it depends on in its requirements.
So if you have, say, protobuf
3.10 installed, you may need to install a version of protoc-wheel-0
that works with that. Generally, you can determine the correct version by
cross referencing the release history of protobuf
with that of protoc-wheel-0
.
The protocol buffer compiler should not re-run if the protocol buffer definition files have not changed.
See DEVELOPMENT.md