Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d6b62de

Browse filesBrowse files
authored
Fix msys2 venv path (#25062)
Fix #24792
1 parent 8892ce6 commit d6b62de
Copy full SHA for d6b62de

File tree

Expand file treeCollapse file tree

2 files changed

+11
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-2
lines changed

‎python_files/create_venv.py

Copy file name to clipboardExpand all lines: python_files/create_venv.py
+10-1Lines 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

‎python_files/tests/test_create_venv.py

Copy file name to clipboardExpand all lines: python_files/tests/test_create_venv.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def create_gitignore(_p):
122122
def test_install_packages(install_type):
123123
importlib.reload(create_venv)
124124
create_venv.is_installed = lambda _x: True
125-
create_venv.file_exists = lambda x: install_type in x
125+
create_venv.file_exists = lambda x: install_type in str(x)
126126

127127
pip_upgraded = False
128128
installing = None

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.