Skip to content

Commit 7bb1f4a

Browse files
authored
fix: Skip printing unneccesary warning. (#1407)
If the python version is explicitly provided by the root module, they should not be warned for choosing the same version that rules_python provides as default.
1 parent f4b62fc commit 7bb1f4a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

python/extensions/python.bzl

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,22 @@ def _python_impl(module_ctx):
8686
# much else that can be done. Modules don't know and can't control
8787
# what other modules do, so the first in the dependency graph wins.
8888
if toolchain_version in global_toolchain_versions:
89-
_warn_duplicate_global_toolchain_version(
90-
toolchain_version,
91-
first = global_toolchain_versions[toolchain_version],
92-
second_toolchain_name = toolchain_name,
93-
second_module_name = mod.name,
94-
)
89+
# If the python version is explicitly provided by the root
90+
# module, they should not be warned for choosing the same
91+
# version that rules_python provides as default.
92+
first = global_toolchain_versions[toolchain_version]
93+
if mod.name != "rules_python" or not first.is_root:
94+
_warn_duplicate_global_toolchain_version(
95+
toolchain_version,
96+
first = first,
97+
second_toolchain_name = toolchain_name,
98+
second_module_name = mod.name,
99+
)
95100
continue
96101
global_toolchain_versions[toolchain_version] = struct(
97102
toolchain_name = toolchain_name,
98103
module_name = mod.name,
104+
is_root = mod.is_root,
99105
)
100106

101107
# Only the root module and rules_python are allowed to specify the default

0 commit comments

Comments
 (0)