def test_expand_interpreter_search_paths(self): local_pyenv_version = "3.5.5" all_pyenv_versions = ["2.7.14", local_pyenv_version] self.create_file(".python-version", local_pyenv_version + "\n") with environment_as(PATH="/env/path1:/env/path2"): with setup_pexrc_with_pex_python_path( ["/pexrc/path1:/pexrc/path2"]): with fake_pyenv_root(all_pyenv_versions, local_pyenv_version) as ( pyenv_root, expected_pyenv_paths, expected_pyenv_local_paths, ): paths = [ "/foo", "<PATH>", "/bar", "<PEXRC>", "/baz", "<PYENV>", "<PYENV_LOCAL>", "/qux", ] expanded_paths = PythonSetup.expand_interpreter_search_paths( paths, pyenv_root_func=lambda: pyenv_root) expected = ([ "/foo", "/env/path1", "/env/path2", "/bar", "/pexrc/path1", "/pexrc/path2", "/baz" ] + expected_pyenv_paths + expected_pyenv_local_paths + ["/qux"]) self.assertListEqual(expected, expanded_paths)
def test_expand_interpreter_search_paths(self): with environment_as(PATH="/env/path1:/env/path2"): with setup_pexrc_with_pex_python_path( ["/pexrc/path1:/pexrc/path2"]): with fake_pyenv_root(["2.7.14", "3.5.5" ]) as (pyenv_root, expected_pyenv_paths): paths = [ "/foo", "<PATH>", "/bar", "<PEXRC>", "/baz", "<PYENV>", "/qux" ] expanded_paths = PythonSetup.expand_interpreter_search_paths( paths, pyenv_root_func=lambda: pyenv_root) expected = ([ "/foo", "/env/path1", "/env/path2", "/bar", "/pexrc/path1", "/pexrc/path2", "/baz" ] + expected_pyenv_paths + ["/qux"]) self.assertListEqual(expected, expanded_paths)
def test_expand_interpreter_search_paths(rule_runner: RuleRunner) -> None: local_pyenv_version = "3.5.5" all_pyenv_versions = ["2.7.14", local_pyenv_version] rule_runner.create_file(".python-version", local_pyenv_version + "\n") with setup_pexrc_with_pex_python_path(["/pexrc/path1:/pexrc/path2"]): with fake_pyenv_root(all_pyenv_versions, local_pyenv_version) as ( pyenv_root, expected_pyenv_paths, expected_pyenv_local_paths, ): paths = [ "/foo", "<PATH>", "/bar", "<PEXRC>", "/baz", "<PYENV>", "<PYENV_LOCAL>", "/qux", ] env = Environment({ "PATH": "/env/path1:/env/path2", "PYENV_ROOT": pyenv_root }) expanded_paths = PythonSetup.expand_interpreter_search_paths( paths, env, ) expected = [ "/foo", "/env/path1", "/env/path2", "/bar", "/pexrc/path1", "/pexrc/path2", "/baz", *expected_pyenv_paths, *expected_pyenv_local_paths, "/qux", ] assert expected == expanded_paths
def test_expand_interpreter_search_paths(rule_runner: RuleRunner) -> None: local_pyenv_version = "3.5.5" all_python_versions = ["2.7.14", local_pyenv_version, "3.7.10", "3.9.4", "3.9.5"] asdf_home_versions = [0, 1, 2] asdf_local_versions = [2, 1, 4] asdf_local_versions_str = " ".join( materialize_indices(all_python_versions, asdf_local_versions) ) rule_runner.write_files( { ".python-version": f"{local_pyenv_version}\n", ".tool-versions": ( "nodejs 16.0.1\n" "java current\n" f"python {asdf_local_versions_str}\n" "rust 1.52.0\n" ), } ) with setup_pexrc_with_pex_python_path(["/pexrc/path1:/pexrc/path2"]): with fake_asdf_root(all_python_versions, asdf_home_versions, asdf_local_versions) as ( home_dir, asdf_dir, expected_asdf_paths, expected_asdf_home_paths, expected_asdf_local_paths, ), fake_pyenv_root(all_python_versions, local_pyenv_version) as ( pyenv_root, expected_pyenv_paths, expected_pyenv_local_paths, ): paths = [ "/foo", "<PATH>", "/bar", "<PEXRC>", "/baz", "<ASDF>", "<ASDF_LOCAL>", "<PYENV>", "<PYENV_LOCAL>", "/qux", ] env = Environment( { "HOME": home_dir, "PATH": "/env/path1:/env/path2", "PYENV_ROOT": pyenv_root, "ASDF_DATA_DIR": asdf_dir, } ) expanded_paths = PythonSetup.expand_interpreter_search_paths( paths, env, ) expected = [ "/foo", "/env/path1", "/env/path2", "/bar", "/pexrc/path1", "/pexrc/path2", "/baz", *expected_asdf_home_paths, *expected_asdf_local_paths, *expected_pyenv_paths, *expected_pyenv_local_paths, "/qux", ] assert expected == expanded_paths