summaryrefslogtreecommitdiffstats
path: root/testcases/vIMS/CI/create_venv.sh
blob: 15294f77b9218a3a691d08c3abdc63d55123c250 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash -e

# Script checks that venv exists. If it doesn't it will be created
# It requires python2.7 and virtualenv packages installed

BASEDIR=`dirname $0`
VENV_PATH=$1
VENV_NAME="venv_cloudify"
function venv_install() {
    if command -v virtualenv-2.7; then
        virtualenv-2.7 $1
    elif command -v virtualenv2; then
        virtualenv2 $1
    elif command -v virtualenv; then
        virtualenv $1
    else
        echo Cannot find virtualenv command.
        return 1
    fi
}

# exit when something goes wrong during venv install
set -e
if [ ! -d "$VENV_PATH/$VENV_NAME" ]; then
    venv_install $VENV_PATH/$VENV_NAME
    echo "Virtualenv" + $VENV_NAME + "created."
fi

if [ ! -f "$VENV_PATH/$VENV_NAME/updated" -o $BASEDIR/requirements.pip -nt $VENV_PATH/$VENV_NAME/updated ]; then
    source $VENV_PATH/$VENV_NAME/bin/activate
    pip install -r $BASEDIR/requirements.pip
    touch $VENV_PATH/$VENV_NAME/updated
    echo "Requirements installed."
    deactivate
fi
set +e