<#19186 `protobuf_sources` interacts badly with mu...
# github-notifications
c
#19186 `protobuf_sources` interacts badly with multiple Python resolves Issue created by tgolsson Describe the bug I found two issues while trying to get a few protobuf sources to be part of multiple resolves. I'm not sure if it's a setup-specific thing, haven't set up a full repro yet. The base setup is the following: We have a set of resolves that apply to the exact same set of code. To solve this we have the following snippet in the root:
Copy code
__defaults__(
    {
        python_source: dict(resolve=parametrize("cpu", "gpu", "reqs")),
        python_sources: dict(resolve=parametrize("cpu", "gpu", "reqs")),
        pex_binary: dict(resolve=parametrize("cpu", "gpu", "reqs")),
    }
)
However; parametrizing
protobuf_sources.python_resolve
here fails with the following error: pants/src/python/pants/engine/internals/graph.py Lines 437 to 441 in </pantsbuild/pants/commit/a34feabef5400eb52472c34900ed39438dfa1d55|a34feab> Then; I tried to simply generate all the variants in a loop:
Copy code
for resolve in ['reqs', 'cpu', 'gpu']:
    protobuf_sources(
        name=f'proto_{resolve}',
        python_resolve=resolve,
        ...,
    )
However; we have two files in our set:
foo_v2
, which imports
foo_v1
. Thus, this approach to ambiguity of which
foo_v1.proto
it would be importing. Thus, I had to expand to two
protobuf_source
statements with explicit dependencies:
Copy code
for resolve in ['reqs', 'cpu', 'gpu']:
    protobuf_source(
        name=f"foo_v1_{resolve}",
        source="foo_v1.proto",
        grpc=True,
        python_resolve=resolve,
    )

    protobuf_source(
        name=f"foo_v2_{resolve}",
        source="foo_v2.proto",
        grpc=True,
        python_resolve=resolve,
        dependencies=[f":foo_v1_{resolve}"],
    )
Pants version Stable, 2.15.0 OS Linux Additional info Will try to isolate a repro soon! pantsbuild/pants