Please sign in to comment.
Propagate global interpreter constraints when building PEXes with int…
…erpreter constraints requested (#7285) ### Problem When running `./pants binary`, we do not consider the global interpreter constraints in passing them to the Pex builder. This resulted in a bug where the interpreter used to build a PEX in CI differed from the Python used to run the PEX. See pantsbuild/pex#676. To resolve this issue, we need some way to specify the Pex builder must use the specific Python version 2.7.13 (UCS4). This blocks #7235. ### Solution Modify `PexBuilderWrapper` to use `compatibility_or_constrains()`. This will first try to get the compatibility constraints from the target itself, and then resort to using the PythonSetup subsystem's constraints (for the global instance, resolved from `pants.ini`, `PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS`, and `--interpreter-constraints`). ### Result Users of the function `add_interpreter_constraints_from()` will now add the global `--interpreter-constraints` to the Pex builder if the targets do not themselves specify a constraint. At the moment, this only impacts `./pants binary`, as `python_binary_create.py` is the only file which uses this function. Note this is still not a great solution. It would be better to kill `add_interpreter_constraint()` and `add_interpreter_constraints_from()` to instead automatically set the interpreter constraints from the targets' graph. This PR does not make that change to avoid scope creep. #### Skipped tests Due to pantsbuild/pex#655, we must now skip several tests that now fail. PEX does not correctly OR interpreter constraints, so these tests complain that they cannot find an appropriate interpreter to satisfy `['CPython>=3.6,<4', 'CPython>=2.7,<3']`. Because this PR blocks #7235, which blocks #7197, we skip these tests until the upstream fix pantsbuild/pex#678 is merged into PEX and Pants upgrades its PEX to the new version #7186.
- Loading branch information...
Showing with 25 additions and 3 deletions.
- +3 −2 src/python/pants/backend/python/subsystems/pex_build_util.py
- +2 −1 src/python/pants/backend/python/tasks/python_binary_create.py
- +10 −0 tests/python/pants_test/backend/python/tasks/test_pytest_run_integration.py
- +10 −0 tests/python/pants_test/backend/python/tasks/test_python_run_integration.py