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

gorgeous-eve-12553

06/03/2022, 7:34 PM
Is it possible to run multiple python versions of pants targets at a time? I'd like to simulate (or even just directly use) tox and run pytest in multiple versions of python to ensure compatibility. Maybe other targets as it makes sense.
h

hundreds-father-404

06/03/2022, 7:44 PM
It is! Via `parametrize()`: https://blog.pantsbuild.org/introducing-pants-2-11/ You'll want to set that on your
python_tests
targets, like this:
Copy code
python_tests(
  name="tests",
  interpreter_constraints=parametrize(
     py37=["==3.7.*"],
     py38=["==3.8.*"],
  ),
)
You can use a macro if it's getting tedious to type that. https://www.pantsbuild.org/docs/macros
fyi some feedback we've gotten from people is it's too hard to say "Run all the tests in my repo, but only the Py37 versions" otherwise, seems to have worked out well
g

gorgeous-eve-12553

06/03/2022, 7:50 PM
Ok, that is a fair point.
Maybe I'll avoid this for now.
Now I just need to figure out how to properly configure bandit (a problem I always face outside of using pants).
b

busy-vase-39202

06/03/2022, 8:39 PM
Sounds like something to open a feature request about...
5 Views