62d1d698 |
#!/usr/bin/env bash
# **install_pip.sh**
|
dace92f5 |
# install_pip.sh [--pip-version <version>] [--use-get-pip] [--force] |
62d1d698 |
#
# Update pip and friends to a known common version
# Assumptions:
# - update pip to $INSTALL_PIP_VERSION
|
c85ade77 |
set -o errexit
set -o xtrace
|
62d1d698 |
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
# Change dir to top of devstack
cd $TOP_DIR
# Import common functions
source $TOP_DIR/functions
FILES=$TOP_DIR/files
|
7b63c5ec |
PIP_GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py |
f625ffe2 |
LOCAL_PIP="$FILES/$(basename $PIP_GET_PIP_URL)" |
62d1d698 |
GetDistro
echo "Distro: $DISTRO"
|
aee18c74 |
function get_versions { |
46ea7238 |
PIP=$(which pip 2>/dev/null || which pip-python 2>/dev/null || true) |
62d1d698 |
if [[ -n $PIP ]]; then
PIP_VERSION=$($PIP --version | awk '{ print $2}') |
dace92f5 |
echo "pip: $PIP_VERSION" |
46ea7238 |
else
echo "pip: Not Installed" |
62d1d698 |
fi
}
|
aee18c74 |
function install_get_pip { |
f625ffe2 |
if [[ ! -r $LOCAL_PIP ]]; then |
f5b41542 |
curl --retry 6 --retry-delay 5 -o $LOCAL_PIP $PIP_GET_PIP_URL || \ |
f625ffe2 |
die $LINENO "Download of get-pip.py failed" |
62d1d698 |
fi |
130efefe |
sudo -H -E python $LOCAL_PIP |
62d1d698 |
}
|
683ff42d |
function configure_pypi_alternative_url {
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
#it means that the index-url does not exist
iniset "$PIP_CONFIG_FILE" "global" "index-url" "$PYPI_OVERRIDE"
fi
}
|
35b5283a |
# Setuptools 8 implements PEP 440, and 8.0.4 adds a warning triggered any time
# pkg_resources inspects the list of installed Python packages if there are
# non-compliant version numbers in the egg-info (for example, from distro
# system packaged Python libraries). This is off by default after 8.2 but can
# be enabled by uncommenting the lines below.
#PYTHONWARNINGS=$PYTHONWARNINGS,always::RuntimeWarning:pkg_resources
#export PYTHONWARNINGS |
683ff42d |
|
62d1d698 |
# Show starting versions
get_versions
# Do pip
|
dace92f5 |
# Eradicate any and all system packages
uninstall_package python-pip |
62d1d698 |
|
7b63c5ec |
install_get_pip |
dace92f5 |
|
683ff42d |
if [[ -n $PYPI_ALTERNATIVE_URL ]]; then
configure_pypi_alternative_url
fi
|
b7ebc476 |
pip_install -U setuptools |
76ed427c |
|
dace92f5 |
get_versions |