rules-proto-grpc / rules_proto_grpc

Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
https://rules-proto-grpc.com
Apache License 2.0
249 stars 156 forks source link

No such package @[unknown repo 'rules_proto_grpc_py3_deps_grpcl ib' requested from @]// #307

Closed pavannaganna closed 5 months ago

pavannaganna commented 7 months ago

Issue Description

When using python_grpclib_library the build is failing with the following error.

no such package '@[unknown repo 'rules_proto_grpc_py3_deps_grpcl
ib' requested from @]//': The repository '@[unknown repo 'rules_proto_grpc_py3_deps_grpclib' requested from @]' could not be resolved: No reposit
ory visible as '@rules_proto_grpc_py3_deps_grpclib' from main repository and referenced by '

NOTE: using python_grpc_library works as expected

Log Output

bazel build //services/greeter/protos:greeter_grpclib_py
ERROR: /home/pavannaganna/source/playground/services/greeter/protos/BUILD:23:23: no such package '@[unknown repo 'rules_proto_grpc_py3_deps_grpclib' requested from @]//': The repository '@[unknown repo 'rules_proto_
grpc_py3_deps_grpclib' requested from @]' could not be resolved: No repository visible as '@rules_proto_grpc_py3_deps_grpclib' from main repository and referenced by '//services/greeter/protos:greeter_grpclib_py'
ERROR: Analysis of target '//services/greeter/protos:greeter_grpclib_py' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.100s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)

rules_proto_grpc Version

4.6.0

Bazel Version

6.4.0

OS

Ubuntu

Link to Demo Repo

No response

MODULE.bazel or WORKSPACE Content

workspace(name = "com_devmachine_playground")

# References - GRPC bazel rules - https://rules-proto-grpc.com/en/latest/index.html
# Rules Python https://rules-python.readthedocs.io/en/stable/getting-started.html
# Rules Python WORKSPACE https://github.com/bazelbuild/rules_python/blob/main/examples/pip_parse/WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Update the SHA and VERSION to the lastest version available here:
# https://github.com/bazelbuild/rules_python/releases.

http_archive(
    name = "rules_python",
    sha256 = "5868e73107a8e85d8f323806e60cad7283f34b32163ea6ff1020cf27abef6036",
    strip_prefix = "rules_python-0.25.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.25.0/rules_python-0.25.0.tar.gz",
)

load("@rules_python//python:repositories.bzl", "py_repositories")

py_repositories()

# python_register_toolchains(
#     name = "python_3_10",
#     # Available versions are listed in @rules_python//python:versions.bzl.
#     # We recommend using the same version your team is already standardized on.
#     python_version = "3.10",
# )

# load("@python_3_10//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")

# Create a central repo that knows about the dependencies needed from
# requirements_lock.txt.
pip_parse(
    name = "pypi_3_11_external_deps",
    # python_interpreter_target = interpreter,
    # Install pip-tools
    # python3 -m pip install pip-tools
    # pip-compile --output-file=external/py/3.11/requirements_lock.txt external/py/3.11/requirements.in.txt
    requirements_lock = "//external/py/3.11:requirements_lock.txt",
)

# Load the starlark macro, which will define your dependencies.
load("@pypi_3_11_external_deps//:requirements.bzl", "install_deps")

# Call it to define repos for your requirements.
install_deps()

http_archive(
    name = "rules_proto_grpc",
    sha256 = "2a0860a336ae836b54671cbbe0710eec17c64ef70c4c5a88ccfd47ea6e3739bd",
    strip_prefix = "rules_proto_grpc-4.6.0",
    urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/releases/download/4.5.0/rules_proto_grpc-4.6.0.tar.gz"],
)

load("@rules_proto_grpc//:repositories.bzl", "rules_proto_grpc_repos", "rules_proto_grpc_toolchains")

rules_proto_grpc_toolchains()

rules_proto_grpc_repos()

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

load("@rules_proto_grpc//python:repositories.bzl", rules_proto_grpc_python_repos = "python_repos")

rules_proto_grpc_python_repos()

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()

BUILD Content

load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_proto_grpc//python:defs.bzl", "python_grpc_library", "python_grpclib_library", "python_proto_compile")

proto_library(
    name = "greeter_proto",
    srcs = ["greeter.proto"],
    visibility = ["//visibility:public"],
)

# python_proto_compile(
#     name = "greeter_proto_py",
#     protos = [":greeter_proto"],
#     visibility = ["//visibility:public"],
# )

python_grpc_library(
    name = "greeter_grpc_py",
    protos = [":greeter_proto"],
    visibility = ["//visibility:public"],
)

python_grpclib_library(
    name = "greeter_grpclib_py",
    protos = [":greeter_proto"],
    visibility = ["//visibility:public"],
)

Proto Content

syntax = "proto3";

package greeter;

service Greeter {
  rpc SayHello(HelloRequest) returns (HelloReply) {}
  rpc SayHelloStreamReply(HelloRequest) returns (stream HelloReply) {}
}

message HelloRequest {
  string name = 1;
}

message HelloReply {
  string message = 1;
}

Any Other Content

No response

aaliddell commented 7 months ago

You are missing the required lines in your WORKSPACE listed in the docs: https://rules-proto-grpc.com/en/4.5.0/lang/python.html#python-grpclib-library. Crucially the pip_parse and subsequent lines

github-actions[bot] commented 5 months ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.