From 498c33c5756fb82ca091061bba93c86391e8d8ed Mon Sep 17 00:00:00 2001 From: Elvis Wianda Date: Tue, 20 Aug 2024 16:19:22 -0400 Subject: [PATCH 1/2] fix: Exclude external directory when generating python report --- CHANGELOG.md | 4 ++++ python/private/stage2_bootstrap_template.py | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b457c411d..f982bd2e53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,10 @@ A brief description of the categories of changes: ### Changed * Nothing yet +### Fixed +* (rule) Omit third-party python packages from coverage reports + ([#2136](https://github.com/bazelbuild/rules_python/issues/2136)) + ### Added * Nothing yet diff --git a/python/private/stage2_bootstrap_template.py b/python/private/stage2_bootstrap_template.py index 29f59d2195..f66c28bd51 100644 --- a/python/private/stage2_bootstrap_template.py +++ b/python/private/stage2_bootstrap_template.py @@ -364,6 +364,14 @@ def _maybe_collect_coverage(enable): # Pipes can't be read back later, which can cause coverage to # throw an error when trying to get its source code. "/dev/fd/*", + # The mechanism for finding third-party packages in coverage-py + # only works for installed packages, not for runfiles. e.g: + #'$HOME/.local/lib/python3.10/site-packages', + # '/usr/lib/python', + # '/usr/lib/python3.10/site-packages', + # '/usr/local/lib/python3.10/dist-packages' + # see https://github.com/nedbat/coveragepy/blob/bfb0c708fdd8182b2a9f0fc403596693ef65e475/coverage/inorout.py#L153-L164 + "*/external/*", ], ) cov.start() From 0216054f93352a4fa942b05ff569214eed9e3bde Mon Sep 17 00:00:00 2001 From: aignas <240938+aignas@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:48:34 +0300 Subject: [PATCH 2/2] doc: modify the changelog slightly --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02a8a65974..2e29017535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,10 +29,8 @@ A brief description of the categories of changes: ### Fixed * (gazelle): Fix incorrect use of `t.Fatal`/`t.Fatalf` in tests. - -### Fixed -* (rule) Omit third-party python packages from coverage reports - ([#2136](https://github.com/bazelbuild/rules_python/issues/2136)) +* (toolchain) Omit third-party python packages from coverage reports from + stage2 bootstrap template. ### Added * Nothing yet