pantsbuild / pants

The Pants Build System
https://www.pantsbuild.org
Apache License 2.0
3.27k stars 626 forks source link

Proto resolution mess up #21173

Open leozc opened 2 months ago

leozc commented 2 months ago

Describe the bug A python protobuf_sources dependency is checked, and reported error by JVM

pants check src/jvm::
07:44:27.11 [ERROR] 1 Exception encountered:

Engine traceback:
  in `check` goal

InvalidTargetException: src/proto/events/BUILD:1: Unrecognized field `python_resolve=python-ds` in target src/proto/events:events. Valid fields for the target type `protobuf_sources`: ['dependencies', 'description', 'go_mod_address', 'grpc', 'jvm_jdk', 'jvm_resolve', 'overrides', 'sources', 'tags'].

Pants version https://github.com/leozc/test_pants_proto/blob/main/README.md

OS MacOs, Apple Silicon

Additional info https://github.com/leozc/test_pants_proto/blob/main/README.md

benjyw commented 2 months ago

This is because the Python protobuf plugin is inferring a dependency from the protobuf_sources target to the protobuf distribution, and then the Java backend is trying to build a classpath entry out of this, and obviously cannot.

As a workaround you can turn the dep inference off with

[python-protobuf]
infer_runtime_dependency = false

in pants.toml. But then your Python side may not work, and you'll have to manually add back that dep from the relevant python_sources so it gets pulled in. Again, this is just a workaround until I figure out something more robust.

benjyw commented 2 months ago

@leozc can you add some python code that uses the python-generated protobuf code (generated from the same Event.proto) to the example repo? I'd like to see more closely how those interact.

leozc commented 2 months ago

will do

benjyw commented 1 month ago

@leozc best to @ me here and/or on Slack when this is ready, thanks!