Skip to content

Commit 9bc5f60

Browse files
committed
Dynamically load Setuptools and Pip versions from ensurepip
The lookup table contained older versions of setuptools than what was configured in ensurepip for the given version. By dynamically loading the versions, it is guaranteed to keep in sync.
1 parent 80b437e commit 9bc5f60

File tree

1 file changed

+2
-41
lines changed

1 file changed

+2
-41
lines changed

update.sh

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,6 @@ declare -A gpgKeys=(
2525
# https://www.python.org/dev/peps/pep-0664/#release-manager-and-crew
2626
)
2727

28-
# https://github.com/docker-library/python/issues/365
29-
# https://pypi.org/project/pip/#history
30-
declare -A pipVersions=(
31-
[3.11]='21.2' # https://github.com/python/cpython/blob/v3.11.0a1/Lib/ensurepip/__init__.py -- "_PIP_VERSION"
32-
[3.10]='21.2' # https://github.com/python/cpython/blob/3.10/Lib/ensurepip/__init__.py -- "_PIP_VERSION"
33-
[3.9]='21.2' # https://github.com/python/cpython/blob/3.9/Lib/ensurepip/__init__.py -- "_PIP_VERSION"
34-
[3.8]='21.2' # historical
35-
[3.7]='21.2' # historical
36-
)
37-
# https://pypi.org/project/setuptools/#history
38-
declare -A setuptoolsVersions=(
39-
[3.11]='57' # https://github.com/python/cpython/blob/v3.11.0a1/Lib/ensurepip/__init__.py -- "_SETUPTOOLS_VERSION"
40-
[3.10]='57' # https://github.com/python/cpython/blob/3.10/Lib/ensurepip/__init__.py -- "_SETUPTOOLS_VERSION"
41-
[3.9]='57' # https://github.com/python/cpython/blob/3.9/Lib/ensurepip/__init__.py -- "_SETUPTOOLS_VERSION"
42-
[3.8]='57' # historical
43-
[3.7]='57' # historical
44-
)
4528
# https://pypi.org/project/wheel/#history
4629
# TODO wheelVersions: https://github.com/docker-library/python/issues/365#issuecomment-914669320
4730

@@ -151,30 +134,8 @@ for version in "${versions[@]}"; do
151134
exit 1
152135
fi
153136

154-
pipVersion="${pipVersions[$rcVersion]}"
155-
pipVersion="$(
156-
export pipVersion
157-
jq <<<"$pipJson" -r '
158-
.releases
159-
| [
160-
keys_unsorted[]
161-
| select(. == env.pipVersion or startswith(env.pipVersion + "."))
162-
]
163-
| max_by(split(".") | map(tonumber))
164-
'
165-
)"
166-
setuptoolsVersion="${setuptoolsVersions[$rcVersion]}"
167-
setuptoolsVersion="$(
168-
export setuptoolsVersion
169-
jq <<<"$setuptoolsJson" -r '
170-
.releases
171-
| [
172-
keys_unsorted[]
173-
| select(. == env.setuptoolsVersion or startswith(env.setuptoolsVersion + "."))
174-
]
175-
| max_by(split(".") | map(tonumber))
176-
'
177-
)"
137+
pipVersion=$(curl -s "https://raw.githubusercontent.com/python/cpython/v$fullVersion/Lib/ensurepip/__init__.py" | sed -n -r 's/^_PIP_VERSION = "(.*?)"/\1/p')
138+
setuptoolsVersion=$(curl -s "https://raw.githubusercontent.com/python/cpython/v$fullVersion/Lib/ensurepip/__init__.py" | sed -n -r 's/^_SETUPTOOLS_VERSION = "(.*?)"/\1/p')
178139

179140
echo "$version: $fullVersion (pip $pipVersion, setuptools $setuptoolsVersion)"
180141

0 commit comments

Comments
 (0)