Skip to content

Commit e84fc04

Browse files
committed
fix venv path in case of msys2 python
1 parent 09ef3c4 commit e84fc04

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

python_files/create_venv.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,20 @@ def run_process(args: Sequence[str], error_message: str) -> None:
9898
raise VenvError(error_message) from exc
9999

100100

101+
def get_win_venv_path(name: str) -> str:
102+
venv_dir = CWD / name
103+
# If using MSYS2 Python, the Python executable is located in the 'bin' directory.
104+
if file_exists(venv_dir / "bin" / "python.exe"):
105+
return os.fspath(venv_dir / "bin" / "python.exe")
106+
else:
107+
return os.fspath(venv_dir / "Scripts" / "python.exe")
108+
109+
101110
def get_venv_path(name: str) -> str:
102111
# See `venv` doc here for more details on binary location:
103112
# https://docs.python.org/3/library/venv.html#creating-virtual-environments
104113
if sys.platform == "win32":
105-
return os.fspath(CWD / name / "Scripts" / "python.exe")
114+
return get_win_venv_path(name)
106115
else:
107116
return os.fspath(CWD / name / "bin" / "python")
108117

0 commit comments

Comments
 (0)