Hi Jens,
The
grpcio package itself is completely agnostic to protobuf. It only has byte-oriented interfaces. Protobuf integration only happens within the generated code (e.g.
helloworld_pb2_grpc.py). This generated code comes from running the
grpcio-tools package, which
does have a dependency on protobuf. The compatibility range with protobuf is defined by this package's dependency range on protobuf and can be seen by either looking at
its setup.py file or using a dependency inspection tool such as pipdeptree:
(venv) rbellevi-macbookpro:tmp.m984j04o rbellevi$ python3 -m pipdeptree
grpcio-tools==1.56.0
├── grpcio [required: >=1.56.0, installed: 1.56.0]
├── protobuf [required: >=4.21.6,<5.0dev, installed: 4.23.4]
└── setuptools [required: Any, installed: 67.8.0]
In general, you can use the heuristic that if you do pip install grpcio-tools and generate your code, you'll have the right version of protobuf already installed.
This isn't ideal since many people generate their code only once and then rebuild their application many times, potentially forgetting the version of protobuf that they originally used to generate their code. In practice, even these people are generally fine, only getting bitten when protobuf does a major version bump, which has happened once in the past 5 years.