Hey! These docs are for version 2.10, which is no longer officially supported. Click here for the latest version, 2.18!


Options related to the Protobuf Python backend.

See Pants.

Backend: pants.backend.python
Config section: [python-protobuf]

Basic options


default: False

Use the mypy-protobuf plugin (https://github.com/dropbox/mypy-protobuf) to also generate .pyi type stubs.

Advanced options


default: True

If True, will add a dependency on a python_requirement target exposing the protobuf module (usually from the protobuf requirement). If the protobuf_source target sets grpc=True, will also add a dependency on the python_requirement target exposing the grpcio module.

If [python].enable_resolves is set, Pants will only infer dependencies on python_requirement targets that use the same resolve as the particular protobuf_source / protobuf_sources target uses, which is set via its python_resolve field.

Unless this option is disabled, Pants will error if no relevant target is found or if more than one is found which causes ambiguity.

Deprecated options


--python-protobuf-runtime-dependencies="[<target_option>, <target_option>, ...]"
default: []

Deprecated, will be removed in version: 2.11.0.dev0.
Pants can now infer dependencies on the Protobuf and gRPC runtime libraries for you. Not only is this more convenient, it allows Pants to support the new `[python].resolves` feature.

To use Pants's new mechanism, simply remove this option. Run ./pants dependencies path/to/f.proto to confirm that dependencies are still added correctly. You can disable this new dependency inference feature by setting [python-protobuf].infer_runtime_dependency = false.

A list of addresses to python_requirement targets for the runtime dependencies needed for generated Python code to work. For example, ['3rdparty/python:protobuf', '3rdparty/python:grpcio']. These dependencies will be automatically added to every protobuf_sources target