Closed arpitpatel901 closed 1 year ago
A few things.
http_archive
to bring in the repo. See https://github.com/bazelbuild/platforms/releases/tag/0.0.8git_repository
if you can avoid it.load("@bazel_tools//tools/build_defs:platforms/linux.bzl", "platform")
. You should use the native platform()
rule. Avoid any use of things in @bazel_tools
because we are eliminating more from it at each Bazel release.Thanks @aiuto for the quick response ! :)
That is weird since I am building for ubuntu and running it on ubuntu too :/
I changed the import to use http
http_archive(
name = "platforms",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz",
"https://github.com/bazelbuild/platforms/releases/download/0.0.8/platforms-0.0.8.tar.gz",
],
sha256 = "8150406605389ececb6da07cbcb509d5637a3ab9a24bc69b1101531367d89d74",
)
Removed links to linux.bz[load
] in my project build file and directly used the native platform format:
platform(
name = "linux_x86",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
":glibc_2_25",
],
)
But still for some reason, during build it is trying to build for windows[did a bazel clean --expunge
in the middle]:
arpit@arpit-ThinkPad-T460s:~/bazel_ws/workspace-template/projects/python_folder/grpc$ bazel build :all
Starting local Bazel server and connecting to it...
DEBUG: Rule 'com_google_absl' indicated that a canonical reproducible form can be obtained by modifying arguments commit = "215105818dfde3174fe799600bb0f3cae233d0bf" and dropping ["tag"]
DEBUG: Repository com_google_absl instantiated at:
/home/arpit/bazel_ws/workspace-template/WORKSPACE:48:15: in <toplevel>
Repository rule git_repository defined at:
/home/arpit/.cache/bazel/_bazel_arpit/f196a2da91eeaec415a1459ab74281d6/external/bazel_tools/tools/build_defs/repo/git.bzl:181:33: in <toplevel>
ERROR: /home/arpit/.cache/bazel/_bazel_arpit/f196a2da91eeaec415a1459ab74281d6/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: /home/arpit/.cache/bazel/_bazel_arpit/f196a2da91eeaec415a1459ab74281d6/external/bazel_tools/platforms/BUILD:89:6: Analysis of target '@bazel_tools//platforms:windows' failed
ERROR: /home/arpit/.cache/bazel/_bazel_arpit/f196a2da91eeaec415a1459ab74281d6/external/upb/BUILD:83:11: errors encountered resolving select() keys for @upb//:upb
ERROR: Analysis of target '//projects/python_folder/grpc:helloworld_py_grpc' failed; build aborted:
INFO: Elapsed time: 18.628s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (82 packages loaded, 1327 targets configured)
Fetching repository @python_interpreter; starting
Fetching repository @boringssl; starting
Fetching ...81d6/external/boringssl; Extracting b9232f9e27e5668bc0414879dcdedb2a59ea75f2.tar.gz
Fetching ...f196a2da91eeaec415a1459ab74281d6/external/python_interpreter; Extracting python.tar
arpit@arpit-ThinkPad-T460s:~/bazel_ws/workspace-template/projects/python_folder/grpc$
This is how I am loading the grpc library
Inside project WORKSPACE file:
http_archive(
name = "com_github_grpc_grpc",
strip_prefix = "grpc-1.45.0",
sha256 = "ec19657a677d49af59aa806ec299c070c882986c9fcc022b1c22c2a3caf01bcd",
urls = ["https://github.com/grpc/grpc/archive/refs/tags/v1.45.0.tar.gz"],
)
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()
and then inside the project BUILD:
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@com_github_grpc_grpc//bazel:python_rules.bzl", "py_grpc_library", "py_proto_library")
Is there something wrong/outdated with my grpc imports ?
I was able to solve the platform windows
issue by following instructions from https://rules-proto-grpc.com/en/latest/lang/python.html#python-proto-compile
for writing a grpc protobuf. This particular issue is solved.
Thank you !
Currently I am attempting to build a starter grpc project with bazel[version 6.3.2]. Upon building, I get the following error, which I believe requires me to add the platform constraints[I believe the default platform is windows, while I am using an ubuntu os]:
Thus I added the following to my project
inside WORKSPACE
I then created a linux_platform.bzl file inside the workspace:
and then linked the linux_platform file inside my project BUILD file to force the build for linux os:
However this fails, with the following error:
I am new to bazel environment [previously have been using catkin/cmake], so I apologize for the noob question. What am I missing here, I see that linux.bzl is not part of the platforms repo, but I thought should it would built with the os folder. How do I provide the linux constraint ?