Skip to content

Commit 38adcd6

Browse files
authored
Merge branch 'main' into aignas.refactor.parse_requirements_evaluate_markers
2 parents 26ec1cc + 5511aaf commit 38adcd6

4 files changed

Lines changed: 25 additions & 10 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ END_UNRELEASED_TEMPLATE
115115
* (pypi) Fix the versions of packages that we are recording to a `MODULE.bazel.lock` file
116116
facts by passing all of the versions to the `get_index` function.
117117
Fixes [#3756](https://github.com/bazel-contrib/rules_python/issues/3756).
118+
* (bzlmod) Reduce default verbosity of our loggers for non-root modules
119+
([#3749](https://github.com/bazel-contrib/rules_python/issues/3749)).
118120

119121
{#v2-0-0}
120122
## [2.0.0] - 2026-04-09

python/private/pypi/extension.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ You cannot use both the additive_build_content and additive_build_content_file a
357357
# TODO @aignas 2025-09-06: do not use kwargs
358358
minor_mapping = kwargs.get("minor_mapping", MINOR_MAPPING),
359359
available_interpreters = kwargs.get("available_interpreters", INTERPRETER_LABELS),
360-
logger = repo_utils.logger(module_ctx, "pypi:hub:" + hub_name),
360+
logger = repo_utils.logger(module_ctx, "pypi:hub:" + hub_name, mod = mod),
361361
)
362362
pip_hub_map[pip_attr.hub_name] = builder
363363
elif pip_hub_map[hub_name].module_name != mod.name:

python/private/python.bzl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ load(
3131
)
3232
load(":version.bzl", "version")
3333

34-
def parse_modules(*, module_ctx, logger, _fail = fail):
34+
def parse_modules(*, module_ctx, logger = None, _fail = fail):
3535
"""Parse the modules and return a struct for registrations.
3636
3737
Args:
@@ -137,7 +137,7 @@ def parse_modules(*, module_ctx, logger, _fail = fail):
137137
first = first,
138138
second_toolchain_name = toolchain_name,
139139
second_module_name = mod.name,
140-
logger = logger,
140+
logger = logger or repo_utils.logger(module_ctx, "python", mod = mod),
141141
)
142142
toolchain_info = None
143143
else:
@@ -213,8 +213,10 @@ def parse_modules(*, module_ctx, logger, _fail = fail):
213213
)
214214

215215
def _python_impl(module_ctx):
216-
logger = repo_utils.logger(module_ctx, "python")
217-
py = parse_modules(module_ctx = module_ctx, logger = logger)
216+
py = parse_modules(module_ctx = module_ctx)
217+
218+
# For all other processing (after parsing the modules) let's use a single logger.
219+
logger = repo_utils.logger(module_ctx, "python", mod = module_ctx.modules[0])
218220

219221
# Host compatible runtime repos
220222
# dict[str version, struct] where struct has:

python/private/repo_utils.bzl

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _is_repo_debug_enabled(mrctx):
3131
"""
3232
return mrctx.getenv(REPO_DEBUG_ENV_VAR) == "1"
3333

34-
def _logger(mrctx = None, name = None, verbosity_level = None, printer = None):
34+
def _logger(mrctx = None, name = None, verbosity_level = None, printer = None, mod = None):
3535
"""Creates a logger instance for printing messages.
3636
3737
Args:
@@ -42,6 +42,7 @@ def _logger(mrctx = None, name = None, verbosity_level = None, printer = None):
4242
taken from `mrctx`.
4343
printer: a function to use for printing. Defaults to `print` or `fail` depending
4444
on the logging method.
45+
mod: {type}`module_ctx.module`. The module for which the logger is created.
4546
4647
Returns:
4748
A struct with attributes logging: trace, debug, info, warn, fail.
@@ -50,20 +51,30 @@ def _logger(mrctx = None, name = None, verbosity_level = None, printer = None):
5051
the logger injected into the function work as expected by terminating
5152
on the given line.
5253
"""
54+
default_verbosity_level = "WARN"
55+
if mod:
56+
if name:
57+
name = "{}:{}".format(mod.name, name)
58+
else:
59+
name = mod.name
60+
61+
if not mod.is_root:
62+
default_verbosity_level = "ERROR" # the warnings are non actionable anyway, but we should keep them.
63+
5364
if verbosity_level == None:
5465
if _is_repo_debug_enabled(mrctx):
55-
verbosity_level = "DEBUG"
56-
else:
57-
verbosity_level = "WARN"
66+
default_verbosity_level = "DEBUG"
5867

5968
env_var_verbosity = mrctx.getenv(REPO_VERBOSITY_ENV_VAR)
60-
verbosity_level = env_var_verbosity or verbosity_level
69+
verbosity_level = env_var_verbosity or default_verbosity_level
6170

6271
verbosity = {
6372
"DEBUG": 2,
73+
"ERROR": -1,
6474
"FAIL": -1,
6575
"INFO": 1,
6676
"TRACE": 3,
77+
"WARN": 0,
6778
}.get(verbosity_level, 0)
6879

6980
if hasattr(mrctx, "attr"):

0 commit comments

Comments
 (0)