Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix msys2 venv path #25062

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion python_files/create_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,20 @@ def run_process(args: Sequence[str], error_message: str) -> None:
raise VenvError(error_message) from exc


def get_win_venv_path(name: str) -> str:
venv_dir = CWD / name
# If using MSYS2 Python, the Python executable is located in the 'bin' directory.
if file_exists(venv_dir / "bin" / "python.exe"):
return os.fspath(venv_dir / "bin" / "python.exe")
else:
return os.fspath(venv_dir / "Scripts" / "python.exe")


def get_venv_path(name: str) -> str:
# See `venv` doc here for more details on binary location:
# https://docs.python.org/3/library/venv.html#creating-virtual-environments
if sys.platform == "win32":
return os.fspath(CWD / name / "Scripts" / "python.exe")
return get_win_venv_path(name)
else:
return os.fspath(CWD / name / "bin" / "python")

Expand Down
2 changes: 1 addition & 1 deletion python_files/tests/test_create_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def create_gitignore(_p):
def test_install_packages(install_type):
importlib.reload(create_venv)
create_venv.is_installed = lambda _x: True
create_venv.file_exists = lambda x: install_type in x
create_venv.file_exists = lambda x: install_type in str(x)

pip_upgraded = False
installing = None
Expand Down