blob: 150faaa2581172ef43a1f1fe685867582bf2a060 [file] [log] [blame]
Dean Troyer62d1d692013-08-01 17:40:40 -05001#!/usr/bin/env bash
2
3# **install_pip.sh**
4
Monty Taylordace92f2013-08-10 23:49:47 -03005# install_pip.sh [--pip-version <version>] [--use-get-pip] [--force]
Dean Troyer62d1d692013-08-01 17:40:40 -05006#
7# Update pip and friends to a known common version
8
9# Assumptions:
Dean Troyer62d1d692013-08-01 17:40:40 -050010# - update pip to $INSTALL_PIP_VERSION
11
Adam Spiersc85ade72013-10-01 00:35:16 +010012set -o errexit
13set -o xtrace
14
Dean Troyer62d1d692013-08-01 17:40:40 -050015# Keep track of the current directory
16TOOLS_DIR=$(cd $(dirname "$0") && pwd)
17TOP_DIR=`cd $TOOLS_DIR/..; pwd`
18
19# Change dir to top of devstack
20cd $TOP_DIR
21
22# Import common functions
23source $TOP_DIR/functions
24
25FILES=$TOP_DIR/files
26
Sean Dague7b63c5e2014-06-04 16:25:52 -040027PIP_GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py
Sean Daguef625ffe2014-06-05 07:04:41 -040028LOCAL_PIP="$FILES/$(basename $PIP_GET_PIP_URL)"
Dean Troyer62d1d692013-08-01 17:40:40 -050029
30GetDistro
31echo "Distro: $DISTRO"
32
Ian Wienandaee18c72014-02-21 15:35:08 +110033function get_versions {
Attila Fazekas46ea7232013-10-07 07:29:27 +020034 PIP=$(which pip 2>/dev/null || which pip-python 2>/dev/null || true)
Dean Troyer62d1d692013-08-01 17:40:40 -050035 if [[ -n $PIP ]]; then
Dean Troyer62d1d692013-08-01 17:40:40 -050036 PIP_VERSION=$($PIP --version | awk '{ print $2}')
Monty Taylordace92f2013-08-10 23:49:47 -030037 echo "pip: $PIP_VERSION"
Attila Fazekas46ea7232013-10-07 07:29:27 +020038 else
39 echo "pip: Not Installed"
Dean Troyer62d1d692013-08-01 17:40:40 -050040 fi
41}
42
Dean Troyer62d1d692013-08-01 17:40:40 -050043
Ian Wienandaee18c72014-02-21 15:35:08 +110044function install_get_pip {
Sean Daguef625ffe2014-06-05 07:04:41 -040045 if [[ ! -r $LOCAL_PIP ]]; then
46 curl -o $LOCAL_PIP $PIP_GET_PIP_URL || \
47 die $LINENO "Download of get-pip.py failed"
Dean Troyer62d1d692013-08-01 17:40:40 -050048 fi
Sean Daguef625ffe2014-06-05 07:04:41 -040049 sudo -E python $LOCAL_PIP
Dean Troyer62d1d692013-08-01 17:40:40 -050050}
51
Dean Troyer62d1d692013-08-01 17:40:40 -050052
53# Show starting versions
54get_versions
55
Dean Troyer62d1d692013-08-01 17:40:40 -050056# Do pip
Dean Troyer62d1d692013-08-01 17:40:40 -050057
Monty Taylordace92f2013-08-10 23:49:47 -030058# Eradicate any and all system packages
59uninstall_package python-pip
Dean Troyer62d1d692013-08-01 17:40:40 -050060
Sean Dague7b63c5e2014-06-04 16:25:52 -040061install_get_pip
Monty Taylordace92f2013-08-10 23:49:47 -030062
Mathieu Gagné76ed4272014-06-05 16:50:40 -040063pip_install -U setuptools
64
Monty Taylordace92f2013-08-10 23:49:47 -030065get_versions