|
2 | 2 | set -Eeuo pipefail
|
3 | 3 | shopt -s nullglob
|
4 | 4 |
|
5 |
| -# TODO https://github.com/docker-library/python/pull/686 |
6 | 5 | # https://github.com/docker-library/python/issues/365
|
7 |
| -# https://pypi.org/project/pip/#history |
8 |
| -declare -A pipVersions=( |
9 |
| - [3.11]='21.2' # https://github.com/python/cpython/blob/v3.11.0a1/Lib/ensurepip/__init__.py -- "_PIP_VERSION" |
10 |
| - [3.10]='21.2' # https://github.com/python/cpython/blob/3.10/Lib/ensurepip/__init__.py -- "_PIP_VERSION" |
11 |
| - [3.9]='21.2' # https://github.com/python/cpython/blob/3.9/Lib/ensurepip/__init__.py -- "_PIP_VERSION" |
12 |
| - [3.8]='21.2' # historical |
13 |
| - [3.7]='21.2' # historical |
14 |
| -) |
15 |
| -# https://pypi.org/project/setuptools/#history |
16 |
| -declare -A setuptoolsVersions=( |
17 |
| - [3.11]='57' # https://github.com/python/cpython/blob/v3.11.0a1/Lib/ensurepip/__init__.py -- "_SETUPTOOLS_VERSION" |
18 |
| - [3.10]='57' # https://github.com/python/cpython/blob/3.10/Lib/ensurepip/__init__.py -- "_SETUPTOOLS_VERSION" |
19 |
| - [3.9]='57' # https://github.com/python/cpython/blob/3.9/Lib/ensurepip/__init__.py -- "_SETUPTOOLS_VERSION" |
20 |
| - [3.8]='57' # historical |
21 |
| - [3.7]='57' # historical |
22 |
| -) |
23 |
| -# https://pypi.org/project/wheel/#history |
24 |
| -# TODO wheelVersions: https://github.com/docker-library/python/issues/365#issuecomment-914669320 |
| 6 | +minimumPipVersion='21.2.4' |
| 7 | +minimumSetuptoolsVersion='57.5.0' |
| 8 | +# for historical reasons, these get pinned to either the version bundled with each Python version or these, whichever is higher |
25 | 9 |
|
26 | 10 | cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
|
27 | 11 |
|
|
34 | 18 | fi
|
35 | 19 | versions=( "${versions[@]%/}" )
|
36 | 20 |
|
37 |
| -pipJson="$(curl -fsSL 'https://pypi.org/pypi/pip/json')" |
38 |
| -setuptoolsJson="$(curl -fsSL 'https://pypi.org/pypi/setuptools/json')" |
39 |
| - |
40 | 21 | getPipCommit="$(curl -fsSL 'https://github.com/pypa/get-pip/commits/main/public/get-pip.py.atom' | tac|tac | awk -F '[[:space:]]*[<>/]+' '$2 == "id" && $3 ~ /Commit/ { print $4; exit }')"
|
41 | 22 | getPipUrl="https://github.com/pypa/get-pip/raw/$getPipCommit/public/get-pip.py"
|
42 | 23 | getPipSha256="$(curl -fsSL "$getPipUrl" | sha256sum | cut -d' ' -f1)"
|
@@ -139,31 +120,38 @@ for version in "${versions[@]}"; do
|
139 | 120 | exit 1
|
140 | 121 | fi
|
141 | 122 |
|
142 |
| - pipVersion="${pipVersions[$rcVersion]}" |
| 123 | + ensurepipVersions="$( |
| 124 | + wget -qO- "https://github.com/python/cpython/raw/v$fullVersion/Lib/ensurepip/__init__.py" \ |
| 125 | + | grep -E '^[^[:space:]]+_VERSION[[:space:]]*=' |
| 126 | + )" |
| 127 | + pipVersion="$(sed -nre 's/^_PIP_VERSION[[:space:]]*=[[:space:]]*"(.*?)".*/\1/p' <<<"$ensurepipVersions")" |
| 128 | + setuptoolsVersion="$(sed -nre 's/^_SETUPTOOLS_VERSION[[:space:]]*=[[:space:]]*"(.*?)".*/\1/p' <<<"$ensurepipVersions")" |
| 129 | + # make sure we got something |
| 130 | + if [ -z "$pipVersion" ] || [ -z "$setuptoolsVersion" ]; then |
| 131 | + echo >&2 "error: $version: missing either pip ($pipVersion) or setuptools ($setuptoolsVersion) version" |
| 132 | + exit 1 |
| 133 | + fi |
| 134 | + # make sure what we got is valid versions |
| 135 | + if ! wget -q -O /dev/null -o /dev/null --spider "https://pypi.org/pypi/pip/$pipVersion/json" || ! wget -q -O /dev/null -o /dev/null --spider "https://pypi.org/pypi/setuptools/$setuptoolsVersion/json"; then |
| 136 | + echo >&2 "error: $version: either pip ($pipVersion) or setuptools ($setuptoolsVersion) version seems to be invalid?" |
| 137 | + exit 1 |
| 138 | + fi |
| 139 | + |
143 | 140 | pipVersion="$(
|
144 |
| - export pipVersion |
145 |
| - jq <<<"$pipJson" -r ' |
146 |
| - .releases |
147 |
| - | [ |
148 |
| - keys_unsorted[] |
149 |
| - | select(. == env.pipVersion or startswith(env.pipVersion + ".")) |
150 |
| - ] |
151 |
| - | max_by(split(".") | map(tonumber)) |
152 |
| - ' |
| 141 | + { |
| 142 | + echo "$pipVersion" |
| 143 | + echo "$minimumPipVersion" |
| 144 | + } | sort -rV | head -1 |
153 | 145 | )"
|
154 |
| - setuptoolsVersion="${setuptoolsVersions[$rcVersion]}" |
155 | 146 | setuptoolsVersion="$(
|
156 |
| - export setuptoolsVersion |
157 |
| - jq <<<"$setuptoolsJson" -r ' |
158 |
| - .releases |
159 |
| - | [ |
160 |
| - keys_unsorted[] |
161 |
| - | select(. == env.setuptoolsVersion or startswith(env.setuptoolsVersion + ".")) |
162 |
| - ] |
163 |
| - | max_by(split(".") | map(tonumber)) |
164 |
| - ' |
| 147 | + { |
| 148 | + echo "$setuptoolsVersion" |
| 149 | + echo "$minimumSetuptoolsVersion" |
| 150 | + } | sort -rV | head -1 |
165 | 151 | )"
|
166 | 152 |
|
| 153 | + # TODO wheelVersion, somehow: https://github.com/docker-library/python/issues/365#issuecomment-914669320 |
| 154 | + |
167 | 155 | echo "$version: $fullVersion (pip $pipVersion, setuptools $setuptoolsVersion${hasWindows:+, windows})"
|
168 | 156 |
|
169 | 157 | export fullVersion pipVersion setuptoolsVersion hasWindows
|
|
0 commit comments