| OLD | NEW |
| (Empty) |
| 1 #! /bin/bash | |
| 2 | |
| 3 # Create the python environment needed by run-tests.py and closure-linter and | |
| 4 # other Python tools. | |
| 5 | |
| 6 OLD_PWD=$PWD | |
| 7 | |
| 8 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
| 9 | |
| 10 cd $DIR | |
| 11 if [ ! -f bin/activate ]; then | |
| 12 echo "Setting up Python environment in $DIR" | |
| 13 | |
| 14 if [ x$(which pip) == x -o x$(which virtualenv) == x ]; then | |
| 15 cat <<EOF | |
| 16 Can not autoinstall as pip and virtualenv are not avaliable. | |
| 17 | |
| 18 To install 'pip' please do one of the following; | |
| 19 | |
| 20 # sudo apt-get install python-pip python-virtualenv | |
| 21 | |
| 22 or | |
| 23 | |
| 24 # sudo easy_install pip | |
| 25 # sudo pip install virtualenv | |
| 26 EOF | |
| 27 exit 1 | |
| 28 fi | |
| 29 | |
| 30 if virtualenv --system-site-packages .; then | |
| 31 echo -e; | |
| 32 else | |
| 33 cat <<EOF | |
| 34 Was unable to set up the virtualenv environment. Please see output for errors. | |
| 35 EOF | |
| 36 exit 1 | |
| 37 fi | |
| 38 fi | |
| 39 | |
| 40 source bin/activate | |
| 41 | |
| 42 function ensureRequirementsMet() { | |
| 43 # Check if installed | |
| 44 pip install --no-download $@ > /dev/null 2>&1 | |
| 45 if [ $? -ne 0 ]; then | |
| 46 # Install dependencies | |
| 47 pip install --upgrade $@ | |
| 48 if [ $? -ne 0 ]; then | |
| 49 cat <<EOF | |
| 50 Unable to install dependencies. Please see error output above. | |
| 51 EOF | |
| 52 exit 1 | |
| 53 fi | |
| 54 fi | |
| 55 } | |
| 56 | |
| 57 ensureRequirementsMet 'pip>=1.5' | |
| 58 ensureRequirementsMet -r requirements.txt | |
| 59 | |
| 60 cd $OLD_PWD | |
| OLD | NEW |