Skip to content

Defining a Skylark py_proto_library via proto_library #3935

Description

@htuch

Given #2626, I was wondering whether it would be possible to add a pure Skylark py_proto_library built on proto_library.

I've played around with rules and had a look at how rules_go does this with toolchains (https://github.com/bazelbuild/rules_go/pull/803/files). These basically involve you maintaining an additional dependency tree (which proto_library is supposed to solve) and having your custom py_proto_library applied across this tree. The most promising approach to avoiding this seems to be to use aspects.

It's pretty clear how aspects could be used to invoke protoc to generate the _pb2.py files. What's less clear is how to use these outputs, which are unknown ahead of time and come from the proto_library transitive dep provider, in conjunction with the native py_library rule (I think this is the sandwich problem?).

Any guidance here from the Bazel proto or Python teams?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)team-DocumentationDocumentation improvements that cannot be directly linked to other team labelsteam-Rules-PythonNative rules for Pythontype: documentation (cleanup)type: feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions