Skip to content

Commit caf6947

Browse files
author
SitD
committed
Fix python-poetry#3520
1 parent 22c3aad commit caf6947

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

Diff for: poetry/utils/env.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,31 @@ def activate(self, python: str, io: IO) -> "Env":
440440

441441
try:
442442
python_version = Version.parse(python)
443-
python = f"python{python_version.major}"
443+
python = f"{python_version.major}"
444444
if python_version.precision > 1:
445445
python += f".{python_version.minor}"
446+
if sys.platform == "win32":
447+
# Use Python Launcher for Windows to retrieve the path of the Python executable.
448+
python = "-" + python
449+
python = (
450+
'"'
451+
+ decode(
452+
subprocess.check_output(
453+
list_to_shell_command(
454+
[
455+
"py",
456+
python,
457+
"-c",
458+
"\"import sys; print(f'{sys.executable}', end='')\"",
459+
]
460+
),
461+
shell=True,
462+
)
463+
)
464+
+ '"'
465+
)
466+
else:
467+
python = "python" + python
446468
except ValueError:
447469
# Executable in PATH or full executable path
448470
pass

0 commit comments

Comments
 (0)