Skip to content

Automatic recompilation of protocol buffers on import

Notifications You must be signed in to change notification settings

kalaracey/import-proto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This package allows for automatic recompilation of protocol buffers on import.

Setup

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.

Known issues:

Protobuf compatibilty

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.

Other

The protocol buffer compiler should not re-run if the protocol buffer definition files have not changed.

Development

See DEVELOPMENT.md

About

Automatic recompilation of protocol buffers on import

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages