Skip to content

Commit a47c6cd

Browse files
authored
Fix glob includes/exclues (#1038)
1 parent 3d17505 commit a47c6cd

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

python/repositories.bzl

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -198,13 +198,24 @@ def _python_repository_impl(rctx):
198198
python_bin = "python.exe" if ("windows" in platform) else "bin/python3"
199199

200200
glob_include = []
201+
glob_exclude = [
202+
"**/* *", # Bazel does not support spaces in file names.
203+
# Unused shared libraries. `python` executable and the `:libpython` target
204+
# depend on `libpython{python_version}.so.1.0`.
205+
"lib/libpython{python_version}.so",
206+
# static libraries
207+
"lib/**/*.a",
208+
# tests for the standard libraries.
209+
"lib/python{python_version}/**/test/**",
210+
"lib/python{python_version}/**/tests/**",
211+
]
201212

202213
if rctx.attr.ignore_root_user_error:
203-
glob_include += [
204-
"# These pycache files are created on first use of the associated python files.",
205-
"# Exclude them from the glob because otherwise between the first time and second time a python toolchain is used,",
206-
"# the definition of this filegroup will change, and depending rules will get invalidated.",
207-
"# See https://github.com/bazelbuild/rules_python/issues/1008 for unconditionally adding these to toolchains so we can stop ignoring them.",
214+
glob_exclude += [
215+
# These pycache files are created on first use of the associated python files.
216+
# Exclude them from the glob because otherwise between the first time and second time a python toolchain is used,"
217+
# the definition of this filegroup will change, and depending rules will get invalidated."
218+
# See https://github.com/bazelbuild/rules_python/issues/1008 for unconditionally adding these to toolchains so we can stop ignoring them."
208219
"**/__pycache__/*.pyc",
209220
"**/__pycache__/*.pyo",
210221
]
@@ -245,17 +256,7 @@ filegroup(
245256
include = {glob_include},
246257
# Platform-agnostic filegroup can't match on all patterns.
247258
allow_empty = True,
248-
exclude = [
249-
"**/* *", # Bazel does not support spaces in file names.
250-
# Unused shared libraries. `python` executable and the `:libpython` target
251-
# depend on `libpython{python_version}.so.1.0`.
252-
"lib/libpython{python_version}.so",
253-
# static libraries
254-
"lib/**/*.a",
255-
# tests for the standard libraries.
256-
"lib/python{python_version}/**/test/**",
257-
"lib/python{python_version}/**/tests/**",
258-
],
259+
exclude = {glob_exclude},
259260
),
260261
)
261262
@@ -321,6 +322,7 @@ py_runtime_pair(
321322
py3_runtime = ":py3_runtime",
322323
)
323324
""".format(
325+
glob_exclude = repr(glob_exclude),
324326
glob_include = repr(glob_include),
325327
python_path = python_bin,
326328
python_version = python_short_version,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy