Skip to content

Commit

Permalink
Fix poetry shell on Windows when using Python installed from POSIX-li…
Browse files Browse the repository at this point in the history
…ke emulators(#8644)
  • Loading branch information
ArchGuyWu authored Nov 13, 2023
1 parent 2b50120 commit 8d7e55e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/poetry/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ def get(cls) -> Shell:

def activate(self, env: VirtualEnv) -> int | None:
activate_script = self._get_activate_script()
bin_dir = "Scripts" if WINDOWS else "bin"
if WINDOWS:
bin_path = env.path / "Scripts"
# Python innstalled via msys2 on Windows might produce a POSIX-like venv
# See https://github.com/python-poetry/poetry/issues/8638
bin_dir = "Scripts" if bin_path.exists() else "bin"
else:
bin_dir = "bin"
activate_path = env.path / bin_dir / activate_script

# mypy requires using sys.platform instead of WINDOWS constant
Expand Down

0 comments on commit 8d7e55e

Please sign in to comment.