What is the appropriate way to specify a dependenc...
# general
g
What is the appropriate way to specify a dependency in a BUILD file when it's in two resolves?
Copy code
python_requirement(
    name="aiohttp",
    requirements=["aiohttp>=3.11.2,<4.0.0"],
    resolve=parametrize("fanny-dp", "fanny-v2"),
)
Copy code
python_sources(
    resolve=parametrize("fanny-dp", "fanny-v2"),
    dependencies=[
        "3rdparty/python:aiohttp",
    ]
)
All of these iterations fail either in CI or locally. I can't get it to work in both.
Copy code
python_sources(
    resolve=parametrize("fanny-dp", "fanny-v2"),
    dependencies=[
        "3rdparty/python:aiohttp@resolve=fanny-dp",
    ]
)
Copy code
python_sources(
    resolve=parametrize("fanny-dp", "fanny-v2"),
    dependencies=[
        "3rdparty/python:aiohttp@resolve=fanny-dp",
        "3rdparty/python:aiohttp@resolve=fanny-v2",
    ]
)
Copy code
ValueError: The explicit dependency `3rdparty/python:aiohttp` of the target at `apps/packages/fanny-opensearch-client/fanny_opensearch_client:py_typed` does not provide enough address parameters to identify which parametrization of the dependency target should be used.
Target `3rdparty/python:aiohttp` can be addressed as:
  * 3rdparty/python:aiohttp@resolve=fanny-dp
  * 3rdparty/python:aiohttp@resolve=fanny-v2
d
I believe you'll need the
**parametrize
variant as in the docs: https://www.pantsbuild.org/stable/docs/using-pants/key-concepts/targets-and-build-files#parametrizing-targets something like:
Copy code
python_sources(
    **parametrize("fanny-dp", resolve="fanny-dp", dependencies=["3rdparty/python:aiohttp@resolve=fanny-dp"],
    **parametrize("fanny-v2", resolve="fanny-v2", dependencies=["3rdparty/python:aiohttp@resolve=fanny-v2"],
)
g
Thanks. I’ll try it out.