Skip to content

0.18.0 breaks compatibility for Bazel 5 #1056

Closed

Description

@faximan

🐞 bug report

Affected Rule

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_runtime was 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

🌍 Your Environment

**Operating System: Debian

Output of bazel version:

  
Build label: 5.4.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Thu Dec 15 16:14:25 2022 (1671120865)
Build timestamp: 1671120865
Build timestamp as int: 1671120865
  

Rules_python version:

  
0.18.0
  

Activity

  1. rickeylev commented on Feb 11, 2023

    @rickeylev
    Collaborator

    Sorry about that. Thanks for the report. This looks like an easy fix. As an interim workaround, you can manually set register_coverage_tool=False

    edit: the workaround doesn't actually work. Upgrade to 0.18.1

  2. added a commit that references this issue on Feb 11, 2023
    4f8ca60
  3. alexeagle commented on Feb 12, 2023

    @alexeagle
    Contributor

    @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.

  4. rickeylev commented on Feb 12, 2023

    @rickeylev
    Collaborator

    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?

  5. alexeagle commented on Feb 13, 2023

    @alexeagle
    Contributor

    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...

  6. added 2 commits that reference this issue on Feb 14, 2023
    83a2a63
    9ad0674
  7. carpenterjc commented on Feb 14, 2023

    @carpenterjc

    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.

  8. rickeylev commented on Feb 14, 2023

    @rickeylev
    Collaborator

    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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions