From f6d5750e74ce6db32a5dba025a051d8f6a805723 Mon Sep 17 00:00:00 2001 From: s0600204 Date: Sun, 26 Dec 2021 20:43:40 +0000 Subject: [PATCH 1/3] Fix installing under MinGW on Windows python[.exe], when installed via (msys) MinGW on Windows, can be found under a path structure similar to that you might find on *nix systems. The install-python.py script was not taking this into consideration, causing installation failure under Windows + MinGW. A similar fault in poetry itself was resolved with python-poetry/poetry#3713. --- install-poetry.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/install-poetry.py b/install-poetry.py index 079cb68..7a2a988 100644 --- a/install-poetry.py +++ b/install-poetry.py @@ -22,6 +22,7 @@ import site import subprocess import sys +import sysconfig import tempfile from contextlib import closing @@ -36,6 +37,7 @@ SHELL = os.getenv("SHELL", "") WINDOWS = sys.platform.startswith("win") or (sys.platform == "cli" and os.name == "nt") +MINGW = sysconfig.get_platform().startswith("mingw") MACOS = sys.platform == "darwin" FOREGROUND_COLORS = { @@ -158,7 +160,7 @@ def bin_dir(version: Optional[str] = None) -> Path: user_base = site.getuserbase() - if WINDOWS: + if WINDOWS and not MINGW: bin_dir = os.path.join(user_base, "Scripts") else: bin_dir = os.path.join(user_base, "bin") @@ -273,15 +275,20 @@ def __init__(self, return_code: int = 0, log: Optional[str] = None): class VirtualEnvironment: def __init__(self, path: Path) -> None: self._path = path + self._bin_path = self._path.joinpath("Scripts" if WINDOWS and not MINGW else "bin") # str is required for compatibility with subprocess run on CPython <= 3.7 on Windows self._python = str( - self._path.joinpath("Scripts/python.exe" if WINDOWS else "bin/python") + self._path.joinpath(self._bin_path, "python.exe" if WINDOWS else "python") ) @property def path(self): return self._path + @property + def bin_path(self): + return self._bin_path + @classmethod def make(cls, target: Path) -> "VirtualEnvironment": try: @@ -602,12 +609,8 @@ def make_bin(self, version: str, env: VirtualEnvironment) -> None: self._install_comment(version, "Creating script") self._bin_dir.mkdir(parents=True, exist_ok=True) - script = "poetry" - script_bin = "bin" - if WINDOWS: - script = "poetry.exe" - script_bin = "Scripts" - target_script = env.path.joinpath(script_bin, script) + script = "poetry.exe" if WINDOWS else "poetry" + target_script = env.bin_path.joinpath(script) if self._bin_dir.joinpath(script).exists(): self._bin_dir.joinpath(script).unlink() From c52519c17e34f8ac8738740ca7f098fc7f2c4074 Mon Sep 17 00:00:00 2001 From: s0600204 Date: Sun, 26 Dec 2021 21:01:39 +0000 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e9601e2..24c8ad1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ https://install.python-poetry.org/. Poetry provides a custom installer that will install `poetry` isolated from the rest of your system. -### osx / linux / bashonwindows install instructions +### osx / linux / bashonwindows / Windows+MinGW install instructions ```bash curl -sSL https://install.python-poetry.org | python - ``` From 25e55e266cb1470b60cfe9c10deb9a635efdf9bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 26 Dec 2021 21:30:14 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- install-poetry.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install-poetry.py b/install-poetry.py index 7a2a988..6399217 100644 --- a/install-poetry.py +++ b/install-poetry.py @@ -275,7 +275,9 @@ def __init__(self, return_code: int = 0, log: Optional[str] = None): class VirtualEnvironment: def __init__(self, path: Path) -> None: self._path = path - self._bin_path = self._path.joinpath("Scripts" if WINDOWS and not MINGW else "bin") + self._bin_path = self._path.joinpath( + "Scripts" if WINDOWS and not MINGW else "bin" + ) # str is required for compatibility with subprocess run on CPython <= 3.7 on Windows self._python = str( self._path.joinpath(self._bin_path, "python.exe" if WINDOWS else "python")