blob: fc1c19584be1d971618d689fbd9a2b4279a0385c [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
Chmouel Boudjnah59178682013-09-06 16:14:17 +020026INSTALL_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() {
Dean Troyer9acc12a2013-08-09 15:09:31 -050068 (cd $FILES; \
69 curl -O $PIP_TAR_URL; \
70 tar xvfz pip-$INSTALL_PIP_VERSION.tar.gz; \
71 cd pip-$INSTALL_PIP_VERSION; \
72 sudo python setup.py install; \
73 )
Dean Troyer62d1d692013-08-01 17:40:40 -050074}
75
76# Show starting versions
77get_versions
78
Dean Troyer62d1d692013-08-01 17:40:40 -050079# Do pip
Dean Troyer62d1d692013-08-01 17:40:40 -050080
Monty Taylordace92f2013-08-10 23:49:47 -030081# Eradicate any and all system packages
82uninstall_package python-pip
Dean Troyer62d1d692013-08-01 17:40:40 -050083
Monty Taylordace92f2013-08-10 23:49:47 -030084if [[ -n "$USE_GET_PIP" ]]; then
85 install_get_pip
86else
87 install_pip_tarball
Dean Troyer62d1d692013-08-01 17:40:40 -050088fi
Monty Taylordace92f2013-08-10 23:49:47 -030089
90get_versions