Files
40142e880ba6f4610798758a2f359b644c83d2ad
devstack /tools /install_pip.sh

150 lines
4.7 KiB
Bash
Raw Normal View History

# **install_pip.sh**
# Update pip and friends to a known common version
# Assumptions:
TOOLS_DIR=$(cd $(dirname "0ドル") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
# Import common functions
set -o xtrace
# get-pip.py mirror is available, PIP_GET_PIP_URL can be set to that
# mirror in local.conf to avoid download timeouts.
# Example:
# PIP_GET_PIP_URL="http://local-server/get-pip.py"
#
# Note that if get-pip.py already exists in $FILES this script will
# not re-download or check for a new version. For example, this is
# done by openstack-infra diskimage-builder elements as part of image
# preparation [1]. This prevents any network access, which can be
# unreliable in CI situations.
PIP_GET_PIP_URL=${PIP_GET_PIP_URL:-"https://bootstrap.pypa.io/get-pip.py"}
GetDistro
echo "Distro: $DISTRO"
# is just used for reporting, so maybe not?
PIP_VERSION=$($PIP --version | awk '{ print 2ドル}')
echo "pip: Not Installed"
}
_local_pip="$FILES/$(basename $_pip_url)"
# outage on the server.
if ! head -1 $_local_pip | grep -q '#!/usr/bin/env python'; then
echo "WARNING: Corrupt $_local_pip found removing"
rm $_local_pip
fi
# The OpenStack gate and others put a cached version of get-pip.py
#
# However, if DevStack *did* download the file, we want to check
# for updates; people can leave their stacks around for a long
#
# 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.
# otherwise we generate a scary warning.
local timecond=""
timecond="-z $_local_pip"
PIP_ROOT_FOLDER="$HOME/.pip"
PIP_CONFIG_FILE="$PIP_ROOT_FOLDER/pip.conf"
if [[ ! -d $PIP_ROOT_FOLDER ]]; then
echo "Creating $PIP_ROOT_FOLDER"
mkdir $PIP_ROOT_FOLDER
fi
if [[ ! -f $PIP_CONFIG_FILE ]]; then
echo "Creating $PIP_CONFIG_FILE"
touch $PIP_CONFIG_FILE
fi
if ! ini_has_option "$PIP_CONFIG_FILE" "global" "index-url"; then
fi
}
get_versions
configure_pypi_alternative_url
fi
# Fedora 34 any more.
# https://bugzilla.redhat.com/show_bug.cgi?id=1988935
# https://github.com/pypa/pip/issues/9904
# You can still install using get-pip.py if python3-pip is *not*
# installed; this *should* remain separate under /usr/local and not break
# if python3-pip is later installed.
# For general sanity, we just use the packaged pip. It should be
sed -i -e '/setuptools/d' $REQUIREMENTS_DIR/upper-constraints.txt
install_get_pip
# Note setuptools is part of requirements.txt and we want to make sure
# we obey any versioning as described there.
pip_install_gr setuptools