From 1be9e901c5eb192c2221b9beff2043d47622213b Mon Sep 17 00:00:00 2001 From: Eric Arellano Date: Mon, 25 Feb 2019 22:41:04 -0700 Subject: [PATCH] Squashed commit of the following: commit 6b07abd8a48164a183298da784730f06238b2be2 Author: Eric Arellano Date: Mon Feb 25 21:49:52 2019 -0700 Remove bad import My bad for not catching this before pushing. commit 2c6fdb0094db46f776112d976edcee968fe4e67d Author: Eric Arellano Date: Mon Feb 25 21:37:41 2019 -0700 Generify solution by using compatibility_or_constraints() Instead of applying a bandaid for only `./pants binary`, John proposed fixing the issue with our PexBuilderWrapper itself. So, we use `compatibility_or_constrains()`, which will first try to return the target's compatibility, else will return the Python Setup subystem's value. The wrapper still is not ideal and John proposes killing add_interpreter_constraint() and add_interpreter_constraints_from() to instead automatically be setting the interpreter constraints from the targets graph. This PR does not make that change for the scope, but this should be noted. commit b71f16449a8097e68ae04fef25f22d7314b0f23b Author: Eric Arellano Date: Mon Feb 25 21:03:46 2019 -0700 Fix typo commit 3bca020672cfe3a3eb44ca21dcb199f84da03ec6 Author: Eric Arellano Date: Mon Feb 25 20:31:14 2019 -0700 Add global interpreter constraints to Python binary creation commit 887a8ef035a81b79826f7c3b93231586b8a07c10 Author: Eric Arellano Date: Fri Feb 22 21:05:50 2019 -0700 Constrain ci.sh to the exact Python interpreter version Earlier we allowed the patch version to float. We discovered in https://github.com/pantsbuild/pants/pull/7235 with the CI run https://travis-ci.org/pantsbuild/pants/jobs/497208431#L891 that PEX was building with 2.7.10 but running with 2.7.13. The fix will require having Pants pass interpreter constraints to Pex. Even with that change though, the CI shard would still have the issue because the constraint would be floating. Now, we have the constraint be exact. --- .../pants/backend/python/subsystems/pex_build_util.py | 6 +++--- .../pants/backend/python/tasks/python_binary_create.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/python/pants/backend/python/subsystems/pex_build_util.py b/src/python/pants/backend/python/subsystems/pex_build_util.py index 49ae5508931..6b6037f213b 100644 --- a/src/python/pants/backend/python/subsystems/pex_build_util.py +++ b/src/python/pants/backend/python/subsystems/pex_build_util.py @@ -255,9 +255,9 @@ def add_interpreter_constraints_from(self, constraint_tgts): # TODO this would be a great place to validate the constraints and present a good error message # if they are incompatible because all the sources of the constraints are available. # See: https://github.com/pantsbuild/pex/blob/584b6e367939d24bc28aa9fa36eb911c8297dac8/pex/interpreter_constraints.py - for tgt in constraint_tgts: - for constraint in tgt.compatibility: - self.add_interpreter_constraint(constraint) + constraints = {self._python_setup_subsystem.compatibility_or_constraints(tgt) for tgt in constraint_tgts} + for constraint in constraints: + self.add_interpreter_constraint(constraint) def add_direct_requirements(self, reqs): for req in reqs: diff --git a/src/python/pants/backend/python/tasks/python_binary_create.py b/src/python/pants/backend/python/tasks/python_binary_create.py index dc30234b909..66345d270d5 100644 --- a/src/python/pants/backend/python/tasks/python_binary_create.py +++ b/src/python/pants/backend/python/tasks/python_binary_create.py @@ -141,7 +141,7 @@ def _create_binary(self, binary_tgt, results_dir): if is_python_target(tgt): constraint_tgts.append(tgt) - # Add global and target-level interpreter compatibility constraints to pex info. + # Add target-level and possibly global interpreter compatibility constraints to pex info. pex_builder.add_interpreter_constraints_from(constraint_tgts) pex_builder.add_interpreter_constraint(PythonSetup.global_instance().interpreter_constraints)