Commit 45b20eee by finswimmer Committed by Bjorn Neergaard

alternative generic solution by returning sys.executable

parent 5b17d708
......@@ -286,18 +286,30 @@ class Application(BaseApplication):
io = event.io
poetry = command.poetry
executable = None
find_compatible = None
# add on option to trigger this
with contextlib.suppress(CalledProcessError):
executable = decode(
subprocess.check_output(
list_to_shell_command(["pyenv", "which", "python"]),
list_to_shell_command(
[
"python",
"-c",
'"import sys; print(sys.executable)"',
]
),
shell=True,
).strip()
)
find_compatible = True
env_manager = EnvManager(poetry)
env = env_manager.create_venv(io, executable=executable)
env = env_manager.create_venv(
io, executable=executable, find_compatible=find_compatible
)
if env.is_venv() and io.is_verbose():
io.write_line(f"Using virtualenv: <comment>{env.path}</>")
......
......@@ -763,6 +763,7 @@ class EnvManager:
name: Optional[str] = None,
executable: Optional[str] = None,
force: bool = False,
find_compatible: Optional[bool] = None,
) -> Union["SystemEnv", "VirtualEnv"]:
if self._env is not None and not force:
return self._env
......@@ -812,7 +813,7 @@ class EnvManager:
# If an executable has been specified, we stop there
# and notify the user of the incompatibility.
# Otherwise, we try to find a compatible Python version.
if executable:
if executable and not find_compatible:
raise NoCompatiblePythonVersionFound(
self._poetry.package.python_versions, python_patch
)
......
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