strong-dawn-11939
07/02/2024, 8:18 PMmypy
as well as pytest
-based tests) against all versions of Python that we support.
In the current setup, we have only one resolve
with an interpreter_constraint
set to "==3.10.*"
. Everything about the package/deploy process currently works, but, as expected, tests are only running with Python 3.10. I've tried following the docs below to accomplish, āļø, but nothing that I do has ended without a configuration problem:
⢠https://www.pantsbuild.org/2.21/docs/python/overview/interpreter-compatibility#using-multiple-python-versions-in-the-same-project
⢠https://www.pantsbuild.org/2.21/docs/python/overview/lockfiles#multiple-lockfiles
I'm wondering: is there specific documentation or an example of what I'm trying to accomplish?ancient-france-42909
07/02/2024, 8:24 PM__defaults__
. You want to set a default for interpreter_constraints
(copy pasting from our stuff) (python_sources, python_test_utils, python_source)
something like ["==3.9.*", "==3.10.*", "==3.11.*", "==3.12.*]
, for python_tests
you want parametrize of that, and your pex_binary
(that you use to deploy), to ==3.10.*
ancient-france-42909
07/02/2024, 8:27 PM__defaults__(
{
(python_sources, python_test_utils, python_source): {
"interpreter_constraints": ["==3.9.*", "==3.10.*", "==3.11.*", "==3.12.*"]
},
(python_tests): {
"interpreter_constraints": parametrize(
**{
"3_9": "==3.9.*",
"3_10": "==3.10.*",
"3_11": "==3.11.*",
"3_12": "==3.12.*",
}
)
},
(pex_binary): {"interpreter_constraints": ["==3.10.*"]},
}
)
ancient-france-42909
07/02/2024, 8:28 PMset_interpreter_constraints(supported_versions=["3_10", "3_11"], build_version="3_10")
ancient-france-42909
07/02/2024, 8:29 PMancient-france-42909
07/02/2024, 8:29 PMancient-france-42909
07/02/2024, 8:31 PMancient-france-42909
07/02/2024, 8:32 PM__defaults__(
{
(python_sources, python_test_utils, python_source): {
"interpreter_constraints": ["==3.9.*", "==3.10.*", "==3.11.*", "==3.12.*"]
},
(python_tests): {
**parametrize("3_9", interpreter_constraints="==3.9.*", resolve="lock-3_9"),
**parametrize("3_10", interpreter_constraints="==3.10.*", resolve="lock-3_10"),
**parametrize("3_11", interpreter_constraints="==3.11.*", resolve="lock-3_11"),
**parametrize("3_12", interpreter_constraints="==3.12.*", resolve="lock-3_12"),
},
(pex_binary): {"interpreter_constraints": ["==3.10.*"]},
}
)
ancient-france-42909
07/02/2024, 8:33 PMancient-france-42909
07/02/2024, 8:33 PM__defaults__(
{
(python_sources, python_test_utils, python_source): {
"interpreter_constraints": ["==3.9.*", "==3.10.*", "==3.11.*", "==3.12.*"],
"resolve": parametrize("lock-3_9", "lock-3_10", "lock-3_11", "lock-3_12")
},
(python_tests): {
**parametrize("3_9", interpreter_constraints="==3.9.*", resolve="lock-3_9"),
**parametrize("3_10", interpreter_constraints="==3.10.*", resolve="lock-3_10"),
**parametrize("3_11", interpreter_constraints="==3.11.*", resolve="lock-3_11"),
**parametrize("3_12", interpreter_constraints="==3.12.*", resolve="lock-3_12"),
},
(pex_binary): {"interpreter_constraints": ["==3.10.*"]},
}
)
strong-dawn-11939
07/02/2024, 8:35 PM_defaults_
approach yet, but, when I tried parameterizing interpreter constraints more manually, I got a configuration error along the lines of (paraphrasing, from memory) "the default resolve 'python-default' doesn't match the interpreter_constraint 3.9". I can try this out though.ancient-france-42909
07/02/2024, 8:35 PMancient-france-42909
07/02/2024, 8:36 PMancient-france-42909
07/02/2024, 8:36 PM# Creates four targets:
#
# example:tests@interpreter_constraints=py2,resolve=lock-a
# example:tests@interpreter_constraints=py2,resolve=lock-b
# example:tests@interpreter_constraints=py3,resolve=lock-a
# example:tests@interpreter_constraints=py3,resolve=lock-b
python_test(
name="tests",
source="tests.py",
interpreter_constraints=parametrize(py2=["==2.7.*"], py3=[">=3.6,<3.7"]),
resolve=parametrize("lock-a", "lock-b"),
)
ancient-france-42909
07/02/2024, 8:36 PMancient-france-42909
07/02/2024, 8:36 PM# Creates two targets:
#
# example:tests@parametrize=py2
# example:tests@parametrize=py3
python_test(
name="tests",
source="tests.py",
**parametrize("py2", interpreter_constraints=["==2.7.*"], resolve="lock-a"),
**parametrize("py3", interpreter_constraints=[">=3.6,<3.7"], resolve="lock-b"),
)
strong-dawn-11939
07/02/2024, 8:38 PMancient-france-42909
07/02/2024, 8:38 PMstrong-dawn-11939
07/02/2024, 8:43 PMrequirements.txt
file with all deps for all of the Python packages in my project, I would do something like this?
python_requirements(
name="3rdparty",
source="requirements.txt",
resolves=parametrize("lock-3_9", "lock-3_10", "lock-3_11", "lock-3_12")
)
Or is there another way I should be thinking about this?ancient-france-42909
07/02/2024, 8:44 PMancient-france-42909
07/02/2024, 8:45 PMstrong-dawn-11939
07/02/2024, 8:45 PMancient-france-42909
07/02/2024, 8:46 PMpython.resolves_to_interpreter_constraints
or whatever it's calledancient-france-42909
07/02/2024, 8:46 PMancient-france-42909
07/02/2024, 8:47 PM