py_library generated from wheel shouldn't include tests/ folders (#528)
This is a python convention that wheels are shipped to pypi including their tests.
These shouldn't be used in user code.
We have observed these files expose modules which collide with first-party targets.
diff --git a/python/pip_install/extract_wheels/lib/bazel.py b/python/pip_install/extract_wheels/lib/bazel.py
index a51a41a..7a91191 100644
--- a/python/pip_install/extract_wheels/lib/bazel.py
+++ b/python/pip_install/extract_wheels/lib/bazel.py
@@ -129,7 +129,15 @@
py_library(
name = "{name}",
- srcs = glob(["**/*.py"], exclude=["{entry_point_prefix}*.py"], allow_empty = True),
+ srcs = glob(
+ ["**/*.py"],
+ allow_empty = True,
+ exclude = [
+ "{entry_point_prefix}*.py",
+ "tests/**",
+ "*/tests/**",
+ ],
+ ),
data = glob(["**/*"], exclude={data_exclude}),
# This makes this directory a top-level in the python import
# search path for anything that depends on this.