2017-08-07 19:07:58 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
BASEDIR=`dirname $0`/..
|
|
|
|
|
2017-08-10 14:35:11 -04:00
|
|
|
if [ ! -d "$BASEDIR/zulip-api-py2-venv" ]; then
|
|
|
|
virtualenv $BASEDIR/zulip-api-py2-venv
|
2017-08-07 19:07:58 -04:00
|
|
|
echo "Virtualenv created."
|
|
|
|
fi
|
|
|
|
|
2017-08-10 14:52:05 -04:00
|
|
|
VENVBINDIR="bin"
|
|
|
|
if [[ "$OSTYPE" == "cygwin" ]]; then
|
|
|
|
# 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/
|
|
|
|
VENVBINDIR="Scripts"
|
|
|
|
fi
|
|
|
|
|
2017-08-17 13:41:23 -04:00
|
|
|
source "$BASEDIR/zulip-api-py2-venv/$VENVBINDIR/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-17 13:41:23 -04:00
|
|
|
cmp "$BASEDIR/zulip-api-py2-venv/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"
|
|
|
|
cp requirements.txt "$BASEDIR/zulip-api-py2-venv/installed-requirements.txt"
|
2017-08-07 19:07:58 -04:00
|
|
|
echo "Requirements installed."
|
|
|
|
fi
|