fix: allow pypi packages with empty data attribute (#3463)
An empty glob under site-packages (after excluding code and pyi files)
is a bit strange,
but not actually incorrect. If such a situation occurs, it would cause a
failure because
Bazel has since changed to disallow empty globs by default.
To fix, just set allow_empty=True on the data glob.
diff --git a/python/private/pypi/whl_library_targets.bzl b/python/private/pypi/whl_library_targets.bzl
index a2d77da..39b1ccc 100644
--- a/python/private/pypi/whl_library_targets.bzl
+++ b/python/private/pypi/whl_library_targets.bzl
@@ -356,6 +356,7 @@
data = data + native.glob(
["site-packages/**/*"],
exclude = _data_exclude,
+ allow_empty = True,
)
pyi_srcs = native.glob(
diff --git a/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl b/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl
index b7fb909..1d80340 100644
--- a/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl
+++ b/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl
@@ -275,6 +275,7 @@
"**/*.pyc.*",
"**/*.dist-info/RECORD",
],
+ allow_empty = True,
),
# pyi call
_glob_call(["site-packages/**/*.pyi"], allow_empty = True),
@@ -457,7 +458,7 @@
"**/*.pyc",
"**/*.pyc.*",
"**/*.dist-info/RECORD",
- ]),
+ ], allow_empty = True),
_glob_call(["site-packages/**/*.pyi"], allow_empty = True),
])