From 5f5d9000a7bf3e1b4aee78a06816c43588fa03b9 Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Mon, 31 Jan 2022 16:38:31 +0000 Subject: [PATCH] Add python3.6 pip support Since pip v22, python3.6 is not supported (the minimum version is python3.7). This patch adds the reference for the pip3.6 URL to be used instead of the default one. Closes-Bug: #1959600 Change-Id: Iab2c391d5388461fe9e9037cee81884ce8032e72 (cherry picked from commit a756f4b9681d429f2612164eb01d57c800ff2d2a) (cherry picked from commit 13da39fc2e8c6e7e30da8f58cad3d48bce4a6e51) (cherry picked from commit a4369c8bb7a7e5d9ef445de56af0dfd1cc64b730) --- tools/install_pip.sh | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/tools/install_pip.sh b/tools/install_pip.sh index 9afd2e53c2..c7bb2c6f55 100755 --- a/tools/install_pip.sh +++ b/tools/install_pip.sh @@ -38,7 +38,7 @@ FILES=$TOP_DIR/files # [1] https://opendev.org/openstack/project-config/src/branch/master/nodepool/elements/cache-devstack/source-repository-pip PIP_GET_PIP_URL=${PIP_GET_PIP_URL:-"https://bootstrap.pypa.io/get-pip.py"} -LOCAL_PIP="$FILES/$(basename $PIP_GET_PIP_URL)" +PIP_GET_PIP36_URL=${PIP_GET_PIP36_URL:-"https://bootstrap.pypa.io/pip/3.6/get-pip.py"} GetDistro echo "Distro: $DISTRO" @@ -59,12 +59,21 @@ function get_versions { function install_get_pip { + if [[ "$PYTHON3_VERSION" = "3.6" ]]; then + _pip_url=$PIP_GET_PIP36_URL + _local_pip="$FILES/$(basename $_pip_url)-py36" + else + _pip_url=$PIP_GET_PIP_URL + _local_pip="$FILES/$(basename $_pip_url)" + fi + + # If get-pip.py isn't python, delete it. This was probably an # outage on the server. - if [[ -r $LOCAL_PIP ]]; then - if ! head -1 $LOCAL_PIP | grep -q '#!/usr/bin/env python'; then - echo "WARNING: Corrupt $LOCAL_PIP found removing" - rm $LOCAL_PIP + if [[ -r $_local_pip ]]; then + if ! head -1 $_local_pip | grep -q '#!/usr/bin/env python'; then + echo "WARNING: Corrupt $_local_pip found removing" + rm $_local_pip fi fi @@ -78,22 +87,22 @@ function install_get_pip { # Thus we use curl's "-z" feature to always check the modified # since and only download if a new version is out -- but only if # it seems we downloaded the file originally. - if [[ ! -r $LOCAL_PIP || -r $LOCAL_PIP.downloaded ]]; then + if [[ ! -r $_local_pip || -r $_local_pip.downloaded ]]; then # only test freshness if LOCAL_PIP is actually there, # otherwise we generate a scary warning. local timecond="" - if [[ -r $LOCAL_PIP ]]; then - timecond="-z $LOCAL_PIP" + if [[ -r $_local_pip ]]; then + timecond="-z $_local_pip" fi curl -f --retry 6 --retry-delay 5 \ - $timecond -o $LOCAL_PIP $PIP_GET_PIP_URL || \ + $timecond -o $_local_pip $_pip_url || \ die $LINENO "Download of get-pip.py failed" - touch $LOCAL_PIP.downloaded + touch $_local_pip.downloaded fi # TODO: remove the trailing pip constraint when a proper fix # arrives for bug https://bugs.launchpad.net/devstack/+bug/1906322 - sudo -H -E python${PYTHON3_VERSION} $LOCAL_PIP -c $TOOLS_DIR/cap-pip.txt + sudo -H -E python${PYTHON3_VERSION} $_local_pip -c $TOOLS_DIR/cap-pip.txt }