From b5cd57a4c530cbd890fc45488c78702d42e0b102 Mon Sep 17 00:00:00 2001 From: Keeran Rothenfusser <141222236+keeranroth@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:40:58 +0100 Subject: [PATCH] Only load conda environment if required (#2698) The build script for CI is useful to use locally. However, the conda path does not need to be the same on the local system. As such, we only source the conda environment in the case that we request it. Locally, having conda available in PATH will prevent conda from being sourced again. --- .ci/scripts/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/scripts/build.sh b/.ci/scripts/build.sh index 8937c04ad4c..9b45a2eacd6 100755 --- a/.ci/scripts/build.sh +++ b/.ci/scripts/build.sh @@ -90,8 +90,8 @@ backend_config=${backend_config:-mkl} GLOBAL_RETURN=0 if [ "${OS}" == "lnx" ]; then - source /usr/share/miniconda/etc/profile.d/conda.sh if [ "${conda_env}" != "" ]; then + command -v conda >/dev/null 2>&1 || source /usr/share/miniconda/etc/profile.d/conda.sh conda activate ${conda_env} echo "conda '${conda_env}' env activated at ${CONDA_PREFIX}" fi @@ -104,8 +104,8 @@ if [ "${OS}" == "lnx" ]; then with_gpu="false" fi elif [ "${OS}" == "mac" ]; then - source /usr/local/miniconda/etc/profile.d/conda.sh if [ "${conda_env}" != "" ]; then + command -v conda >/dev/null 2>&1 || source /usr/local/miniconda/etc/profile.d/conda.sh conda activate ${conda_env} echo "conda '${conda_env}' env activated at ${CONDA_PREFIX}" fi