Commit 58d2b996 by Bjorn Neergaard

refactor: once again rework get-poetry.py

The new plan is described in https://github.com/python-poetry/poetry/issues/6377.

With these changes, we see the following behaviors:

```sh
$ python get-poetry.py

Retrieving Poetry metadata

This installer is deprecated, and scheduled for removal from the Poetry repository on or after January 1, 2023.
See https://github.com/python-poetry/poetry/issues/6377 for details.

You should migrate to https://install.python-poetry.org instead, which supports all versions of Poetry, and allows for `self update` of versions 1.1.7 or newer.
Instructions are available at https://python-poetry.org/docs/#installation.

Without an explicit version, this installer will attempt to install the latest version of Poetry.
This installer cannot install Poetry 1.2.0a1 or newer (and installs will be unable to `self update` to 1.2.0a1 or newer).

To continue to use this deprecated installer, you must specify an explicit version with --version <version> or POETRY_VERSION=<version>.
Alternatively, if you wish to force this deprecated installer to use the latest installable release, set GET_POETRY_IGNORE_DEPRECATION=1.

Version 1.2.0 is not supported by this installer! Please specify a version prior to 1.2.0a1 to continue!
```
```sh
$ python get-poetry.py --version 1.2.0

Retrieving Poetry metadata

This installer is deprecated, and scheduled for removal from the Poetry repository on or after January 1, 2023.
See https://github.com/python-poetry/poetry/issues/6377 for details.

You should migrate to https://install.python-poetry.org instead, which supports all versions of Poetry, and allows for `self update` of versions 1.1.7 or newer.
Instructions are available at https://python-poetry.org/docs/#installation.

Without an explicit version, this installer will attempt to install the latest version of Poetry.
This installer cannot install Poetry 1.2.0a1 or newer (and installs will be unable to `self update` to 1.2.0a1 or newer).

To continue to use this deprecated installer, you must specify an explicit version with --version <version> or POETRY_VERSION=<version>.
Alternatively, if you wish to force this deprecated installer to use the latest installable release, set GET_POETRY_IGNORE_DEPRECATION=1.

Version 1.2.0 is not supported by this installer! Please specify a version prior to 1.2.0a1 to continue!
```
```sh
$ python get-poetry.py --version 1.1.15

Retrieving Poetry metadata

This installer is deprecated, and scheduled for removal from the Poetry repository on or after January 1, 2023.
See https://github.com/python-poetry/poetry/issues/6377 for details.

You should migrate to https://install.python-poetry.org instead, which supports all versions of Poetry, and allows for `self update` of versions 1.1.7 or newer.
Instructions are available at https://python-poetry.org/docs/#installation.

[install of 1.1.15]
```
```sh
$ GET_POETRY_IGNORE_DEPRECATION=1 python get-poetry.py

Retrieving Poetry metadata

This installer is deprecated, and scheduled for removal from the Poetry repository on or after January 1, 2023.
See https://github.com/python-poetry/poetry/issues/6377 for details.

You should migrate to https://install.python-poetry.org instead, which supports all versions of Poetry, and allows for `self update` of versions 1.1.7 or newer.
Instructions are available at https://python-poetry.org/docs/#installation.

Version 1.2.0 is available but is not supported by this installer!
Version 1.1.15 will be installed as it is the latest version supported by this installer.

This is not the latest version of Poetry! If you wish to install the latest version, you must move to the new installer as described above!

[install of 1.1.15]
```
parent b34cf21b
...@@ -21,7 +21,6 @@ import hashlib ...@@ -21,7 +21,6 @@ import hashlib
import json import json
import os import os
import platform import platform
import random
import re import re
import shutil import shutil
import stat import stat
...@@ -70,8 +69,6 @@ SHELL = os.getenv("SHELL", "") ...@@ -70,8 +69,6 @@ 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")
BROWNOUT_CHANCE = 5 # percent chance to randomly fail in CI
FOREGROUND_COLORS = { FOREGROUND_COLORS = {
"black": 30, "black": 30,
"red": 31, "red": 31,
...@@ -355,7 +352,7 @@ class Installer: ...@@ -355,7 +352,7 @@ class Installer:
version, current_version = self.get_version() version, current_version = self.get_version()
if version is None: if version is None:
return 0 return 1
self.customize_install() self.customize_install()
self.display_pre_message() self.display_pre_message()
...@@ -449,49 +446,30 @@ class Installer: ...@@ -449,49 +446,30 @@ class Installer:
print( print(
colorize( colorize(
"deprecation", "deprecation",
"This installer is deprecated, and cannot install Poetry 1.2.0a1 or" "This installer is deprecated, and scheduled for removal from the"
" newer.\nAdditionally, Poetry installations created by this installer" " Poetry repository on or after January 1, 2023.\nSee"
" cannot `self update` to 1.2.0a1 or later.\nYou should migrate to" " https://github.com/python-poetry/poetry/issues/6377 for"
" https://install.python-poetry.org instead. Instructions are available" " details.\n\nYou should migrate to https://install.python-poetry.org"
" at https://python-poetry.org/docs/#installation.\n", " instead, which supports all versions of Poetry, and allows for `self"
" update` of versions 1.1.7 or newer.\nInstructions are available at"
" https://python-poetry.org/docs/#installation.\n",
) )
) )
if not os.environ.get("GET_POETRY_IGNORE_DEPRECATION"): if not os.environ.get("GET_POETRY_IGNORE_DEPRECATION") and not self._version:
if os.environ.get("CI"): print(
print( colorize(
colorize( "deprecation",
"deprecation", "Without an explicit version, this installer will attempt to"
"A CI environment has been detected! Due to the above" " install the latest version of Poetry.\nThis installer cannot"
" deprecation, this installer is subject to an escalating" " install Poetry 1.2.0a1 or newer (and installs will be unable to"
" brownout percentage (currently {percent}%)!\nIf you" " `self update` to 1.2.0a1 or newer).\n\nTo continue to use this"
" understand the above warning and wish to opt out of this" " deprecated installer, you must specify an explicit version with"
" brownout, set GET_POETRY_IGNORE_DEPRECATION=1 in the" " --version <version> or POETRY_VERSION=<version>.\nAlternatively,"
" environment.\n".format(percent=BROWNOUT_CHANCE), " if you wish to force this deprecated installer to use the latest"
) " installable release, set GET_POETRY_IGNORE_DEPRECATION=1.\n",
)
if random.randrange(1, 100) < BROWNOUT_CHANCE:
print(
colorize(
"error",
"This invocation of the installer has been terminated due"
" to the brownout described above. Please carefully read"
" the above notices and update your CI pipeline"
" accordingly!",
)
)
return None, None
else:
print(
colorize(
"error",
"This installer will now exit. If you understand the above"
" warning and wish to proceed anyway, set"
" GET_POETRY_IGNORE_DEPRECATION=1 in the environment and run"
" this installer again.",
)
) )
return None, None )
version = self._version version = self._version
if not version: if not version:
...@@ -500,29 +478,33 @@ class Installer: ...@@ -500,29 +478,33 @@ class Installer:
if m.group(5) and not self.allows_prereleases(): if m.group(5) and not self.allows_prereleases():
continue continue
if _is_supported(release): if not os.environ.get("GET_POETRY_IGNORE_DEPRECATION"):
version = release version = release
print(
colorize(
"warning",
"Version {version} will be installed as it is the latest"
" version supported by this installer.\nThis is not the"
" latest version of Poetry! If you wish to install the"
" latest version, please migrate to the new installer as"
" described above!\n".format(version=release),
)
)
break break
else: else:
print( if _is_supported(release):
colorize( print(
"warning", colorize(
"Version {version} is available but is not supported by" "warning",
" this installer!".format(version=release), "Version {release} will be installed as it is the"
" latest version supported by this installer.\n\nThis"
" is not the latest version of Poetry! If you wish to"
" install the latest version, you must move to the new"
" installer as described above!\n".format(
release=release
),
)
)
version = release
break
else:
print(
colorize(
"warning",
"Version {release} is available but is not supported by"
" this installer!".format(release=release),
)
) )
)
if not _is_supported(version): if not _is_supported(version):
print( print(
...@@ -534,6 +516,7 @@ class Installer: ...@@ -534,6 +516,7 @@ class Installer:
), ),
) )
) )
return None, None return None, None
current_version = None current_version = None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment