forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Override interpreter constraints if global option is passed down (pan…
…tsbuild#6387) I commandeered @alanbato's PR at pantsbuild#6250 ## Problem The original issue is documented at pantsbuild#6081, an attempt to solve this was pantsbuild#6234, but we've decided to take another path instead. ## Solution Instead of relying on interpreter constraints when building a pex in the repl task, we're checking if the --python-setup-interpreter-constraints is flagged. If so, it overrides the interpreter filters at interpreter selection time. ## Result Users should now be able to further filter the python interpreter to use even if the task does not declare an option to do so (like in the repl task)
- Loading branch information
1 parent
ba01940
commit c0a64d0
Showing
10 changed files
with
209 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
testprojects/src/python/interpreter_selection/python_3_selection_testing/lib_py23.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# coding=utf-8 | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
|
||
def say_something(): | ||
print('I am a python 2/3 compatible library method.') | ||
# Note that ascii exists as a built-in in Python 3 and | ||
# does not exist in Python 2. | ||
try: | ||
ret = ascii | ||
except NameError: | ||
ret = 'Python2' | ||
else: | ||
ret = 'Python3' | ||
return ret |
23 changes: 23 additions & 0 deletions
23
testprojects/src/python/interpreter_selection/python_3_selection_testing/main_py23.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# coding=utf-8 | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
import sys | ||
|
||
from interpreter_selection.python_3_selection_testing.lib_py23 import say_something | ||
|
||
|
||
# A simple example to test building/running/testing a python 2 binary target | ||
|
||
|
||
def main(): | ||
v = sys.version_info | ||
print(sys.executable) | ||
print('%d.%d.%d' % v[0:3]) | ||
return say_something() | ||
|
||
if __name__ == '__main__': | ||
main() |
22 changes: 22 additions & 0 deletions
22
testprojects/src/python/interpreter_selection/python_3_selection_testing/test_py23.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# coding=utf-8 | ||
# Copyright 2017 Pants project contributors (see CONTRIBUTORS.md). | ||
# Licensed under the Apache License, Version 2.0 (see LICENSE). | ||
|
||
from __future__ import (absolute_import, division, generators, nested_scopes, print_function, | ||
unicode_literals, with_statement) | ||
|
||
import sys | ||
|
||
from interpreter_selection.python_3_selection_testing.main_py23 import main | ||
|
||
|
||
def test_main(): | ||
print(sys.executable) | ||
v = sys.version_info | ||
# Note that ascii exists as a built-in in Python 3 and | ||
# does not exist in Python 2 | ||
ret = main() | ||
if v[0] == '3': | ||
assert ret == 'Python3' | ||
else: | ||
assert ret == 'Python2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters