<@UBV8BCQPJ> I have an idea for that one that I ca...
# general
s
@red-balloon-89377 I have an idea for that one that I can sync with you and John on (if you havent started yet)
r
I have to leave pretty soon, but I spent most of today trying to come up with an integration test to test #656. I had something along the lines of:
Copy code
tox.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}
Copy code
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
If I understood correctly, the failure happens when: We set
--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.
s
--interpreter-constraints
are only applied when PEX_PYTHON_PATH is set, not to path I believe
r
Then I'm probably doing something wrong because that test looks for python 3.6.6