Skip to content

Commit

Permalink
Allow override of location of virtual env Galaxy manages.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Jan 13, 2016
1 parent 9dc9ddf commit 8fd83df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
7 changes: 4 additions & 3 deletions run.sh
Expand Up @@ -56,11 +56,12 @@ done

# If there is a .venv/ directory, assume it contains a virtualenv that we
# should run this instance in.
if [ -d .venv -a -z "$skip_venv" ];
GALAXY_VIRTUAL_ENV="${GALAXY_VIRTUAL_ENV:-.venv}"
if [ -d "$GALAXY_VIRTUAL_ENV" -a -z "$skip_venv" ];
then
[ -n "$PYTHONPATH" ] && { echo 'Unsetting $PYTHONPATH'; unset PYTHONPATH; }
printf "Activating virtualenv at %s/.venv\n" $(pwd)
. .venv/bin/activate
printf "Activating virtualenv at $GALAXY_VIRTUAL_ENV\n"
. "$GALAXY_VIRTUAL_ENV/bin/activate"
fi

# If you are using --skip-venv we assume you know what you are doing but warn
Expand Down
7 changes: 4 additions & 3 deletions run_tests.sh
Expand Up @@ -329,10 +329,11 @@ if [ -z "$skip_common_startup" ]; then
./scripts/common_startup.sh $skip_venv $no_create_venv $no_replace_pip $replace_pip --dev-wheels || exit 1
fi

if [ -z "$skip_venv" -a -d .venv ];
GALAXY_VIRTUAL_ENV="${GALAXY_VIRTUAL_ENV:-.venv}"
if [ -z "$skip_venv" -a -d "$GALAXY_VIRTUAL_ENV" ];
then
printf "Activating virtualenv at %s/.venv\n" $(pwd)
. .venv/bin/activate
printf "Activating virtualenv at $GALAXY_VIRTUAL_ENV\n"
. "$GALAXY_VIRTUAL_ENV/bin/activate"
fi

if [ -n "$migrated_test" ] ; then
Expand Down
16 changes: 9 additions & 7 deletions scripts/common_startup.sh
Expand Up @@ -66,14 +66,16 @@ if [ ! -f $GALAXY_CONFIG_FILE ]; then
GALAXY_CONFIG_FILE=config/galaxy.ini.sample
fi

: ${GALAXY_VIRTUAL_ENV:=.venv}

if [ $SET_VENV -eq 1 -a $CREATE_VENV -eq 1 ]; then
# If .venv does not exist, attempt to create it.
if [ ! -d .venv ]
if [ ! -d "$GALAXY_VIRTUAL_ENV" ]
then
# Ensure Python is a supported version before creating .venv
python ./scripts/check_python.py || exit 1
if command -v virtualenv >/dev/null; then
virtualenv .venv
virtualenv "$GALAXY_VIRTUAL_ENV"
else
vvers=13.1.2
vurl="https://pypi.python.org/packages/source/v/virtualenv/virtualenv-${vvers}.tar.gz"
Expand All @@ -98,7 +100,7 @@ if [ $SET_VENV -eq 1 -a $CREATE_VENV -eq 1 ]; then
python -c "import hashlib; assert hashlib.sha256(open('$vsrc', 'rb').read()).hexdigest() == '$vsha', '$vsrc: invalid checksum'"
fi
tar zxf $vsrc -C $vtmp
python $vtmp/virtualenv-$vvers/virtualenv.py .venv
python $vtmp/virtualenv-$vvers/virtualenv.py "$GALAXY_VIRTUAL_ENV"
rm -rf $vtmp
fi
fi
Expand All @@ -107,10 +109,10 @@ fi
if [ $SET_VENV -eq 1 ]; then
# If there is a .venv/ directory, assume it contains a virtualenv that we
# should run this instance in.
if [ -d .venv ];
if [ -d "$GALAXY_VIRTUAL_ENV" ];
then
printf "Activating virtualenv at %s/.venv\n" $(pwd)
. .venv/bin/activate
printf "Activating virtualenv at $GALAXY_VIRTUAL_ENV\n"
. "$GALAXY_VIRTUAL_ENV/bin/activate"
# Because it's a virtualenv, we assume $PYTHONPATH is unnecessary for
# anything in the venv to work correctly, and having it set can cause
# problems when there are conflicts with Galaxy's dependencies outside
Expand All @@ -122,7 +124,7 @@ if [ $SET_VENV -eq 1 ]; then
fi

if [ -z "$VIRTUAL_ENV" ]; then
echo "ERROR: A virtualenv cannot be found. Please create a virtualenv in .venv, or activate one."
echo "ERROR: A virtualenv cannot be found. Please create a virtualenv in $GALAXY_VIRTUAL_ENV, or activate one."
exit 1
fi
fi
Expand Down

0 comments on commit 8fd83df

Please sign in to comment.