blob: 64cc20052e652f201e3e59769fd4382d625c14fc [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
12# Keep track of the current directory
13TOOLS_DIR=$(cd $(dirname "$0") && pwd)
14TOP_DIR=`cd $TOOLS_DIR/..; pwd`
15
16# Change dir to top of devstack
17cd $TOP_DIR
18
19# Import common functions
20source $TOP_DIR/functions
21
22FILES=$TOP_DIR/files
23
24# Handle arguments
25
Monty Taylordace92f2013-08-10 23:49:47 -030026INSTALL_PIP_VERSION=${INSTALL_PIP_VERSION:-"1.4.1"}
Dean Troyer62d1d692013-08-01 17:40:40 -050027while [[ -n "$1" ]]; do
28 case $1 in
29 --force)
30 FORCE=1
31 ;;
32 --pip-version)
33 INSTALL_PIP_VERSION="$2"
34 shift
35 ;;
Dean Troyer62d1d692013-08-01 17:40:40 -050036 --use-get-pip)
37 USE_GET_PIP=1;
38 ;;
39 esac
40 shift
41done
42
Dean Troyer62d1d692013-08-01 17:40:40 -050043PIP_GET_PIP_URL=https://raw.github.com/pypa/pip/master/contrib/get-pip.py
44PIP_TAR_URL=https://pypi.python.org/packages/source/p/pip/pip-$INSTALL_PIP_VERSION.tar.gz
45
46GetDistro
47echo "Distro: $DISTRO"
48
49function get_versions() {
50 PIP=$(which pip 2>/dev/null || which pip-python 2>/dev/null)
51 if [[ -n $PIP ]]; then
Dean Troyer62d1d692013-08-01 17:40:40 -050052 PIP_VERSION=$($PIP --version | awk '{ print $2}')
Monty Taylordace92f2013-08-10 23:49:47 -030053 echo "pip: $PIP_VERSION"
Dean Troyer62d1d692013-08-01 17:40:40 -050054 fi
55}
56
Dean Troyer62d1d692013-08-01 17:40:40 -050057
58function install_get_pip() {
59 if [[ ! -r $FILES/get-pip.py ]]; then
60 (cd $FILES; \
61 curl $PIP_GET_PIP_URL; \
62 )
63 fi
64 sudo python $FILES/get-pip.py
65}
66
67function install_pip_tarball() {
68 curl -O $PIP_TAR_URL
69 tar xvfz pip-$INSTALL_PIP_VERSION.tar.gz
70 cd pip-$INSTALL_PIP_VERSION
71 sudo python setup.py install
72}
73
74# Show starting versions
75get_versions
76
Dean Troyer62d1d692013-08-01 17:40:40 -050077# Do pip
Dean Troyer62d1d692013-08-01 17:40:40 -050078
Monty Taylordace92f2013-08-10 23:49:47 -030079# Eradicate any and all system packages
80uninstall_package python-pip
Dean Troyer62d1d692013-08-01 17:40:40 -050081
Monty Taylordace92f2013-08-10 23:49:47 -030082if [[ -n "$USE_GET_PIP" ]]; then
83 install_get_pip
84else
85 install_pip_tarball
Dean Troyer62d1d692013-08-01 17:40:40 -050086fi
Monty Taylordace92f2013-08-10 23:49:47 -030087
88get_versions