strong-crayon-70379
02/08/2019, 4:56 PMred-balloon-89377
02/08/2019, 4:58 PMtox.ini
[testenv:py36-integration]
basepython = "/this/should/be/a/link/to/python3.6.5"
commands =
; py.test tests/test_integration.py {posargs:-vvs}
py.test tests/test_integration.py {posargs}
def test_interpreter_resolution_without_pex_python_path():
# tox -e py36-integration -- -s -k test_interpreter_resolution_without_pex_python_path
# We want a test where:
# We build a pex with some interpreter-constraints set
# At construction time, we don't want either PEX_PYTHON or PEX_PYTHON_PATH set
with temporary_dir() as td:
pex_out_path = os.path.join(td, 'pex.pex')
res = run_pex_command(['--disable-cache',
'--interpreter-constraint===%s' % PY36,
'-o', pex_out_path],
# env=make_env(PATH="/usr/local/bin/python3.6") # 3.6.6
)
res.assert_success()
# We want to try to run that pex with no environment variables set
stdin_payload = b'import sys; print(sys.executable); sys.exit(0)'
# We want this to fail because it won't find python3.6.6 in the PATH, and it's looking for it.
stdout, rc = run_simple_pex(pex_out_path, stdin=stdin_payload)
assert rc == 1
--interpreter-constraints
at building time (call to run_pex_command
), and it picks a version (say 3.6.6) from the path. Then, we try to run the pex again without the same PATH variable but with the constraints recorded in the pex. This should fail, but it doesn’t.strong-crayon-70379
02/08/2019, 5:31 PM--interpreter-constraints
are only applied when PEX_PYTHON_PATH is set, not to path I believered-balloon-89377
02/08/2019, 5:48 PM