From 51746acd8ec8cd51a8ece926dfff5fe659fbe7c5 Mon Sep 17 00:00:00 2001 From: Francisco Javier Arceo Date: Tue, 18 Feb 2025 05:49:28 -0500 Subject: [PATCH] fix: Fixing some small issues with the build script after updating mac OS Signed-off-by: Francisco Javier Arceo --- llama_stack/distribution/build_venv.sh | 2 +- llama_stack/distribution/common.sh | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/llama_stack/distribution/build_venv.sh b/llama_stack/distribution/build_venv.sh index 0b0bffcfd..5c94e1356 100755 --- a/llama_stack/distribution/build_venv.sh +++ b/llama_stack/distribution/build_venv.sh @@ -44,7 +44,7 @@ NC='\033[0m' # No Color # this is set if we actually create a new conda in which case we need to clean up ENVNAME="" -SCRIPT_DIR=$(dirname "$(readlink -f "$0")") +SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) source "$SCRIPT_DIR/common.sh" # pre-run checks to make sure we can proceed with the installation diff --git a/llama_stack/distribution/common.sh b/llama_stack/distribution/common.sh index 171023389..15220048b 100755 --- a/llama_stack/distribution/common.sh +++ b/llama_stack/distribution/common.sh @@ -10,12 +10,12 @@ cleanup() { set +x echo "Cleaning up..." conda deactivate - conda env remove --name $envname -y + conda env remove --name "$envname" -y } handle_int() { - if [ -n $ENVNAME ]; then - cleanup $ENVNAME + if [ -n "$ENVNAME" ]; then + cleanup "$ENVNAME" fi exit 1 } @@ -23,8 +23,8 @@ handle_int() { handle_exit() { if [ $? -ne 0 ]; then echo -e "\033[1;31mABORTING.\033[0m" - if [ -n $ENVNAME ]; then - cleanup $ENVNAME + if [ -n "$ENVNAME" ]; then + cleanup "$ENVNAME" fi fi } @@ -33,10 +33,14 @@ setup_cleanup_handlers() { trap handle_int INT trap handle_exit EXIT - __conda_setup="$('conda' 'shell.bash' 'hook' 2>/dev/null)" - eval "$__conda_setup" - - conda deactivate + if is_command_available conda; then + __conda_setup="$('conda' 'shell.bash' 'hook' 2>/dev/null)" + eval "$__conda_setup" + conda deactivate + else + echo "conda is not available" + exit 1 + fi } # check if a command is present