2017-08-07 19:07:58 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-08-17 13:46:36 -04:00
|
|
|
BASEDIR=$(dirname `dirname $0`)
|
2017-08-18 05:32:27 -04:00
|
|
|
VENVDIR="zulip-api-py2-venv"
|
|
|
|
VENVEXECDIR="bin"
|
2017-08-07 19:07:58 -04:00
|
|
|
|
2017-08-18 05:32:27 -04:00
|
|
|
if [ ! -d "$BASEDIR/$VENVDIR" ]; then
|
|
|
|
virtualenv "$BASEDIR/$VENVDIR"
|
2017-08-07 19:07:58 -04:00
|
|
|
echo "Virtualenv created."
|
|
|
|
fi
|
|
|
|
|
2017-08-10 14:52:05 -04:00
|
|
|
VENVBINDIR="bin"
|
2017-08-18 05:32:27 -04:00
|
|
|
if [[ ! -d "$BASEDIR/$VENVDIR/$VENVEXECDIR" ]]; then
|
2017-08-10 14:52:05 -04:00
|
|
|
# POSIX compatibility layer and Linux environment emulation for Windows
|
|
|
|
# Virtual uses /Scripts instead of /bin on Windows.
|
|
|
|
# Read https://virtualenv.pypa.io/en/stable/userguide/
|
2017-08-18 05:32:27 -04:00
|
|
|
VENVEXECDIR="Scripts"
|
2017-08-10 14:52:05 -04:00
|
|
|
fi
|
|
|
|
|
2017-08-18 05:32:27 -04:00
|
|
|
source "$BASEDIR/$VENVDIR/$VENVEXECDIR/activate"
|
2017-08-10 14:35:11 -04:00
|
|
|
RVAL=$?
|
2017-08-17 13:41:23 -04:00
|
|
|
if [ "$RVAL" -ne 0 ]; then
|
2017-08-10 14:35:11 -04:00
|
|
|
echo "Failed to activate virtualenv."
|
|
|
|
exit
|
|
|
|
fi
|
2017-08-07 19:07:58 -04:00
|
|
|
|
2017-08-10 14:35:11 -04:00
|
|
|
# Install python dependencies if needed.
|
2017-08-18 05:32:27 -04:00
|
|
|
cmp "$BASEDIR/$VENVDIR/installed-requirements.txt" requirements.txt 2>/dev/null
|
2017-08-10 14:35:11 -04:00
|
|
|
RVAL=$? # Return value of the comparision. 0 means files are same.
|
2017-08-17 13:41:23 -04:00
|
|
|
if [ "$RVAL" -ne 0 ]; then
|
|
|
|
pip install -r "$BASEDIR/requirements.txt"
|
2017-08-18 05:32:27 -04:00
|
|
|
cp -a requirements.txt "$BASEDIR/$VENVDIR/installed-requirements.txt"
|
2017-08-07 19:07:58 -04:00
|
|
|
echo "Requirements installed."
|
|
|
|
fi
|
2017-08-18 05:32:27 -04:00
|
|
|
echo 'Success! Run `source' "$BASEDIR/$VENVDIR/$VENVEXECDIR/activate"'`' "to activate virtualenv."
|