Skip to content

Commit

Permalink
Fix python-poetry#3520
Browse files Browse the repository at this point in the history
  • Loading branch information
SitD committed Jun 29, 2021
1 parent 22c3aad commit caf6947
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,31 @@ def activate(self, python: str, io: IO) -> "Env":

try:
python_version = Version.parse(python)
python = f"python{python_version.major}"
python = f"{python_version.major}"
if python_version.precision > 1:
python += f".{python_version.minor}"
if sys.platform == "win32":
# Use Python Launcher for Windows to retrieve the path of the Python executable.
python = "-" + python
python = (
'"'
+ decode(
subprocess.check_output(
list_to_shell_command(
[
"py",
python,
"-c",
"\"import sys; print(f'{sys.executable}', end='')\"",
]
),
shell=True,
)
)
+ '"'
)
else:
python = "python" + python
except ValueError:
# Executable in PATH or full executable path
pass
Expand Down

0 comments on commit caf6947

Please sign in to comment.