Commit be8cd1fb by finswimmer Committed by Randy Döring

fix(env): get full python path for appropriate executable

parent fa29e769
......@@ -995,7 +995,7 @@ class EnvManager:
self._io.write_error_line(
f"Using <c1>{python}</c1> ({python_patch})"
)
executable = python
executable = self._full_python_path(python)
python_minor = ".".join(python_patch.split(".")[:2])
break
......
......@@ -18,6 +18,7 @@ from poetry.factory import Factory
from poetry.repositories.installed_repository import InstalledRepository
from poetry.utils._compat import WINDOWS
from poetry.utils.env import GET_BASE_PREFIX
from poetry.utils.env import GET_PYTHON_VERSION_ONELINER
from poetry.utils.env import EnvCommandError
from poetry.utils.env import EnvManager
from poetry.utils.env import GenericEnv
......@@ -1002,7 +1003,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_generic_
m.assert_called_with(
config_virtualenvs_path / f"{venv_name}-py3.7",
executable="python3",
executable="/usr/bin/python3",
flags={
"always-copy": False,
"system-site-packages": False,
......@@ -1027,7 +1028,9 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific
poetry.package.python_versions = "^3.6"
mocker.patch("sys.version_info", (2, 7, 16))
mocker.patch("subprocess.check_output", side_effect=["3.5.3", "3.9.0"])
mocker.patch(
"subprocess.check_output", side_effect=["3.5.3", "3.9.0", "/usr/bin/python3.9"]
)
m = mocker.patch(
"poetry.utils.env.EnvManager.build_venv", side_effect=lambda *args, **kwargs: ""
)
......@@ -1036,7 +1039,7 @@ def test_create_venv_tries_to_find_a_compatible_python_executable_using_specific
m.assert_called_with(
config_virtualenvs_path / f"{venv_name}-py3.9",
executable="python3.9",
executable="/usr/bin/python3.9",
flags={
"always-copy": False,
"system-site-packages": False,
......@@ -1459,11 +1462,18 @@ def test_create_venv_accepts_fallback_version_w_nonzero_patchlevel(
poetry.package.python_versions = "~3.5.1"
def mock_check_output(cmd: str, *args: Any, **kwargs: Any) -> str:
if GET_PYTHON_VERSION_ONELINER in cmd:
if "python3.5" in cmd:
return "3.5.12"
else:
return "3.7.1"
else:
return "/usr/bin/python3.5"
check_output = mocker.patch(
"subprocess.check_output",
side_effect=lambda cmd, *args, **kwargs: str(
"3.5.12" if "python3.5" in cmd else "3.7.1"
),
side_effect=mock_check_output,
)
m = mocker.patch(
"poetry.utils.env.EnvManager.build_venv", side_effect=lambda *args, **kwargs: ""
......@@ -1474,7 +1484,7 @@ def test_create_venv_accepts_fallback_version_w_nonzero_patchlevel(
assert check_output.called
m.assert_called_with(
config_virtualenvs_path / f"{venv_name}-py3.5",
executable="python3.5",
executable="/usr/bin/python3.5",
flags={
"always-copy": False,
"system-site-packages": False,
......@@ -1582,7 +1592,7 @@ def test_create_venv_project_name_empty_sets_correct_prompt(
m.assert_called_with(
config_virtualenvs_path / f"{venv_name}-py3.7",
executable="python3",
executable="/usr/bin/python3",
flags={
"always-copy": False,
"system-site-packages": False,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment