Skip to content

Commit 498c33c

Browse files
committed
fix: Exclude external directory when generating python report
1 parent 425dfb0 commit 498c33c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ A brief description of the categories of changes:
2727
### Changed
2828
* Nothing yet
2929

30+
### Fixed
31+
* (rule) Omit third-party python packages from coverage reports
32+
([#2136](https://github.com/bazelbuild/rules_python/issues/2136))
33+
3034
### Added
3135
* Nothing yet
3236

python/private/stage2_bootstrap_template.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,14 @@ def _maybe_collect_coverage(enable):
364364
# Pipes can't be read back later, which can cause coverage to
365365
# throw an error when trying to get its source code.
366366
"/dev/fd/*",
367+
# The mechanism for finding third-party packages in coverage-py
368+
# only works for installed packages, not for runfiles. e.g:
369+
#'$HOME/.local/lib/python3.10/site-packages',
370+
# '/usr/lib/python',
371+
# '/usr/lib/python3.10/site-packages',
372+
# '/usr/local/lib/python3.10/dist-packages'
373+
# see https://github.com/nedbat/coveragepy/blob/bfb0c708fdd8182b2a9f0fc403596693ef65e475/coverage/inorout.py#L153-L164
374+
"*/external/*",
367375
],
368376
)
369377
cov.start()

0 commit comments

Comments
 (0)