Skip to content

Duplicated label "@com_google_protobuf//:protobuf_python" in the deps of a py_proto_library #9688

@epertoso

Description

@epertoso

What version of protobuf and what language are you using?
Version: v3.20.0
Language: Python

What operating system (Linux, Windows, ...) and version?
GNU/Linux (Debian Buster, dockerized)

What runtime / compiler are you using (e.g., python version or gcc version)
Python 3.10.3

What did you do?
Steps to reproduce the behavior:

  1. Build the test_py target in the minimal example given below ($ bazel build :test_py)

What did you expect to see
A successful build.

What did you see instead?

ERROR: /home/epertoso/test/BUILD:3:17: Label '@com_google_protobuf//:protobuf_python' is duplicated in the 'deps' attribute of rule 'test_py'
ERROR: error loading package '': Package '' contains errors
INFO: Elapsed time: 0.038s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

Make sure you include information that can help us debug (full error message, exception listing, stack trace, logs).

Anything else we should know about your project / environment
We depend on gRPC, which in turns depend on protoc-gen-validate. We saw the error after updating protobuf to v3.20, the failing target is validate_py.

The error was introduced by this PR: #9187, as the test

if default_runtime and not default_runtime in py_libs + deps:
fails because py_libs and deps contain strings, and not Labels.

Minimal example

WORKSPACE

workspace(name = "test")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "com_google_protobuf",
    sha256 = "b07772d38ab07e55eca4d50f4b53da2d998bb221575c60a4f81100242d4b4889",
    strip_prefix = "protobuf-3.20.0",
    urls = ["https://github.com/protocolbuffers/protobuf/archive/refs/tags/v3.20.0.tar.gz"],
)

load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

BUILD

load("@com_google_protobuf//:protobuf.bzl", "py_proto_library")

py_proto_library(
    name = "test_py",
    srcs = ["test.proto"],
    deps = ["@com_google_protobuf//:protobuf_python"],
)

test.proto

syntax = "proto2";
package test;

message Foo { optional int32 bar = 1; }

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions