diff --git a/run.sh b/run.sh index 8e821f238a3..8453587280e 100755 --- a/run.sh +++ b/run.sh @@ -18,7 +18,7 @@ fi while : do case "$1" in - --skip-eggs|--skip-wheels|--skip-samples|--dev-wheels|--no-create-venv|--no-replace-pip) + --skip-eggs|--skip-wheels|--skip-samples|--dev-wheels|--no-create-venv|--no-replace-pip|--replace-pip) common_startup_args="$common_startup_args $1" shift ;; @@ -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 diff --git a/run_tests.sh b/run_tests.sh index b91e618f010..c4cf50e493a 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -296,6 +296,10 @@ do no_replace_pip='--no-replace-pip' shift ;; + --replace-pip) + replace_pip='--replace-pip' + shift + ;; --skip-common-startup) # Don't run ./scripts/common_startup.sh (presumably it has already # been done, or you know what you're doing). @@ -322,13 +326,14 @@ if [ -z "$skip_common_startup" ]; then GALAXY_CONFIG_OVERRIDE_DATABASE_CONNECTION=$GALAXY_TEST_DBURI export GALAXY_CONFIG_OVERRIDE_DATABASE_CONNECTION fi - ./scripts/common_startup.sh $skip_venv $no_create_venv $no_replace_pip --dev-wheels || exit 1 + ./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 diff --git a/scripts/common_startup.sh b/scripts/common_startup.sh index 98365595b31..bb5fd8243d1 100755 --- a/scripts/common_startup.sh +++ b/scripts/common_startup.sh @@ -1,19 +1,24 @@ #!/bin/bash set -e +SET_VENV=1 +for arg in "$@"; do + [ "$arg" = "--skip-venv" ] && SET_VENV=0 +done + DEV_WHEELS=0 FETCH_WHEELS=1 -SET_VENV=1 CREATE_VENV=1 -REPLACE_PIP=1 +REPLACE_PIP=$SET_VENV COPY_SAMPLE_FILES=1 + for arg in "$@"; do [ "$arg" = "--skip-eggs" ] && FETCH_WHEELS=0 [ "$arg" = "--skip-wheels" ] && FETCH_WHEELS=0 [ "$arg" = "--dev-wheels" ] && DEV_WHEELS=1 - [ "$arg" = "--skip-venv" ] && SET_VENV=0 [ "$arg" = "--no-create-venv" ] && CREATE_VENV=0 [ "$arg" = "--no-replace-pip" ] && REPLACE_PIP=0 + [ "$arg" = "--replace-pip" ] && REPLACE_PIP=1 [ "$arg" = "--stop-daemon" ] && FETCH_WHEELS=0 [ "$arg" = "--skip-samples" ] && COPY_SAMPLE_FILES=0 done @@ -61,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" @@ -93,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 @@ -102,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 @@ -117,13 +124,13 @@ 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 : ${GALAXY_WHEELS_INDEX_URL:="https://wheels.galaxyproject.org/simple"} -if [ $SET_VENV -eq 1 -a $REPLACE_PIP -eq 1 ]; then +if [ $REPLACE_PIP -eq 1 ]; then pip_version=`pip --version | awk '{print $2}'` pre=`python -c "from pkg_resources import parse_version; from sys import stdout; stdout.write('--pre') if parse_version('$pip_version') >= parse_version('1.4') else stdout.write('')"` pip install $pre --no-index --find-links ${GALAXY_WHEELS_INDEX_URL}/pip --upgrade pip