Use max compatible Python interpreter rather than minimum #7048
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
When running
./pants3
, we would expect to run subprocesses like Pytest using Python 3 as well. Instead, we resort to using Python 2—as it's the minimum acceptable—unless--python-setup-interpreter-constraints
is explicitly set to require Python 3.One workaround to this issue would be setting
PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS
to only allow Python 3, but this would mean that./pants3
could no longer be used to run targets that require Python 2 like Antlr.Further, we in general want to write Python 3-first code. Defaulting to the minimum interpreter possible does not coincide with this objective.
How to get to prior behavior
Users may go back to using the minimum interpreter through several ways:
--python-setup-interpreter-constraints
flagPANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS
pants.ini
andcompatibility
BUILD
files andcompatibility
Implications
./pants3
script #6959, Pants and CI will default to using Python 3 for subprocesses instead of Python 2—even when using Python 2 under-the-hood. This is intentional. We can use the compatibility mechanisms to force Python 2 (e.g. CI will usePANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS
to get our Py2 shards to use Python 2).brew upgrade
when 3.8 comes out, and used our internal compatibility setting of>=2.7,<3 or >=3.6,<4
and have issues like not usingcollections.abc
, then they will get aSyntaxError
. Keep in mind this only happens one a year, though, when a new version is released. Further, it is easy to constrain their compatibility to no longer allow 3.8.