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
250 stars 157 forks source link

Allow python_proto_library (and others?) to pass data attribute #257

Closed mark-thm closed 1 year ago

mark-thm commented 1 year ago

Description

It looks like bazel_build_rule_common_attrs does not include data, and due to https://github.com/bazelbuild/bazel/issues/15727 I'd like to use data to pass along my .pyi files to downstream targets -- this is particularly useful w/r/t an in-house mypy aspect and more developer-friendly than asking developers to remember to include a types stub for the proto library in their deps alongside the proto library.

As a workaround, it seems like I can manufacture a py_library myself, but then it's a proxy lib rather than something that includes the real source files. data seems like a pretty standard *_library attr, can we include it?

aaliddell commented 1 year ago

The data attribute isn't in the implicit common attrs table here (it's in the one above, which aren't implicit and aren't guaranteed to exist), hence not being included in that bazel_build_rule_common_attrs list: https://bazel.build/reference/be/common-definitions#common-attributes

Due to the way that list is used as a filter I can't add data, since it is used internally on rules (such as python_proto_compile) that don't have a data attr.

So the solution is unfortunately to add a specific arg forward to each library rule. I'll just do this for Python for now, since nobody else has raised a use case for this in other languages.

mark-thm commented 1 year ago

Thanks!