You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is caused by the rule: python_register_toolchains
Is this a regression?
Yes, the previous version in which this bug was not present was: 0.17.3
Description
I think #977 broke the compatibility for Bazel versions <6 as the coverage_tool attribute on py_runtimewas added in Bazel 6 .
I could not find it stated anywhere that this is WAI.
🔬 Minimal Reproduction
python_register_toolchains(
name = "local_config_python",
python_version = "3.9",
)
py_binary(
name = "foo",
srcs = ["foo.py"],
)
bazel-5.4.0 --bazelrc=/dev/null build //:foo
🔥 Exception or Error
ERROR: ~/.cache/bazel/_bazel_faximan/0920b5666e9ad52e0d97f6f97d994ed1/external/local_config_python_x86_64-unknown-linux-gnu/BUILD.bazel:62:11: @local_config_python_x86_64-unknown-linux-gnu//:py3_runtime: no such attribute 'coverage_tool' in 'py_runtime' rule
@rickeylev I think that might not be the only problem? Even with register_coverage_tool=False in a Bazel 5 repo I get
ERROR: /shared/cache/bazel/user_base/31d1af6682b925f850635e639ebdf8e8/external/python3_8_x86_64-unknown-linux-gnu/BUILD.bazel:62:11: @python3_8_x86_64-unknown-linux-gnu//:py3_runtime: no such attribute 'coverage_tool' in 'py_runtime' rule
ERROR: /home/alexeagle/Projects/a/transcoding/v1/BUILD.bazel:44:10: Target '//a/transcoding/v1:transcoding_wheel.publish' depends on toolchain '@python3_8_x86_64-unknown-linux-gnu//:python_runtimes', which cannot be found: Target '@python3_8_x86_64-unknown-linux-gnu//:python_runtimes' contains an error and its package is in error'
We should add to the 0.18.0 release notes whatever answer we come up with for Bazel 5 users as well.
That's weird. I manually tested a couple targets with 5.4 and things were OK. The only place I see coverage_tool even mentioned is in python/repositories.bzl. The only code path I see that would cause this would be if native.bazel_version was empty. Do you have a repro?
hmm, I got past it with some change, probably related to getting gazelle targets from load("@rules_python_gazelle_plugin//:* rather than load("@rules_python//gazelle:* which we've made awfully easy to get wrong...
I have run into this issue with bazel 5.3.2 and bazel 5.4.0. Works in 6.0.0
The problem is that the workaround only affects the select statement, so the attribute is still set.
Weirdly even if I add: load("@rules_python//python:defs.bzl", "py_runtime") to the top it still rejects the.
Activity
rickeylev commentedon Feb 11, 2023
Sorry about that. Thanks for the report. This looks like an easy fix.
As an interim workaround, you can manually setregister_coverage_tool=Falseedit: the workaround doesn't actually work. Upgrade to 0.18.1
Only set `py_runtime.coverage_tool` for Bazel 6 and higher. (#1061)
alexeagle commentedon Feb 12, 2023
@rickeylev I think that might not be the only problem? Even with
register_coverage_tool=Falsein a Bazel 5 repo I getWe should add to the 0.18.0 release notes whatever answer we come up with for Bazel 5 users as well.
rickeylev commentedon Feb 12, 2023
That's weird. I manually tested a couple targets with 5.4 and things were OK. The only place I see coverage_tool even mentioned is in python/repositories.bzl. The only code path I see that would cause this would be if
native.bazel_versionwas empty. Do you have a repro?alexeagle commentedon Feb 13, 2023
hmm, I got past it with some change, probably related to getting gazelle targets from
load("@rules_python_gazelle_plugin//:*rather thanload("@rules_python//gazelle:*which we've made awfully easy to get wrong...Only set `py_runtime.coverage_tool` for Bazel 6 and higher. (bazel-co…
Only set `py_runtime.coverage_tool` for Bazel 6 and higher. (#1061)
carpenterjc commentedon Feb 14, 2023
I have run into this issue with
bazel 5.3.2andbazel 5.4.0. Works in6.0.0The problem is that the workaround only affects the select statement, so the attribute is still set.
Weirdly even if I add:
load("@rules_python//python:defs.bzl", "py_runtime")to the top it still rejects the.rickeylev commentedon Feb 14, 2023
Sorry, yes, the workaround I originally posted doesn't work. I updated that post to reflect this.
0.18.1 is now released with a fix for this: https://github.com/bazelbuild/rules_python/releases/tag/0.18.1