Skip to content

Commit 0ad2d3f

Browse files
mailto-jonasewianda
authored andcommitted
fix: Don't fail in override from a non-root module (bazel-contrib#2566)
This patch enable calls to pypi override from a non-root module without failing. The call will instead be silently ignored. Fixes bazel-contrib#2550 --------- Co-authored-by: Ignas Anikevicius <[email protected]> fix(toolchain) Override coverage rc
1 parent f219112 commit 0ad2d3f

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ Unreleased changes template.
5252

5353
{#v0-0-0-changed}
5454
### Changed
55-
* Nothing changed.
55+
* (pypi) {obj}`pip.override` will now be ignored instead of raising an error,
56+
fixes [#2550](https://github.com/bazelbuild/rules_python/issues/2550).
5657

5758
{#v0-0-0-fixed}
5859
### Fixed

python/private/pypi/extension.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,9 @@ You cannot use both the additive_build_content and additive_build_content_file a
387387
for module in module_ctx.modules:
388388
for attr in module.tags.override:
389389
if not module.is_root:
390-
fail("overrides are only supported in root modules")
390+
# Overrides are only supported in root modules. Silently
391+
# ignore the override:
392+
continue
391393

392394
if not attr.file.endswith(".whl"):
393395
fail("Only whl overrides are supported at this time")

python/private/stage2_bootstrap_template.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -288,29 +288,28 @@ def _maybe_collect_coverage(enable):
288288
rcfile.write(
289289
"""[run]
290290
relative_files = True
291+
omit =
292+
# Pipes can't be read back later, which can cause coverage to
293+
# throw an error when trying to get its source code.
294+
/dev/fd/*
295+
# The mechanism for finding third-party packages in coverage-py
296+
# only works for installed packages, not for runfiles. e.g:
297+
#'$HOME/.local/lib/python3.10/site-packages',
298+
# '/usr/lib/python',
299+
# '/usr/lib/python3.10/site-packages',
300+
# '/usr/local/lib/python3.10/dist-packages'
301+
# see https://github.com/nedbat/coveragepy/blob/bfb0c708fdd8182b2a9f0fc403596693ef65e475/coverage/inorout.py#L153-L164
302+
*/external/*
291303
"""
292304
)
293305
try:
294306
cov = coverage.Coverage(
295-
config_file=rcfile_name,
307+
config_file=os.environ.get("COVERAGE_RCFILE", rcfile_name),
296308
branch=True,
297309
# NOTE: The messages arg controls what coverage prints to stdout/stderr,
298310
# which can interfere with the Bazel coverage command. Enabling message
299311
# output is only useful for debugging coverage support.
300312
messages=is_verbose_coverage(),
301-
omit=[
302-
# Pipes can't be read back later, which can cause coverage to
303-
# throw an error when trying to get its source code.
304-
"/dev/fd/*",
305-
# The mechanism for finding third-party packages in coverage-py
306-
# only works for installed packages, not for runfiles. e.g:
307-
#'$HOME/.local/lib/python3.10/site-packages',
308-
# '/usr/lib/python',
309-
# '/usr/lib/python3.10/site-packages',
310-
# '/usr/local/lib/python3.10/dist-packages'
311-
# see https://github.com/nedbat/coveragepy/blob/bfb0c708fdd8182b2a9f0fc403596693ef65e475/coverage/inorout.py#L153-L164
312-
"*/external/*",
313-
],
314313
)
315314
cov.start()
316315
try:

0 commit comments

Comments
 (0)