Browse code

Add tools/install_pip.sh

Install a known working recent version of pip that handles installation
dependencies more correctly than before. Extract to a separate script
so it can be used apart from stack.sh.

* Install distro setuptools if it not already present
* Install pip from source tarball as get-pip.py proved to be unreliable
* Remove python-distribute and python-pip from all prereq files,
move python-setuptools to 'general'
* Remove the earlier unfubar_setuptppls() call that attenpted to fix this
* Only update requirements.txt when no changes in repo

Tested on Precise, F18 and CentOS6.
* Fedora and RHEL allow pip to install packages ON TOP OF RPM-installed
packages. THIS IS BROKEN. And is one reason we have to be so picky
about order and so forth.

Change-Id: Ibb4b42119dc2e51577c77bbbbffb110863e5324d

Dean Troyer authored on 2013/08/02 07:40:40
Showing 15 changed files
... ...
@@ -1,6 +1,6 @@
1 1
 bridge-utils
2 2
 pylint
3
-python-pip
3
+python-setuptools
4 4
 screen
5 5
 unzip
6 6
 wget
... ...
@@ -1,4 +1,3 @@
1
-python-setuptools
2 1
 python-dev
3 2
 python-lxml
4 3
 python-pastescript
... ...
@@ -1,4 +1,3 @@
1
-python-setuptools
2 1
 python-gevent
3 2
 python-gflags
4 3
 python-netifaces
... ...
@@ -10,7 +10,6 @@ python-greenlet
10 10
 python-netifaces
11 11
 python-nose
12 12
 python-pastedeploy
13
-python-setuptools
14 13
 python-simplejson
15 14
 python-webob
16 15
 python-xattr
... ...
@@ -6,8 +6,8 @@ iputils
6 6
 openssh
7 7
 openssl
8 8
 psmisc
9
+python-setuptools # instead of python-distribute; dist:sle11sp2
9 10
 python-cmd2 # dist:opensuse-12.3
10
-python-pip
11 11
 python-pylint
12 12
 python-unittest2
13 13
 python-virtualenv
... ...
@@ -7,8 +7,6 @@ python-Routes
7 7
 python-SQLAlchemy
8 8
 python-WebOb
9 9
 python-devel
10
-python-distribute
11
-python-setuptools # instead of python-distribute; dist:sle11sp2
12 10
 python-greenlet
13 11
 python-lxml
14 12
 python-mysql
... ...
@@ -1,5 +1,3 @@
1
-python-distribute
2
-python-setuptools # instead of python-distribute; dist:sle11sp2
3 1
 python-Sphinx
4 2
 python-gevent
5 3
 python-netifaces
... ...
@@ -6,8 +6,6 @@ python-WebOb
6 6
 python-configobj
7 7
 python-coverage
8 8
 python-devel
9
-python-distribute
10
-python-setuptools # instead of python-distribute; dist:sle11sp2
11 9
 python-eventlet
12 10
 python-greenlet
13 11
 python-netifaces
... ...
@@ -11,7 +11,7 @@ libxml2-devel # dist:rhel6 [2]
11 11
 libxslt-devel # dist:rhel6 [2]
12 12
 psmisc
13 13
 pylint
14
-python-pip
14
+python-setuptools
15 15
 python-prettytable # dist:rhel6 [1]
16 16
 python-unittest2
17 17
 python-virtualenv
... ...
@@ -4,10 +4,9 @@ python-paste        #dist:f16,f17,f18,f19
4 4
 python-paste-deploy #dist:f16,f17,f18,f19
5 5
 python-paste-script #dist:f16,f17,f18,f19
6 6
 python-routes
7
-python-setuptools   #dist:f16,f17,f18,f19
8 7
 python-sqlalchemy
9 8
 python-sqlite2
10 9
 python-webob
11 10
 sqlite
12 11
 
13
-# Deps installed via pip for RHEL
14 12
\ No newline at end of file
13
+# Deps installed via pip for RHEL
... ...
@@ -1,5 +1,4 @@
1 1
 python-gevent
2 2
 python-gflags
3 3
 python-netifaces
4
-python-setuptools #dist:f16,f17,f18,f19
5 4
 python-sphinx
... ...
@@ -10,7 +10,6 @@ python-greenlet
10 10
 python-netifaces
11 11
 python-nose
12 12
 python-paste-deploy # dist:f16,f17,f18,f19
13
-python-setuptools   # dist:f16,f17,f18,f19
14 13
 python-simplejson
15 14
 python-webob
16 15
 pyxattr
... ...
@@ -1140,8 +1140,11 @@ function setup_develop() {
1140 1140
 
1141 1141
     echo "cd $REQUIREMENTS_DIR; $SUDO_CMD python update.py $project_dir"
1142 1142
 
1143
-    (cd $REQUIREMENTS_DIR; \
1144
-        $SUDO_CMD python update.py $project_dir)
1143
+    # Don't update repo if local changes exist
1144
+    if (cd $project_dir && git diff --quiet); then
1145
+        (cd $REQUIREMENTS_DIR; \
1146
+            $SUDO_CMD python update.py $project_dir)
1147
+    fi
1145 1148
 
1146 1149
     pip_install -e $project_dir
1147 1150
     # ensure that further actions can do things like setup.py sdist
... ...
@@ -578,18 +578,8 @@ set -o xtrace
578 578
 echo_summary "Installing package prerequisites"
579 579
 source $TOP_DIR/tools/install_prereqs.sh
580 580
 
581
-install_rpc_backend
582
-
583
-if is_service_enabled $DATABASE_BACKENDS; then
584
-    install_database
585
-fi
586
-
587
-if is_service_enabled neutron; then
588
-    install_neutron_agent_packages
589
-fi
590
-
591
-# Unbreak the giant mess that is the current state of setuptools
592
-unfubar_setuptools
581
+# Configure an appropriate python environment
582
+$TOP_DIR/tools/install_pip.sh
593 583
 
594 584
 # System-specific preconfigure
595 585
 # ============================
... ...
@@ -642,6 +632,16 @@ if [[ is_fedora && $DISTRO =~ (rhel6) ]]; then
642 642
     sudo ln -sf /usr/bin/nosetests1.1 /usr/local/bin/nosetests
643 643
 fi
644 644
 
645
+install_rpc_backend
646
+
647
+if is_service_enabled $DATABASE_BACKENDS; then
648
+    install_database
649
+fi
650
+
651
+if is_service_enabled neutron; then
652
+    install_neutron_agent_packages
653
+fi
654
+
645 655
 TRACK_DEPENDS=${TRACK_DEPENDS:-False}
646 656
 
647 657
 # Install python packages into a virtualenv so that we can track them
648 658
new file mode 100755
... ...
@@ -0,0 +1,118 @@
0
+#!/usr/bin/env bash
1
+
2
+# **install_pip.sh**
3
+
4
+# install_pip.sh [--pip-version <version>] [--use-get-pip] [--setuptools] [--force]
5
+#
6
+# Update pip and friends to a known common version
7
+
8
+# Assumptions:
9
+# - currently we try to leave the system setuptools alone, install
10
+#   the system package if it is not already present
11
+# - update pip to $INSTALL_PIP_VERSION
12
+
13
+# Keep track of the current directory
14
+TOOLS_DIR=$(cd $(dirname "$0") && pwd)
15
+TOP_DIR=`cd $TOOLS_DIR/..; pwd`
16
+
17
+# Change dir to top of devstack
18
+cd $TOP_DIR
19
+
20
+# Import common functions
21
+source $TOP_DIR/functions
22
+
23
+FILES=$TOP_DIR/files
24
+
25
+# Handle arguments
26
+
27
+INSTALL_PIP_VERSION=${INSTALL_PIP_VERSION:-"1.4"}
28
+while [[ -n "$1" ]]; do
29
+    case $1 in
30
+        --force)
31
+            FORCE=1
32
+            ;;
33
+        --pip-version)
34
+            INSTALL_PIP_VERSION="$2"
35
+            shift
36
+            ;;
37
+        --setuptools)
38
+            SETUPTOOLS=1
39
+            ;;
40
+        --use-get-pip)
41
+            USE_GET_PIP=1;
42
+            ;;
43
+    esac
44
+    shift
45
+done
46
+
47
+SETUPTOOLS_EZ_SETUP_URL=https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
48
+PIP_GET_PIP_URL=https://raw.github.com/pypa/pip/master/contrib/get-pip.py
49
+PIP_TAR_URL=https://pypi.python.org/packages/source/p/pip/pip-$INSTALL_PIP_VERSION.tar.gz
50
+
51
+GetDistro
52
+echo "Distro: $DISTRO"
53
+
54
+function get_versions() {
55
+    PIP=$(which pip 2>/dev/null || which pip-python 2>/dev/null)
56
+    if [[ -n $PIP ]]; then
57
+        DISTRIBUTE_VERSION=$($PIP freeze | grep 'distribute==')
58
+        SETUPTOOLS_VERSION=$($PIP freeze | grep 'setuptools==')
59
+        PIP_VERSION=$($PIP --version | awk '{ print $2}')
60
+        echo "pip: $PIP_VERSION  setuptools: $SETUPTOOLS_VERSION  distribute: $DISTRIBUTE_VERSION"
61
+    fi
62
+}
63
+
64
+function setuptools_ez_setup() {
65
+    if [[ ! -r $FILES/ez_setup.py ]]; then
66
+        (cd $FILES; \
67
+         curl -OR $SETUPTOOLS_EZ_SETUP_URL; \
68
+        )
69
+    fi
70
+    sudo python $FILES/ez_setup.py
71
+}
72
+
73
+function install_get_pip() {
74
+    if [[ ! -r $FILES/get-pip.py ]]; then
75
+        (cd $FILES; \
76
+            curl $PIP_GET_PIP_URL; \
77
+        )
78
+    fi
79
+    sudo python $FILES/get-pip.py
80
+}
81
+
82
+function install_pip_tarball() {
83
+    curl -O $PIP_TAR_URL
84
+    tar xvfz pip-$INSTALL_PIP_VERSION.tar.gz
85
+    cd pip-$INSTALL_PIP_VERSION
86
+    sudo python setup.py install
87
+}
88
+
89
+# Show starting versions
90
+get_versions
91
+
92
+# Do setuptools
93
+if [[ -n "$SETUPTOOLS" ]]; then
94
+    # We want it from source
95
+    uninstall_package python-setuptools
96
+    setuptools_ez_setup
97
+else
98
+    # See about installing the distro setuptools
99
+    if ! python -c "import setuptools"; then
100
+        install_package python-setuptools
101
+    fi
102
+fi
103
+
104
+# Do pip
105
+if [[ -z $PIP || "$PIP_VERSION" != "$INSTALL_PIP_VERSION" || -n $FORCE ]]; then
106
+
107
+    # Eradicate any and all system packages
108
+    uninstall_package python-pip
109
+
110
+    if [[ -n "$USE_GET_PIP" ]]; then
111
+        install_get_pip
112
+    else
113
+        install_pip_tarball
114
+    fi
115
+
116
+    get_versions
117
+fi