Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way compile protocol buffers into pure python code?

I am looking into using protocol buffers to communicate with some custom devices we have. The problem is that these devices run an embedded python interpreter and we cannot install extra libraries onto them. Is there a way to compile .proto files into python without requirement for the protobuf library?

like image 598
Mad Wombat Avatar asked Nov 04 '16 04:11

Mad Wombat


2 Answers

Give a try to protlib instead, its only 51.4 KB and you can delete some code there that handles types that you don't need.

like image 74
Yoav Glazner Avatar answered Oct 23 '22 11:10

Yoav Glazner


Another possibility is to use Better Protobuf for Python which is currently supported unlike protolib. It supports most use cases and has been under active development since 2019. It also provides a very friendly API to interact with the generated Protobuf files.

like image 44
Moritz Avatar answered Oct 23 '22 11:10

Moritz