Generated Python code version compatibility

100 views
Skip to first unread message

Dominik Gresch

unread,
Dec 13, 2021, 3:59:57 PM12/13/21
to grpc.io
Hi all,

First off, thanks a lot to the gRPC developers - it's a great piece of technology you've created.

I am looking for some guidance regarding the compatibility of the generated Python code across gRPC and / or protobuf versions:

I had previously used the generated C++ code, which checks that the current version of gRPC and the one the files were generated with were compatible. As a result, I assumed best practice was to always keep them the same.

Looking now at the generated Python code however, it seems that it's only using the public gRPC API. Does this mean that it is possible to use Python files generated with a different version of gRPC and / or protobuf than the currently installed one? If yes, is that an actual design goal of the Python code generator, or merely working by accident?

In the setup.py for grpcio-tools, I found the following:
    install_requires=[
        'protobuf>=3.5.0.post1, < 4.0dev',
        'grpcio>={version}'.format(version=grpc_version.VERSION),
        'setuptools',
    ],

which seems to imply that the gRPC version simply needs to be newer than the _pb2.py.

To give some context, the reason I am interested in this compatibility is that I would like to publish a library which works with different versions of gRPC. While building the _pb2.py at install time is an option, it's difficult with pip's build isolation to guarantee that the installed gRPC is the same version used to build the wheel, without pinning both.

Thank you and best regards,
Dominik Gresch
Reply all
Reply to author
Forward
0 new messages