Skip to content
Permalink
Browse files

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.
  • Loading branch information...
Eric-Arellano committed Feb 26, 2019
1 parent b71f164 commit 2c6fdb0094db46f776112d976edcee968fe4e67d
@@ -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:
@@ -143,7 +143,6 @@ def _create_binary(self, binary_tgt, results_dir):

# Add global and target-level interpreter compatibility constraints to pex info.
pex_builder.add_interpreter_constraints_from(constraint_tgts)
pex_builder.add_interpreter_constraint(PythonSetup.global_instance().interpreter_constraints)

# Dump everything into the builder's chroot.
for tgt in source_tgts:

0 comments on commit 2c6fdb0

Please sign in to comment.
You can’t perform that action at this time.