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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ python install-poetry.py --git https://github.com/python-poetry/poetry.git@maste

Updating poetry to the latest stable version is as simple as calling the `self update` command.

**Warning**: Poetry versions installed using the now deprecated `get-poetry.py` installer will not be able to use this
command to update to 1.2 releases or later. Migrate to using the `install-poetry.py` installer or `pipx`.

```bash
poetry self update
```
Expand Down
5 changes: 5 additions & 0 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ pip install --user poetry

Updating Poetry to the latest stable version is as simple as calling the `self update` command.

!!!warning

Poetry versions installed using the now deprecated `get-poetry.py` installer will not be able to use this
command to update to 1.2 releases or later. Migrate to using the `install-poetry.py` installer or `pipx`.

```bash
poetry self update
```
Expand Down
29 changes: 28 additions & 1 deletion get-poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,33 @@ def _compare_versions(x, y):

break

def _is_supported(x):
mx = self.VERSION_REGEX.match(x)
vx = tuple(int(p) for p in mx.groups()[:3]) + (mx.group(5),)
return vx < (1, 2, 0)

if not _is_supported(version):
print(
colorize(
"error",
f"Version {version} does not support this installation method. Please specify a version prior to "
f"1.2.0a1 explicitly using the '--version' option.\n"
"Please see "
"https://python-poetry.org/blog/announcing-poetry-1-2-0a1.html#deprecation-of-the-get-poetry-py-script "
"for more information.",
)
)
return None, None

print(
colorize(
"warning",
"This installer is deprecated. "
"Poetry versions installed using this script will not be able to use 'self update' command to upgrade to "
"1.2.0a1 or later.",
)
)

current_version = None
if os.path.exists(POETRY_LIB):
with open(
Expand Down Expand Up @@ -824,7 +851,7 @@ def set_windows_path_var(self, value):
HWND_BROADCAST,
WM_SETTINGCHANGE,
0,
u"Environment",
"Environment",
SMTO_ABORTIFHUNG,
5000,
ctypes.byref(result),
Expand Down
18 changes: 18 additions & 0 deletions install-poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,24 @@ def run(self) -> int:
self.display_pre_message()
self.ensure_directories()

def _is_self_upgrade_supported(x):
mx = self.VERSION_REGEX.match(x)
vx = tuple(int(p) for p in mx.groups()[:3]) + (mx.group(5),)
return vx >= (1, 2, 0)

if not _is_self_upgrade_supported(version):
self._write(
colorize(
"warning",
f"You are installing {version}. When using the current installer, this version does not support "
f"updating using the 'self update' command. Please use 1.2.0a1 or later.",
)
)
if not self._accept_all:
continue_install = input("Do you want to continue? ([y]/n) ") or "y"
if continue_install.lower() in {"n", "no"}:
return 0

try:
self.install(version)
except subprocess.CalledProcessError as e:
Expand Down