Skip to content

Commit

Permalink
Fix Travis environment variable overriding interpreter_selection test…
Browse files Browse the repository at this point in the history
…'s config (#6939)

### Problem
In `test_conflict_via_config()`, we try to constraint Python to `< 2.7`. However, this fails to do anything when running on Python 3, because it's overriden by `ci.sh`'s environment variable `export PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS='["CPython>=3.5,<4"]'`.

This is expected behavior, that the environment variable overrides the command line argument. So, the issue is not with the source code, but this test should also not be failing.

### Solution
Set the integration test to be hermetic.

### Other related interpreter selection changes
* Allow Python 3.7 now that it's been fixed with #6363 
* In CI, require for Python 3 mode Python 3.5+, now that we use xenial (#6885)
  • Loading branch information
Eric-Arellano authored Dec 15, 2018
1 parent 126c311 commit 62995e3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 1 addition & 2 deletions build-support/bin/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ fi

# NB: Ordering matters here. We (currently) always bootstrap a Python 2 pex.
if [[ "${python_three:-false}" == "true" ]]; then
# The 3.4 end of this constraint is necessary to jive with the travis ubuntu trusty image.
banner "Setting interpreter constraints for 3!"
export PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS='["CPython>=3.4,<4"]'
export PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS='["CPython>=3.5,<4"]'
# TODO: Clear interpreters, otherwise this constraint does not end up applying due to a cache
# bug between the `./pants binary` and further runs.
./pants.pex clean-all
Expand Down
4 changes: 1 addition & 3 deletions testprojects/src/python/interpreter_selection/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ python_library(
sources = ['echo_interpreter_version.py'],
dependencies = [],
# Play with this to test interpreter selection in the pex machinery.
# TODO(John Sirois): Allow `<4` when the issues with `3.7` are fixed. See:
# https://github.com/pantsbuild/pants/issues/6363
compatibility = ['CPython>=2.7,<3.7']
compatibility = ['CPython>=2.7,<4']
)

python_binary(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@


class InterpreterSelectionIntegrationTest(PantsRunIntegrationTest):

testproject = 'testprojects/src/python/interpreter_selection'

@classmethod
def hermetic(cls):
# We must set as true to ignore `PANTS_PYTHON_SETUP_INTERPRETER_CONSTRAINTS`
# preconfiguring the interpreter_constraint. For example, in `ci.sh` we set
# this environment variable to Python 3, which overrides any config defined
# in the below tests.
return True

def test_cli_option_wins_compatibility_conflict(self):
# Tests that targets with compatibility conflicts collide.
binary_target = '{}:deliberately_conficting_compatibility'.format(self.testproject)
Expand Down

0 comments on commit 62995e3

Please sign in to comment.