I'm a little confused how to handle multiple pytho...
# general
h
I'm a little confused how to handle multiple python versions Some of my packages will not build with python3.8. When running
pants test ::
I'd like it to skip those packages if possible (or ignore/skip the build errors) I tried setting some interpreter constraints for those packages, but that didn't seem to help 🤔
h
If you have multiple interpreter constraints Pants should partition the tests and run each one in the appropriate interpreter
If you set the ICs for those packages and run tests on just those packages, does it still not work?
h
hmm let me check
hmm, it seems to work, let me try to push to CI one more time. Fails on CI, likely due to env setup or something 🫠 Just to confirm though, in my root
./BUILD
I have
Copy code
python_sources(
   interpreter_constraints=parametrize(py38=["==3.8.*"], py39=["==3.9.*"], py310=["==3.10.*"]),
)
Then inside
./package/BUILD
I have
Copy code
python_sources(
    name="py39",
    interpreter_constraints=[">=3.9"],
)
And
./package/tests/BUILD
Copy code
python_tests(
  interpreter_constraints=[">=3.9"],
)
h
Well, I recommend having an upper bound on those constraints
As general good practice
But what this setup says is "there are logically 3 'copies' of my
python_sources
, one for each interpreter, and the tests may not depend on the 3.8 one"
So that sounds like more or less what you intend, but I would be specific about which interpreter you mean for the tests
I.e., pick one using
==
, or parameterize the tests as well if you want to run them on multiple interpreters
That loose bound leads to weird platform-dependent behavior, based on what pythons are available to it
h
interesting! I'll try being specific with the versions
Ok this helped a lot! Beyond that, I realized I had a few other packages that required specific python versions as well. By tracking down the package (using the set of dependencies that pants failed on), I managed to get everything passing 🙏
h
Excellent!