blob: 04e18261ac79bbe8d824d7cb05b5051c360962a4 [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
27# Handle arguments
28
Chmouel Boudjnah59178682013-09-06 16:14:17 +020029INSTALL_PIP_VERSION=${INSTALL_PIP_VERSION:-"1.4.1"}
Dean Troyer62d1d692013-08-01 17:40:40 -050030while [[ -n "$1" ]]; do
31 case $1 in
32 --force)
33 FORCE=1
34 ;;
35 --pip-version)
36 INSTALL_PIP_VERSION="$2"
37 shift
38 ;;
Dean Troyer62d1d692013-08-01 17:40:40 -050039 --use-get-pip)
40 USE_GET_PIP=1;
41 ;;
42 esac
43 shift
44done
45
Dean Troyer62d1d692013-08-01 17:40:40 -050046PIP_GET_PIP_URL=https://raw.github.com/pypa/pip/master/contrib/get-pip.py
47PIP_TAR_URL=https://pypi.python.org/packages/source/p/pip/pip-$INSTALL_PIP_VERSION.tar.gz
48
49GetDistro
50echo "Distro: $DISTRO"
51
52function get_versions() {
53 PIP=$(which pip 2>/dev/null || which pip-python 2>/dev/null)
54 if [[ -n $PIP ]]; then
Dean Troyer62d1d692013-08-01 17:40:40 -050055 PIP_VERSION=$($PIP --version | awk '{ print $2}')
Monty Taylordace92f2013-08-10 23:49:47 -030056 echo "pip: $PIP_VERSION"
Dean Troyer62d1d692013-08-01 17:40:40 -050057 fi
58}
59
Dean Troyer62d1d692013-08-01 17:40:40 -050060
61function install_get_pip() {
62 if [[ ! -r $FILES/get-pip.py ]]; then
63 (cd $FILES; \
64 curl $PIP_GET_PIP_URL; \
65 )
66 fi
67 sudo python $FILES/get-pip.py
68}
69
70function install_pip_tarball() {
Dean Troyer9acc12a2013-08-09 15:09:31 -050071 (cd $FILES; \
72 curl -O $PIP_TAR_URL; \
73 tar xvfz pip-$INSTALL_PIP_VERSION.tar.gz; \
74 cd pip-$INSTALL_PIP_VERSION; \
75 sudo python setup.py install; \
76 )
Dean Troyer62d1d692013-08-01 17:40:40 -050077}
78
79# Show starting versions
80get_versions
81
Dean Troyer62d1d692013-08-01 17:40:40 -050082# Do pip
Dean Troyer62d1d692013-08-01 17:40:40 -050083
Monty Taylordace92f2013-08-10 23:49:47 -030084# Eradicate any and all system packages
85uninstall_package python-pip
Dean Troyer62d1d692013-08-01 17:40:40 -050086
Monty Taylordace92f2013-08-10 23:49:47 -030087if [[ -n "$USE_GET_PIP" ]]; then
88 install_get_pip
89else
90 install_pip_tarball
Dean Troyer62d1d692013-08-01 17:40:40 -050091fi
Monty Taylordace92f2013-08-10 23:49:47 -030092
93get_versions