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

ambitious-xylophone-5772

04/10/2023, 8:45 PM
Hi all - I’m trying to see if there’s a way in pants to use a different interpreter constraint in pants based on the github runner python version matrix?
The problem is that if I have my python interpreter constraint set to something like >=3.8, pants chooses the first satisfiable component, but I really want it to be testing 3.10. Of course, if I try setting the constraint to 3.10, then I can’t run tests with 3.8.
Will I have to do something with environment variables here?
h

happy-kitchen-89482

04/10/2023, 10:15 PM
Yeah, you might want to set PANTS_PYTHON_INTERPRETER_CONSTRAINTS based on the matrix value
a

ambitious-xylophone-5772

04/10/2023, 10:15 PM
If I keep the interpreter_constraint in pants.toml will the env variable take precedence?
h

happy-kitchen-89482

04/10/2023, 10:16 PM
Yes, the order of precedence for every option is command line flag > env var > config
👍 1
b

boundless-monitor-67068

12/13/2023, 10:47 AM
hi @happy-kitchen-89482 apologies for jumping in on this thread. Perhaps I'm missing something, but this doesn't work as expected:
Copy code
PANTS_TAG="-mytag" pants --tag="mytag" test ::
according to the docs (and your post), I'd expect to invoke tests for all targets tagged with mytag. However I see no action (using pants v2.18.1), even though I get the expected tests by using either the env var or the tag. The same thing holds when setting the tag in
pants.toml
h

happy-kitchen-89482

12/13/2023, 10:02 PM
try
--tag="['mytag']"
, does that work?
tag
is a list-valued option, and scalar values across different sources (config, env vars and cmd-line args) get concatenated into a list. So in your example you end up with a value of "['-mytag', 'mytag']" and I guess the first one wins. Using a list literal as the value stomps the previous values instead of concatenating.
b

boundless-monitor-67068

12/14/2023, 8:10 AM
yes it does work, thanks for the explanation 🙇