From e2dc5ab85d64acecb0f4c8b371d9678f6c57939c Mon Sep 17 00:00:00 2001 From: Jeffrey Zampieron Date: Tue, 1 Sep 2020 21:35:12 -0400 Subject: [PATCH] Attempt to auto set conda env --- build_unix_dev_conda.sh | 15 +++++++++++++-- conda/build.sh | 0 2 files changed, 13 insertions(+), 2 deletions(-) mode change 100644 => 100755 conda/build.sh diff --git a/build_unix_dev_conda.sh b/build_unix_dev_conda.sh index 4b006438ec..41d094d425 100755 --- a/build_unix_dev_conda.sh +++ b/build_unix_dev_conda.sh @@ -38,7 +38,18 @@ if [ $? != 0 ]; then exit 1 fi -conda activate ${FCENV} +if [[ "${CONDA_DEFAULT_ENV}" =~ "${FCENV}" ]]; then + echo "Already in env" +elif [[ -z "${CONDA_DEFAULT_ENV}" ]]; then + echo "Not in conda env... activating" + conda activate ${FCENV} +else + # Assume we are in some other env. + echo "In ${CONDA_DEFAULT_ENV}, attempting switch to ${FCENV}" + conda deactivate + conda activate ${FCENV} +fi + if [ $? != 0 ]; then echo "Failed to activate conda env: ${FCENV} ... creating" @@ -65,4 +76,4 @@ if [ -z "${CONDA_PREFIX}" ]; then exit 1 fi -PREFIX="${CONDA_PREFIX}" ./conda/build.sh +PREFIX="${CONDA_PREFIX}" ./conda/build.sh diff --git a/conda/build.sh b/conda/build.sh old mode 100644 new mode 100755