@@ -198,13 +198,24 @@ def _python_repository_impl(rctx):
198
198
python_bin = "python.exe" if ("windows" in platform ) else "bin/python3"
199
199
200
200
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
+ ]
201
212
202
213
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."
208
219
"**/__pycache__/*.pyc" ,
209
220
"**/__pycache__/*.pyo" ,
210
221
]
@@ -245,17 +256,7 @@ filegroup(
245
256
include = {glob_include},
246
257
# Platform-agnostic filegroup can't match on all patterns.
247
258
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},
259
260
),
260
261
)
261
262
@@ -321,6 +322,7 @@ py_runtime_pair(
321
322
py3_runtime = ":py3_runtime",
322
323
)
323
324
""" .format (
325
+ glob_exclude = repr (glob_exclude ),
324
326
glob_include = repr (glob_include ),
325
327
python_path = python_bin ,
326
328
python_version = python_short_version ,
0 commit comments