gpt4 book ai didi

grpc - 无法在 bazel 中使用 python gRPC 规则 - 出现 "Constraints from @bazel_tools//platforms have been removed"错误

转载 作者:行者123 更新时间:2023-12-05 08:03:03 25 4
gpt4 key购买 nike

尝试使用 gRPC v1.45.0 创建一个 Python gRPC 库(升级可能很复杂,还会产生不同的问题;稍后会详细介绍)。在我的工作区中,我有

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()

load("@com_github_grpc_grpc//bazel:grpc_extra_deps.bzl", "grpc_extra_deps")

grpc_extra_deps()

当我尝试构建我的 gRPC 库时,我收到以下 bazel 错误:

Repository rule http_archive defined at:
/usr/local/home/bill/.cache/bazel/_bazel_bill/254c50c69c3701cca4e904bef759573b/external/bazel_tools/tools/build_defs/repo/http.bzl:370:31: in <toplevel>
ERROR: /usr/local/home/bill/.cache/bazel/_bazel_bill/254c50c69c3701cca4e904bef759573b/external/bazel_tools/platforms/BUILD:89:6: in alias rule @bazel_tools//platforms:windows: Constraints from @bazel_tools//platforms have been removed. Please use constraints from @platforms repository embedded in Bazel, or preferably declare dependency on https://github.com/bazelbuild/platforms. See https://github.com/bazelbuild/bazel/issues/8622 for details.
ERROR: /usr/local/home/bill/.cache/bazel/_bazel_bill/254c50c69c3701cca4e904bef759573b/external/bazel_tools/platforms/BUILD:89:6: Analysis of target '@bazel_tools//platforms:windows' failed
INFO: Repository cython instantiated at:
/usr/local/home/bill/depot/src/project/WORKSPACE:448:10: in <toplevel>
/usr/local/home/bill/.cache/bazel/_bazel_bill/254c50c69c3701cca4e904bef759573b/external/com_github_grpc_grpc/bazel/grpc_deps.bzl:458:21: in grpc_deps
/usr/local/home/bill/.cache/bazel/_bazel_bill/254c50c69c3701cca4e904bef759573b/external/com_github_grpc_grpc/bazel/grpc_python_deps.bzl:69:21: in grpc_python_deps
Repository rule http_archive defined at:
/usr/local/home/bill/.cache/bazel/_bazel_bill/254c50c69c3701cca4e904bef759573b/external/bazel_tools/tools/build_defs/repo/http.bzl:370:31: in <toplevel>

我检查了错误;它建议添加标志 --incompatible_use_platforms_repo_for_constraints。在构建时添加标志不会消除此错误。

我尝试将我的 gRPC 升级到新版本 (1.50.0),但我在 grpc_extra_deps 上遇到了不同的错误:Error in fail: go_register_toolchains: version set after go sdk rule declared (go_sdk)。显然 grpc_extra_deps 也试图在 grpc_deps 之后设置版本,我不知道如何让它不那样做。

这两个问题都发生在 gRPC 包本身,所以我不知道如何在我自己的build设置中解决它。有解决办法吗?

最佳答案

我将此错误追溯到新版本的 bazelbuild (6.0.0)。您可以通过设置环境变量强制它使用以前的版本

USE_BAZEL_VERSION=5.4.0

这为我修复了错误。祝你好运!

关于grpc - 无法在 bazel 中使用 python gRPC 规则 - 出现 "Constraints from @bazel_tools//platforms have been removed"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74815654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com