bazel-contrib/bazel-mypy-integration

bazel_skylib version problem

Closed this issue · 2 comments

Hello, I've met a problem while intergrating the new mypy-intergration. The problem might be that I have relied on many rules package like

rules_bison rules_cc rules_flex rules_foreign_cc rules_foreign_cc_bazel_version rules_java rules_m4 rules_proto
rules_python and etc

The error was

'struct' value has no field or method 'to_list'
Available attributes: difference, disjoint, intersection, is_equal, is_subset, union

I think it's the problem with bazel_skylib version conflits. While in mypy, we use version 1.0.2. It might have been used a lower version in the other packages. But in mypy, we have

def repositories():
    excludes = native.existing_rules().keys()

    rules_python_version = "0.1.0"

    if "bazel_skylib" not in excludes:
        http_archive(
            name = "bazel_skylib",
            urls = [
                "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
                "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
            ],
            sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",
        )

If bazel_skylib is already installed with a old version by the other packages, the new version 1.0.2 will not be installed. This will cause the problem I met. So, how could I do with this problem. Thanks you so much !

I found a solution:

        http_archive(
            name = "bazel_skylib",
            urls = [
                "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
                "https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.2/bazel-skylib-1.0.2.tar.gz",
            ],
            sha256 = "97e70364e9249702246c0e9444bccdc4b847bed1eb03c5a3ece4f83dfe6abc44",

Put this at the beginning of the project workspace can solve this problem, although it seems not a very good idea. But at least it works....

👋 @WeiYunKolmostar I don't think is a problem with the integration; this is a problem with Bazel's repository rules generally. The integration relies on a minimum version of Skylib and if some other dependency pulls in an earlier version there's no good way in Bazel for the integration to communicate that it doesn't support that version.