Skip to main content

Python 3 type hinted protobuf binding generator

Project description Documentation Status Updates


This is a library to generate type-hinted protocol buffer bindings. This tool solves two main issues with the original Google cproto compiler python output:

  • cproto does not support exporting the code with the package roots that are different from what had been supplied by the original .proto file authors, therefore expecting the protocol users to sed through the code (see issues 881 and 1491).
  • It builds the interfaces at run time, therefore disallowing one from using the static type checkers and disabling the auto-complete in your favourite IDE.


This example is usable for building a fully-functional etcd3 client in python. Otherwise see tests.

Let’s start by cloning the repositories containing the necessary .proto files to be compiled. Etcd3 references files from several protobuf libraries, so we are going to need all of them.

mkdir pb-includes

# etcd references it's own .proto files against the root of their own repository, so the doubling here is intended
git clone ./pb-includes/etcd/etcd

git clone ./pb-includes/grpc-gateway
git clone ./pb-includes/protobuf

Now, let’s actually generate the files.

from protobuf_gen import remap, wrap

# all of the _pb2 modules will now be importable through `etcd3py.pb_mods.*`
# for example a module "google/api/http.proto" will be available as ""
    # the working directory is given as the parent directory of the package folder (etcd3py in this case).
    # .proto include directories
    # .proto files to be included in the distribution



Andrey Cizov (, 2018

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
protobuf_gen-0.0.4.tar.gz (13.6 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page