2021-04-28 19:12:09 +02:00
|
|
|
function activate_venv {
|
|
|
|
set -e
|
|
|
|
# check if virtualenv is set up
|
|
|
|
if [ -d "${workdir}/venv" ]; then
|
|
|
|
if [ "Windows_NT" = "$OS" ]; then
|
|
|
|
# Need to quote the path on Windows to preserve the separator.
|
|
|
|
. "${workdir}/venv/Scripts/activate" 2>/tmp/activate_error.log
|
|
|
|
else
|
|
|
|
. ${workdir}/venv/bin/activate 2>/tmp/activate_error.log
|
|
|
|
fi
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Failed to activate virtualenv: $(cat /tmp/activate_error.log)"
|
|
|
|
fi
|
|
|
|
python=python
|
|
|
|
else
|
2021-05-18 22:19:17 +02:00
|
|
|
if [ -z "$python" ]; then
|
|
|
|
echo "\$python is unset. This should never happen"
|
|
|
|
fi
|
|
|
|
python=${python}
|
2021-04-28 19:12:09 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "Windows_NT" = "$OS" ]; then
|
|
|
|
export PYTHONPATH="$PYTHONPATH;$(cygpath -w ${workdir}/src)"
|
|
|
|
else
|
|
|
|
export PYTHONPATH="$PYTHONPATH:${workdir}/src"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "python set to $(which $python)"
|
|
|
|
set +e
|
|
|
|
}
|