What's the easiest way to add a custom argument th...
# general
b
What's the easiest way to add a custom argument that alters the build? I want to be able to include/exclude
python_requirements
based on whether GPUs are available (via a cli argument/env var/similar) but it's not immediately obvious to me how to accomplish that
b
Ah yeah, that would work but be slightly inconvenient because there are a lot of 'leaf' targets (multiple docker images etc) that would all need to be altered based on the flag. Edit: But then we could use the generic target to group them which should be fine?
d
combining with a macro or
__defaults__
may solve the problem of their are lots of places to adjust
👍 1
b
Cheers, will try that. IMO it would be nice if there was a lower boilerplate way to do it but it'll work.
I'd also appreciate advice on how to setup the conditional imports. I've configured a base and base + gpu resolve. In python code I need to do something like:
Copy code
if BUILT_WITH_GPU:
    import ...
else:
    shim = "blah"
I don't currently know how to tell pants the import should only be inferable if the base + gpu resolve is enabled.