https://pantsbuild.org/ logo
#general
Title
# general
g

gorgeous-winter-99296

10/16/2022, 5:00 PM
Does pants have any mechanism for selecting resolve for specific dependency at call-time, CLI, or something local? Or "enforce" a specific resolve for a library from different binary targets? We use
torch
in multiple of our repos; and based on hardware and other specifications we need to switch which "flavor", which is done using localtags:
+rocm
or
+cuNNN
for GPU backends,
+cpu
for "CPU-only", or nothing. I've managed to get a bunch of different resolves to work, but I'm not sure how to tie this into dependency inference for local execution, nevermind trying to publish anything using this abomination of version management.
f

fast-nail-55400

10/16/2022, 5:07 PM
Can you just build a specific resolve of your binary target? I.e., add the resolve to the address:
path/to/some:target@resolve=RESOLVE
I believe that is the parameterization syntax for addresses
h

happy-kitchen-89482

10/16/2022, 5:37 PM
yep, parametrizing targets might be the way to go here: https://www.pantsbuild.org/docs/targets#parametrizing-targets
g

gorgeous-winter-99296

10/16/2022, 5:57 PM
Awesome! And so if let's say
liba.foobar
imports
torch
, and I pass
@resolve=gpu
to
binary/main.py
does the resolve override recursively? I assume so as the opposite would be madness, just double-checking. Also; can I set a "default" parametrize?
f

fast-nail-55400

10/16/2022, 10:09 PM
Parametrized fields like
resolve
will be "passed down" correctly.
For your "root" targets, you can declare them to be in a resolve just by setting the
resolve
field directly or to multiple values using the
parametrize
builtin. (See the link above for examples.)
Not sure if there is a "default" but you could just declare separate targets with different
resolve
values if you want the target to always be in one resolve.
2 Views