-
-
Notifications
You must be signed in to change notification settings - Fork 677
Missing dependencies when not using latest Python version #1472
Description
🐞 bug report
Affected Rule
The issue is caused by the function:python_register_toolchains
Is this a regression?
Yes. The root cause has existed for a long time but this got more problematic in version 0.25.0 with the introduction of platformsppc64le-unknown-linux-gnu and s390x-unknown-linux-gnu.
Description
When using a WORKSPACE file and not using the latest Python versions, then there are dangling repo references to the new above-mentioned platforms. This leads to errors when doing Bazel queries on reverse dependencies.
🔬 Minimal Reproduction
Create a Bazel workspace with this WORKSPACE file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
VERSION = "0.26.0"
http_archive(
name = "rules_python",
strip_prefix = "rules_python-{}".format(VERSION),
url = "https://github.com/bazelbuild/rules_python/releases/download/{}/rules_python-{}.tar.gz".format(VERSION, VERSION),
)
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()
load("@rules_python//python:repositories.bzl", "python_register_toolchains")
python_register_toolchains(
name = "python_3_8",
python_version = "3.8",
)
then run the command
bazel query 'rdeps(@python_3_8//...,@python_3_8//:python3)'
🔥 Exception or Error
ERROR: Evaluation of query "rdeps(@python_3_8//..., @python_3_8//:python3)" failed: preloading transitive closure failed: no such package '@python_3_8_ppc64le-unknown-linux-gnu//': The repository '@python_3_8_ppc64le-unknown-linux-gnu' could not be resolved: Repository '@python_3_8_ppc64le-unknown-linux-gnu' is not defined
In a real-world workspace making a lot of use of Python, this error also shows on much more relevant and less obvious queries:
bazel cquery 'rdeps(//..., //<any_target_in_a_workspace_with_python_dependencies>)'
🌍 Your Environment
Operating System:
Ubuntu Linux 20.04
Output of bazel version:
bazel 6.3.2
Rules_python version:
0.26.0
The issue was introduced in 0.25.0 when adding two new platforms.
Anything else relevant?
The root cause of this seems to be the fact that loading a Python interpreter for some platforms and version combinations is skipped, but the aliases are always created.