Commit 142cbe0d authored by Calder Coalson's avatar Calder Coalson

Declare 'google' namespace when importing Python protobuf via Bazel.

`python/google/__init__.py` declares the top-level 'google' namespace so that
`google.protobuf` can be imported alongside other Google Python modules like
`google.auth`.

This works well when installing protobuf via Pip, but the Bazel `//:python_srcs`
rule doesn't include this file in its `srcs`. Bazel implicitly creates an empty
`google/__init__.py`, which does *not* set up a namespace. The result is that
consuming Python protobuf via Bazel breaks all other Google Python libraries.

This fixes #4658.
parent ce57ccce
......@@ -640,6 +640,7 @@ py_library(
name = "python_srcs",
srcs = glob(
[
"python/google/__init__.py",
"python/google/protobuf/*.py",
"python/google/protobuf/**/*.py",
],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment