Exemple #1
0
def get_pip_version_for_python_executable(python_executable: str) -> Version:
    """
    Returns pip version for the given python executable.
    """
    str_version = run_python_snippet(python_executable,
                                     "import pip;print(pip.__version__)")
    return Version(str_version)
Exemple #2
0
def get_sys_path_for_python_executable(python_executable: str) -> List[str]:
    """
    Returns sys.path list for the given python executable.
    """
    result = run_python_snippet(
        python_executable,
        "import sys;import json;print(json.dumps(sys.path))")

    paths = json.loads(result)
    assert isinstance(paths, list)
    assert all(isinstance(i, str) for i in paths)
    return [os.path.abspath(path) for path in paths]
Exemple #3
0
def test_run_python_snippet_returns_multilne():
    result = run_python_snippet(sys.executable,
                                r'print("MULTILINE\nOUTPUT", end="")')
    assert result == "MULTILINE\nOUTPUT"