Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
```
Expand Down
21 changes: 13 additions & 8 deletions install-poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import site
import subprocess
import sys
import sysconfig
import tempfile

from contextlib import closing
Expand All @@ -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 = {
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -273,15 +275,22 @@ 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:
Expand Down Expand Up @@ -602,12 +611,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()
Expand Down