Hello! Is there any way to `parametrize` the `comp...
# general
b
Hello! Is there any way to
parametrize
the
complete_platforms
of a
pex_binary
target? I want to produce a few different targets, one for each platform... Here's how I would like to define the target, but
complete_platforms
expects a list
Copy code
pex_binary(
    name="bin",
    entry_point="main.py",
    complete_platforms=parametrize(
        "//:linux_x86_64_py312",
        "//:linux_arm64_py312",
        "//:macos_arm64_py312"
    ),
)
e
maybe naiive, but does
parametrize(["//:linux"], ["//:macos"])
work?
b
Oh sorry I should've posted the error message because that's the first thing I tried.
Copy code
pex_binary(
    name="bin",
    entry_point="run_squares_ray_task.py",
    complete_platforms=parametrize(
        ["//:linux_x86_64_py312"],
        ["//:linux_arm64_py312"],
        ["//:macos_arm64_py312"],
    ),
)
results in
Copy code
Original error message: unhashable type: 'list'
e
That makes sense... if you make it a tuple, does it work? (I wouldn't be surprised if something further down the chain accepts strictly a list, but worth a try)
Copy code
pex_binary(
    name="bin",
    entry_point="run_squares_ray_task.py",
    complete_platforms=parametrize(
        ("//:linux_x86_64_py312",),
        ("//:linux_arm64_py312",),
        ("//:macos_arm64_py312",),
    ),
)
b
I was having trouble getting that to work. But go figure, reading the docs one more time had the answer:
Copy code
pex_binary(
    name="bin",
    entry_point="run_squares_ray_task.py",
    complete_platforms=parametrize(
        linux_amd64=["//:linux_x86_64_py312"],
        linux_arm64=["//:linux_arm64_py312"],
        macos_arm64=["//:macos_arm64_py312"],
    ),
)
results in
Copy code
% pants list path/to/ray_job:

path/to/ray_job:bin@complete_platforms=linux_amd64
path/to/ray_job:bin@complete_platforms=linux_arm64
path/to/ray_job:bin@complete_platforms=macos_arm64
thanks for helping @elegant-florist-94385, I appreciate it 🙏
e
...not me seeing that and remembering when I had the same problem trying to set multiple env vars in various sets for some tests. Sorry I didn't remember that earlier and save you another hour haha
b
no problem