-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pex_binary: Pass interpreter attribute as --python-shebang (#61)
The pex_binary interpreter attribute is documented as "Path to the python interpreter the pex should to use in its shebang line." However, it was not being passed when building the PEX, so it did not take effect. It is getting passed as PEX_PYTHON, which changes the interpreter used for *that invocation* of a given pex. This may have been a recent change: pex-tool/pex#53 interpreter_test.py: Add a test that reads the files and verifies that the interpreter is set correctly.
- Loading branch information
Showing
3 changed files
with
53 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python2.7 | ||
|
||
import subprocess | ||
import sys | ||
|
||
EXPECTED_OUTPUT = "I'm a pex file!\n" | ||
|
||
|
||
def test_pex(pex_path, expected_interpreter): | ||
with open(pex_path) as f: | ||
interpreter_line = f.readline() | ||
if interpreter_line != expected_interpreter: | ||
sys.stderr.write('ERROR %s: Unexpected interpreter: %s\n' % ( | ||
pex_path, repr(interpreter_line))) | ||
sys.stderr.write(' Expected: %s\n' % (repr(expected_interpreter))) | ||
sys.exit(1) | ||
|
||
# check that it can be executed | ||
output = subprocess.check_output(pex_path) | ||
assert output == EXPECTED_OUTPUT | ||
|
||
|
||
def main(): | ||
'''Tests that the pex_binary interpreter attribute works.''' | ||
|
||
if len(sys.argv) != 3: | ||
sys.stderr.write('Error: Pass path to default PEX and changed PEX\n') | ||
sys.exit(1) | ||
default_pex = sys.argv[1] | ||
changed_pex = sys.argv[2] | ||
|
||
test_pex(default_pex, '#!/usr/bin/env python2.7\n') | ||
test_pex(changed_pex, '#!/usr/bin/python2.7\n') | ||
print 'PASS' | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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