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

alert-dawn-51425

04/14/2023, 6:17 PM
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

enough-analyst-54434

04/14/2023, 6:34 PM
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

alert-dawn-51425

04/14/2023, 7:48 PM
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

enough-analyst-54434

04/14/2023, 7:50 PM
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

alert-dawn-51425

04/14/2023, 8:10 PM
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

enough-analyst-54434

04/14/2023, 9:04 PM
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/
2 Views