sort of a dumb question that i can't seem to find ...
# general
s
sort of a dumb question that i can't seem to find in the docs: let's say i have a build file like
Copy code
files(
    name = "lockfiles",
    sources = [
        "python_darwin.lock",
        "python_linux.lock",
        "python_linux_cuda.lock",
    ],
)

run_shell_command(
    name = "gen_requirements",
    # command takes four args - want to pass a lockfile like '$@'
    command = "convert_pants_lockfile_to_pip.sh $@ '<path>' '<platform-tags>' '<prefix>' --requirements",
    execution_dependencies = [
        ":shell-scripts",
        parameterize(":lockfiles"),
        "pants_tools:py311_linux_pex_platform_tags",
        "pants_tools:py311_macos_14_pex_platform_tags",
    ],
    workdir = "/",
)
Is there a pants equivalent to how bazel allows you to reference
filegroups
in
srcs
like
$(locations //:lockfiles)
? should i manually generate the targets via python in the build file?
b
So I'm answering the right question: is the goal to have one
gen_requirements
target for each of the 3 lockfiles? (i.e. a target for each of
convert_pants_lockfile_to_pip.sh python_darwin.lock ...
,
convert_pants_lockfile_to_pip.sh python_linux.lock ...
,
convert_pants_lockfile_to_pip.sh python_linux_cuda.lock ...
)
s
yep! i have a python function that works in the build file as is, but just curious if there's a better symbolic ref available via parameterize
b
A function/loop is what I would do... but I think @curved-television-6568 is our resident
parametrize
expert
c
yea,
parametrize
doesn't work well when you need to mix with other values on the same field, as in a list of dependencies, so I think using other constructs is the way to go here..
s
fair enough; the function does the trick as expected
👍 1