mirror of
https://github.com/python-poetry/install.python-poetry.org.git
synced 2024-11-25 07:20:56 -05:00
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.
This commit is contained in:
parent
09509fbe05
commit
110f89092a
1 changed files with 11 additions and 8 deletions
|
@ -22,6 +22,7 @@ import shutil
|
||||||
import site
|
import site
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import sysconfig
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
@ -36,6 +37,7 @@ from urllib.request import urlopen
|
||||||
|
|
||||||
SHELL = os.getenv("SHELL", "")
|
SHELL = os.getenv("SHELL", "")
|
||||||
WINDOWS = sys.platform.startswith("win") or (sys.platform == "cli" and os.name == "nt")
|
WINDOWS = sys.platform.startswith("win") or (sys.platform == "cli" and os.name == "nt")
|
||||||
|
MINGW = sysconfig.get_platform().startswith("mingw")
|
||||||
MACOS = sys.platform == "darwin"
|
MACOS = sys.platform == "darwin"
|
||||||
|
|
||||||
FOREGROUND_COLORS = {
|
FOREGROUND_COLORS = {
|
||||||
|
@ -158,7 +160,7 @@ def bin_dir(version: Optional[str] = None) -> Path:
|
||||||
|
|
||||||
user_base = site.getuserbase()
|
user_base = site.getuserbase()
|
||||||
|
|
||||||
if WINDOWS:
|
if WINDOWS and not MINGW:
|
||||||
bin_dir = os.path.join(user_base, "Scripts")
|
bin_dir = os.path.join(user_base, "Scripts")
|
||||||
else:
|
else:
|
||||||
bin_dir = os.path.join(user_base, "bin")
|
bin_dir = os.path.join(user_base, "bin")
|
||||||
|
@ -273,15 +275,20 @@ class PoetryInstallationError(RuntimeError):
|
||||||
class VirtualEnvironment:
|
class VirtualEnvironment:
|
||||||
def __init__(self, path: Path) -> None:
|
def __init__(self, path: Path) -> None:
|
||||||
self._path = path
|
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
|
# str is required for compatibility with subprocess run on CPython <= 3.7 on Windows
|
||||||
self._python = str(
|
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
|
@property
|
||||||
def path(self):
|
def path(self):
|
||||||
return self._path
|
return self._path
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bin_path(self):
|
||||||
|
return self._bin_path
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def make(cls, target: Path) -> "VirtualEnvironment":
|
def make(cls, target: Path) -> "VirtualEnvironment":
|
||||||
try:
|
try:
|
||||||
|
@ -602,12 +609,8 @@ class Installer:
|
||||||
self._install_comment(version, "Creating script")
|
self._install_comment(version, "Creating script")
|
||||||
self._bin_dir.mkdir(parents=True, exist_ok=True)
|
self._bin_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
script = "poetry"
|
script = "poetry.exe" if WINDOWS else "poetry"
|
||||||
script_bin = "bin"
|
target_script = env.bin_path.joinpath(script)
|
||||||
if WINDOWS:
|
|
||||||
script = "poetry.exe"
|
|
||||||
script_bin = "Scripts"
|
|
||||||
target_script = env.path.joinpath(script_bin, script)
|
|
||||||
|
|
||||||
if self._bin_dir.joinpath(script).exists():
|
if self._bin_dir.joinpath(script).exists():
|
||||||
self._bin_dir.joinpath(script).unlink()
|
self._bin_dir.joinpath(script).unlink()
|
||||||
|
|
Loading…
Reference in a new issue