Skip to content

Commit ce249c7

Browse files
fix(setup_python): Improve pip bootstrapping logic (#73)
1 parent 5cef39b commit ce249c7

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

actions/setup_python/action.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ runs:
135135
python --version
136136
137137
# bootstrap pip as it's not available in all Python installs (Windows with Python 2.7 mostly)
138-
# this only works for python from 2.6 to 3.8
139138
pip_exists=false
140139
if python -m pip --version >/dev/null 2>&1; then
141140
pip_exists=true
@@ -149,16 +148,26 @@ runs:
149148
version_minor=$(echo "${python_version_two_digit}" | cut -d. -f2)
150149
version_numeric=$((version_major * 100 + version_minor))
151150
152-
if [[ "${pip_exists}" == "false" ]] && [[ $version_numeric -ge 206 ]] && [[ $version_numeric -le 308 ]]; then
151+
if [[ "${pip_exists}" == "false" ]]; then
153152
echo "Bootstrapping pip for Python ${python_version_two_digit}"
153+
get_pip_url=""
154+
if [[ $version_numeric -ge 206 ]] && [[ $version_numeric -le 308 ]]; then
155+
get_pip_url="https://bootstrap.pypa.io/pip/${python_version_two_digit}/get-pip.py"
156+
elif [[ $version_numeric -gt 308 ]]; then
157+
get_pip_url="https://bootstrap.pypa.io/pip/get-pip.py"
158+
fi
154159
155-
# TODO: this isn't working for 2.7-win32 or 2.7 on windows-11-arm runner
156-
# Set environment variables to suppress SSL warnings and handle deprecation warnings
157-
export PYTHONWARNINGS="ignore:InsecurePlatformWarning"
160+
if [[ -z "${get_pip_url}" ]]; then
161+
# TODO: this isn't working for 2.7-win32 or 2.7 on windows-11-arm runner
162+
# Set environment variables to suppress SSL warnings and handle deprecation warnings
163+
export PYTHONWARNINGS="ignore:InsecurePlatformWarning"
158164
159-
curl -fsSL "https://bootstrap.pypa.io/pip/${python_version_two_digit}/get-pip.py" --output get-pip.py
160-
python get-pip.py
161-
rm -f get-pip.py
165+
curl -fsSL "${get_pip_url}" --output get-pip.py
166+
python get-pip.py
167+
rm -f get-pip.py
168+
else
169+
python -m ensurepip --default-pip
170+
fi
162171
fi
163172
164173
echo "Installing virtualenv"

0 commit comments

Comments
 (0)