Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
2 | |||||
3 | # **install_pip.sh** | ||||
4 | |||||
Monty Taylor | dace92f | 2013-08-10 23:49:47 -0300 | [diff] [blame] | 5 | # install_pip.sh [--pip-version <version>] [--use-get-pip] [--force] |
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 6 | # |
7 | # Update pip and friends to a known common version | ||||
8 | |||||
9 | # Assumptions: | ||||
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 10 | # - update pip to $INSTALL_PIP_VERSION |
11 | |||||
Adam Spiers | c85ade7 | 2013-10-01 00:35:16 +0100 | [diff] [blame] | 12 | set -o errexit |
13 | set -o xtrace | ||||
14 | |||||
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 15 | # Keep track of the current directory |
16 | TOOLS_DIR=$(cd $(dirname "$0") && pwd) | ||||
17 | TOP_DIR=`cd $TOOLS_DIR/..; pwd` | ||||
18 | |||||
19 | # Change dir to top of devstack | ||||
20 | cd $TOP_DIR | ||||
21 | |||||
22 | # Import common functions | ||||
23 | source $TOP_DIR/functions | ||||
24 | |||||
25 | FILES=$TOP_DIR/files | ||||
26 | |||||
Sean Dague | 7b63c5e | 2014-06-04 16:25:52 -0400 | [diff] [blame^] | 27 | PIP_GET_PIP_URL=https://bootstrap.pypa.io/get-pip.py |
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 28 | |
29 | GetDistro | ||||
30 | echo "Distro: $DISTRO" | ||||
31 | |||||
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 32 | function get_versions { |
Attila Fazekas | 46ea723 | 2013-10-07 07:29:27 +0200 | [diff] [blame] | 33 | PIP=$(which pip 2>/dev/null || which pip-python 2>/dev/null || true) |
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 34 | if [[ -n $PIP ]]; then |
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 35 | PIP_VERSION=$($PIP --version | awk '{ print $2}') |
Monty Taylor | dace92f | 2013-08-10 23:49:47 -0300 | [diff] [blame] | 36 | echo "pip: $PIP_VERSION" |
Attila Fazekas | 46ea723 | 2013-10-07 07:29:27 +0200 | [diff] [blame] | 37 | else |
38 | echo "pip: Not Installed" | ||||
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 39 | fi |
40 | } | ||||
41 | |||||
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 42 | |
Ian Wienand | aee18c7 | 2014-02-21 15:35:08 +1100 | [diff] [blame] | 43 | function install_get_pip { |
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 44 | if [[ ! -r $FILES/get-pip.py ]]; then |
45 | (cd $FILES; \ | ||||
Monty Taylor | 480309e | 2013-11-23 13:02:45 -0500 | [diff] [blame] | 46 | curl -O $PIP_GET_PIP_URL; \ |
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 47 | ) |
48 | fi | ||||
sbauza | a49422e | 2013-12-05 14:56:14 +0100 | [diff] [blame] | 49 | sudo -E python $FILES/get-pip.py |
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 50 | } |
51 | |||||
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 52 | |
53 | # Show starting versions | ||||
54 | get_versions | ||||
55 | |||||
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 56 | # Do pip |
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 57 | |
Monty Taylor | dace92f | 2013-08-10 23:49:47 -0300 | [diff] [blame] | 58 | # Eradicate any and all system packages |
59 | uninstall_package python-pip | ||||
Dean Troyer | 62d1d69 | 2013-08-01 17:40:40 -0500 | [diff] [blame] | 60 | |
Sean Dague | 7b63c5e | 2014-06-04 16:25:52 -0400 | [diff] [blame^] | 61 | install_get_pip |
Monty Taylor | dace92f | 2013-08-10 23:49:47 -0300 | [diff] [blame] | 62 | |
63 | get_versions |