Skip to content

py_proto_library doesn't work for well-known types (Timestamp, Any, etc) #1005

@ksteuck

Description

@ksteuck

🐞 bug report

Affected Rule

The issue is caused by the rule: Possibly `py_proto_library` but maybe the culprit is in `rules_proto` or somewhere in between the two.

Is this a regression?

No

Description

the newly added py_proto_library does not work for well-known types.

🔬 Minimal Reproduction

load("@rules_cc//cc:defs.bzl", "cc_proto_library")
load("@rules_python//python:proto.bzl", "py_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

proto_library(
    name = "my_proto",
    srcs = ["my.proto"],
    deps = [
        "@com_google_protobuf//:any_proto",
    ],
)

cc_proto_library(
    name = "my_cc_proto",
    deps = [":my_proto"],
)

py_proto_library(
    name = "my_py_proto",
    deps = [":my_proto"],
)
$ cat my.proto 
syntax = 'proto2';
import "google/protobuf/any.proto";

message Foo {
}
$ bazel build my_cc_proto 
INFO: Analyzed target //:my_cc_proto (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:my_cc_proto up-to-date:
  bazel-bin/my.pb.h
  bazel-bin/my.pb.cc
  bazel-bin/libmy_proto.a
  bazel-bin/libmy_proto.so
INFO: Elapsed time: 0.205s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action

🔥 Exception or Error




$ bazel build my_py_proto
INFO: Analyzed target //:my_py_proto (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
ERROR: .../.cache/bazel/_bazel_kostik/12e5dc32b4a1cb78e6b68d6d521b6ae5/external/com_google_protobuf/BUILD.bazel:263:14: output 'external/com_google_protobuf/_virtual_imports/any_proto/google/protobuf/any_pb2.py' was not created
ERROR: .../.cache/bazel/_bazel_kostik/12e5dc32b4a1cb78e6b68d6d521b6ae5/external/com_google_protobuf/BUILD.bazel:263:14: Generating Python proto_library @com_google_protobuf//:any_proto failed: not all outputs were created or valid
Target //:my_py_proto failed to build

🌍 Your Environment

Operating System:

  
Linux
  

Output of bazel version:

  
$ bazel version
Build label: 6.0.0
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Mon Dec 19 15:52:35 2022 (1671465155)
Build timestamp: 1671465155
Build timestamp as int: 1671465155
  

Rules_python version:

  
96621391e7e8861eb448fb94b49aa1fcb9f45ba7
  

+latest rules_proto and rules_cc

Anything else relevant?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions