Browse code

Backport install_pip.sh from master

There are several improvements to install_pip.sh in master. All of these
have to do with the general state of pip upstream and are not something
that have anything to do with icehouse. For sanity, just backport the
entire file.

Change-Id: I9996bbc76ea81dd5bdded3bc8a5bf0542ade95f1
Closes-Bug: 1405579
Closes-bug: #1405626
Related-bug: #1405732

Monty Taylor authored on 2014/12/27 01:03:56
Showing 1 changed files
... ...
@@ -46,10 +46,36 @@ function install_get_pip {
46 46
         curl -o $LOCAL_PIP $PIP_GET_PIP_URL || \
47 47
             die $LINENO "Download of get-pip.py failed"
48 48
     fi
49
-    sudo -E python $LOCAL_PIP
49
+    sudo -H -E python $LOCAL_PIP
50 50
 }
51 51
 
52 52
 
53
+function configure_pypi_alternative_url {
54
+    PIP_ROOT_FOLDER="$HOME/.pip"
55
+    PIP_CONFIG_FILE="$PIP_ROOT_FOLDER/pip.conf"
56
+    if [[ ! -d $PIP_ROOT_FOLDER ]]; then
57
+        echo "Creating $PIP_ROOT_FOLDER"
58
+        mkdir $PIP_ROOT_FOLDER
59
+    fi
60
+    if [[ ! -f $PIP_CONFIG_FILE ]]; then
61
+        echo "Creating $PIP_CONFIG_FILE"
62
+        touch $PIP_CONFIG_FILE
63
+    fi
64
+    if ! ini_has_option "$PIP_CONFIG_FILE" "global" "index-url"; then
65
+        #it means that the index-url does not exist
66
+        iniset "$PIP_CONFIG_FILE" "global" "index-url" "$PYPI_OVERRIDE"
67
+    fi
68
+
69
+}
70
+
71
+# Setuptools 8 implements PEP 440, and 8.0.4 adds a warning triggered any time
72
+# pkg_resources inspects the list of installed Python packages if there are
73
+# non-compliant version numbers in the egg-info (for example, from distro
74
+# system packaged Python libraries). This is off by default after 8.2 but can
75
+# be enabled by uncommenting the lines below.
76
+#PYTHONWARNINGS=$PYTHONWARNINGS,always::RuntimeWarning:pkg_resources
77
+#export PYTHONWARNINGS
78
+
53 79
 # Show starting versions
54 80
 get_versions
55 81
 
... ...
@@ -60,4 +86,10 @@ uninstall_package python-pip
60 60
 
61 61
 install_get_pip
62 62
 
63
+if [[ -n $PYPI_ALTERNATIVE_URL ]]; then
64
+    configure_pypi_alternative_url
65
+fi
66
+
67
+pip_install -U setuptools
68
+
63 69
 get_versions