Hi gRPC Python users,
We have decided to deprecate the gRPC repo's implementation of the py_proto_library Bazel rule in favor of the official Protobuf implementation, providing a single supported solution. This change affects how Python libraries are generated from Proto files in Bazel builds.
Key Changes and Timeline
In our next 1.72 release (scheduled to release on April 15th), we're adding a use_protobuf attribute to py_proto_library. This will be true by default, setting this to false will switch the implementation to the gRPC version.
In 1.73 (scheduled to release on May 27th), we will remove the gRPC implementation of py_proto_library. And py_proto_library rule will always use the Protobuf implementation.
Key Differences Between Implementations
There are three key differences between the gRPC implementation and the Protobuf implementation that you need to be aware of:
.pyi File Generation: The Protobuf implementation does not generate .pyi files for type hinting.
Import Attribute and PYTHONPATH: The Protobuf implementation does not support the import attribute for adding directories to the PYTHONPATH.
Location of Generated _pb2.py Files: When a py_proto_library directly depends on a proto_library in another Bazel package, the Protobuf implementation generates the _pb2.py file in the same location as the proto_library. While the gPRC implementation will generate additional .py files in the current package to import the generated code.
Please let us know if you have any questions or concerns.
Best,
gPRC Python Team