diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b59b6830e..c1bbb77709 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - Ship a [zipapp](https://docs.python.org/3/library/zipapp.html) of pipx - Change the program name to `path/to/python -m pipx` when running as `python -m pipx` +- Improve the detection logic for MSYS2 to avoid entering infinite loop (#908) - Remove extra trailing quote from exception message ## 1.1.0 diff --git a/src/pipx/constants.py b/src/pipx/constants.py index 34b2ea9740..6373b660ae 100644 --- a/src/pipx/constants.py +++ b/src/pipx/constants.py @@ -1,5 +1,6 @@ import os import sys +import sysconfig from pathlib import Path from textwrap import dedent from typing import NewType, Optional @@ -38,7 +39,12 @@ def is_windows() -> bool: return sys.platform == "win32" +def is_mingw() -> bool: + return sysconfig.get_platform() == "mingw" + + WINDOWS: bool = is_windows() +MINGW: bool = is_mingw() completion_instructions = dedent( """ diff --git a/src/pipx/util.py b/src/pipx/util.py index 5c872fcb83..b390fffe28 100644 --- a/src/pipx/util.py +++ b/src/pipx/util.py @@ -23,7 +23,7 @@ import pipx.constants from pipx.animate import show_cursor -from pipx.constants import PIPX_TRASH_DIR, WINDOWS +from pipx.constants import MINGW, PIPX_TRASH_DIR, WINDOWS logger = logging.getLogger(__name__) @@ -115,7 +115,7 @@ def run_pypackage_bin(bin_path: Path, args: List[str]) -> NoReturn: if WINDOWS: def get_venv_paths(root: Path) -> Tuple[Path, Path]: - bin_path = root / "Scripts" + bin_path = root / "Scripts" if not MINGW else root / "bin" python_path = bin_path / "python.exe" return bin_path, python_path