docs(coverage): document the uv.lock based coverage of the toolchains
diff --git a/docs/coverage.md b/docs/coverage.md index cf7c2fa..5e966d5 100644 --- a/docs/coverage.md +++ b/docs/coverage.md
@@ -40,11 +40,21 @@ {flag}`--coverage` flag to the same `coverage` (see {ref}`coverage-from-pypi`). ::: +With Bzlmod, the bundled `coverage` is a regular dependency of the +{obj}`py_test` and {obj}`py_binary` targets, like the {flag}`--coverage` flag +target, and it is only fetched when coverage is collected. It comes from a pip +hub that `rules_python` locks with a `uv.lock` file, which has the latest +`coverage` version for each Python version starting from 3.9 and the wheels for +all of the platforms of the toolchains. It is locked per `X.Y` Python version, +so setting `configure_coverage_tool = True` for any `X.Y.Z` toolchain enables it +for all of the toolchains of the same `X.Y` version. The {flag}`--coverage` flag +and the {attr}`py_runtime.coverage_tool` attribute take precedence over it. + :::{note} -The bundled `coverage` wheel set covers CPython 3.9 through 3.14 (with -freethreaded variants for 3.13+), and not every platform within that range. -When the interpreter that `bazel coverage` actually selects has no bundled -wheel, `configure_coverage_tool = True` produces no coverage tool and +With WORKSPACE, the bundled `coverage` wheel set covers CPython 3.9 through 3.14 +(with freethreaded variants for 3.13+), and not every platform within that +range. When the interpreter that `bazel coverage` actually selects has no +bundled wheel, `register_coverage_tool = True` produces no coverage tool and `bazel coverage` emits empty lcov data unless `coverage` is provided via {flag}`--coverage` (see {ref}`coverage-from-pypi`) or manually configured (see below). @@ -55,6 +65,12 @@ registered for but a given build never uses. ::: +:::{versionchanged} VERSION_NEXT_FEATURE +With Bzlmod, the bundled `coverage` comes from a `uv.lock` based pip hub and it +is added to the dependencies of the executables instead of being the +{attr}`py_runtime.coverage_tool` of the toolchains. +::: + ## Manually configuring coverage To manually configure coverage support, you'll need to set the
diff --git a/news/4415.changed.md b/news/4415.changed.md index 923caee..4195e7a 100644 --- a/news/4415.changed.md +++ b/news/4415.changed.md
@@ -1,7 +1,8 @@ (toolchains) With bzlmod, {attr}`python.toolchain.configure_coverage_tool` -uses the `coverage` package from the new `@rules_python_coverage` pip hub, which -locks the latest `coverage` version for each Python version starting from 3.9 -and supports all of the platforms configured with {obj}`pip.default`. Passing a -`py_library` as the {attr}`py_runtime.coverage_tool` is now the preferred way, -and using a target without `PyInfo` will be deprecated in the next version +uses the `coverage` package from a pip hub that is locked with a `uv.lock` +file in `rules_python`. It has the latest `coverage` version for each Python +version starting from 3.9 and the wheels for all of the platforms of the +toolchains. The package is added to the dependencies of the executables when +coverage is collected, like the {flag}`--coverage` flag target, instead of +being the {attr}`py_runtime.coverage_tool` of the toolchains ([#3902](https://github.com/bazel-contrib/rules_python/issues/3902)).