Hi again: I am currently getting this error: ```S...
# general
a
Hi again: I am currently getting this error:
Copy code
SetupPyError: Expected a single interpreter constraint for python/org/domain/library:library, got: CPython==3.10.* OR CPython==3.10.*,==3.9.*.
I am not sure where the interpreter constraints are generated from. For the python_distribution, we have
Copy code
kwargs["interpreter_constraints"] = ["==3.10.*"]
defined in a macro. However, in pants.toml we have it declared as
Copy code
interpreter_constraints = ["==3.10.*", "==3.9.*"]
So that the plugin code can work. I thought that adding the interpreter constrain on all the pex_binary, python_sources, python_tests, python_test_utils and on the python_distribution would ensure that this would only use python 3.10. Why is it still bringing in 3.9?
e
So, Pants supports a list of ICs but you should definitely avoid this. It's non-standard in the Python ecosystem at the very least. Can you use
[">=3.9,<3.11"]
instead of
["==3.9.**, "==3.10.**"]
- it means the same thing, but no non-standard OR.
a
I want to restrict our applications to be tested on python3.10 because that is what they will be run on, but we can't run the pants plugins on 3.10 yet.
e
Details of why aside, I'm trying to point out that the 2 forms of IC mean exactly the same thing and you should prefer the standard syntax. Have you tried my suggestion?
I'm laser-focused on the 2-item list and getting it to be 1 item. Whether that solves your problem or not, you should do it.
a
so, to ensure that code would run on python3.10, we would just need to constrain the tests to 3.10 so that they run that way
I am just trying to ensure that the code we wrote will run on a 3.10 docker image, and that after we deployed we aren't surprised because we tested on a different python version.
Additionally, when running the package locally, I would like that to run on the 3.10 python so that you are using the same as what the docker image is (but we can always run the docker image built locally, so that may not be a problem).
btw, switching to
[">=3.9,<3.11"]
did fix the problem. Thank you.
I am just trying to understand how to ensure that the code will run on the final python version it gets deployed with using the range.
e
The best way is to run the Pex with the Python you intend; i.e.
/this/exact/python my.pex
or, if you are installing the PEX in a docker image, doing said same at venv install time as per https://pex.readthedocs.io/en/v2.1.131/recipes.html#pex-app-in-a-container and https://blog.pantsbuild.org/optimizing-python-docker-deploys-using-pants/