provision: Refactor script variables and Windows support.
This commit is contained in:
parent
095cea7ab9
commit
a4d6c4700f
|
@ -1,21 +1,23 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
BASEDIR=$(dirname `dirname $0`)
|
BASEDIR=$(dirname `dirname $0`)
|
||||||
|
VENVDIR="zulip-api-py2-venv"
|
||||||
|
VENVEXECDIR="bin"
|
||||||
|
|
||||||
if [ ! -d "$BASEDIR/zulip-api-py2-venv" ]; then
|
if [ ! -d "$BASEDIR/$VENVDIR" ]; then
|
||||||
virtualenv $BASEDIR/zulip-api-py2-venv
|
virtualenv "$BASEDIR/$VENVDIR"
|
||||||
echo "Virtualenv created."
|
echo "Virtualenv created."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
VENVBINDIR="bin"
|
VENVBINDIR="bin"
|
||||||
if [[ "$OSTYPE" == "msys" ]]; then
|
if [[ ! -d "$BASEDIR/$VENVDIR/$VENVEXECDIR" ]]; then
|
||||||
# POSIX compatibility layer and Linux environment emulation for Windows
|
# POSIX compatibility layer and Linux environment emulation for Windows
|
||||||
# Virtual uses /Scripts instead of /bin on Windows.
|
# Virtual uses /Scripts instead of /bin on Windows.
|
||||||
# Read https://virtualenv.pypa.io/en/stable/userguide/
|
# Read https://virtualenv.pypa.io/en/stable/userguide/
|
||||||
VENVBINDIR="Scripts"
|
VENVEXECDIR="Scripts"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source "$BASEDIR/zulip-api-py2-venv/$VENVBINDIR/activate"
|
source "$BASEDIR/$VENVDIR/$VENVEXECDIR/activate"
|
||||||
RVAL=$?
|
RVAL=$?
|
||||||
if [ "$RVAL" -ne 0 ]; then
|
if [ "$RVAL" -ne 0 ]; then
|
||||||
echo "Failed to activate virtualenv."
|
echo "Failed to activate virtualenv."
|
||||||
|
@ -23,11 +25,11 @@ if [ "$RVAL" -ne 0 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install python dependencies if needed.
|
# Install python dependencies if needed.
|
||||||
cmp "$BASEDIR/zulip-api-py2-venv/installed-requirements.txt" requirements.txt 2>/dev/null
|
cmp "$BASEDIR/$VENVDIR/installed-requirements.txt" requirements.txt 2>/dev/null
|
||||||
RVAL=$? # Return value of the comparision. 0 means files are same.
|
RVAL=$? # Return value of the comparision. 0 means files are same.
|
||||||
if [ "$RVAL" -ne 0 ]; then
|
if [ "$RVAL" -ne 0 ]; then
|
||||||
pip install -r "$BASEDIR/requirements.txt"
|
pip install -r "$BASEDIR/requirements.txt"
|
||||||
cp -a requirements.txt "$BASEDIR/zulip-api-py2-venv/installed-requirements.txt"
|
cp -a requirements.txt "$BASEDIR/$VENVDIR/installed-requirements.txt"
|
||||||
echo "Requirements installed."
|
echo "Requirements installed."
|
||||||
fi
|
fi
|
||||||
echo 'Success! Run `source' "$BASEDIR/zulip-api-py2-venv/bin/activate"'`' "to activate virtualenv."
|
echo 'Success! Run `source' "$BASEDIR/$VENVDIR/$VENVEXECDIR/activate"'`' "to activate virtualenv."
|
||||||
|
|
Loading…
Reference in a new issue