Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
59a38bd9
Commit
59a38bd9
authored
Aug 31, 2022
by
Bjorn Neergaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: rework deprecation of get-poetry.py to include CI brownout and restructured messaging
parent
b2b49927
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
23 deletions
+82
-23
get-poetry.py
+82
-23
No files found.
get-poetry.py
View file @
59a38bd9
...
...
@@ -21,6 +21,7 @@ import hashlib
import
json
import
os
import
platform
import
random
import
re
import
shutil
import
stat
...
...
@@ -69,6 +70,8 @@ SHELL = os.getenv("SHELL", "")
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
=
{
"black"
:
30
,
"red"
:
31
,
...
...
@@ -118,6 +121,7 @@ STYLES = {
"comment"
:
style
(
"yellow"
,
None
,
None
),
"error"
:
style
(
"red"
,
None
,
None
),
"warning"
:
style
(
"yellow"
,
None
,
None
),
"deprecation"
:
style
(
"magenta"
,
None
,
None
),
}
...
...
@@ -437,6 +441,58 @@ class Installer:
return
None
,
None
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
)
print
(
colorize
(
"deprecation"
,
"This installer is deprecated, and cannot install Poetry 1.2.0a1 or"
" newer.
\n
Additionally, Poetry installations created by this installer"
" cannot `self update` to 1.2.0a1 or later.
\n
You should migrate to"
" https://install.python-poetry.org instead. Instructions are available"
" at https://python-poetry.org/docs/#installation.
\n
"
,
)
)
if
not
os
.
environ
.
get
(
"GET_POETRY_IGNORE_DEPRECATION"
):
if
os
.
environ
.
get
(
"CI"
):
print
(
colorize
(
"deprecation"
,
"A CI environment has been detected! Due to the above"
" deprecation, this installer is subject to an escalating"
" brownout percentage (currently {percent}
%
)!
\n
If you"
" understand the above warning and wish to opt out of this"
" brownout, set GET_POETRY_IGNORE_DEPRECATION=1 in the"
" environment.
\n
"
.
format
(
percent
=
BROWNOUT_CHANCE
),
)
)
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
if
not
version
:
for
release
in
reversed
(
releases
):
...
...
@@ -444,39 +500,42 @@ class Installer:
if
m
.
group
(
5
)
and
not
self
.
allows_prereleases
():
continue
version
=
release
break
if
_is_supported
(
release
):
version
=
release
print
(
colorize
(
"warning"
,
"Version {version} will be installed as it is the latest"
" version supported by this installer.
\n
This 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
),
)
)
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
)
break
else
:
print
(
colorize
(
"warning"
,
"Version {version} is available but is not supported by"
" this installer!"
.
format
(
version
=
release
),
)
)
if
not
_is_supported
(
version
):
print
(
colorize
(
"error"
,
"Version {version} does not support this installation method."
" Please specify a version prior to 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."
.
format
(
version
=
version
),
"Version {version} is not supported by this installer! Please"
" specify a version prior to 1.2.0a1 to continue!"
.
format
(
version
=
version
),
)
)
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. It is recommended to use"
" https://install.python-poetry.org instead. Instructions are"
" available at https://python-poetry.org/docs/#installation"
,
)
)
current_version
=
None
if
os
.
path
.
exists
(
POETRY_LIB
):
with
open
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment