From 6c725a38149f1810aa74f306c745b4526a472d15 Mon Sep 17 00:00:00 2001 From: kalomaze <66376113+kalomaze@users.noreply.github.com> Date: Tue, 25 Jul 2023 20:06:18 -0500 Subject: [PATCH] Reorder PATH checks and install onnxruntime --- run.sh | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/run.sh b/run.sh index 0ebec6b..3a082da 100644 --- a/run.sh +++ b/run.sh @@ -43,16 +43,24 @@ add_to_path() { # Source the shell profile file source "$shell_profile" + + # Verify that the new PATH includes Homebrew + if ! command -v brew &> /dev/null; then + echo "Failed to add Homebrew to the PATH." + fi fi } # Check if Homebrew is in PATH -if ! command -v brew &> /dev/null; then +if command -v brew &> /dev/null; then + echo "Homebrew is already in your PATH." +else # If not, check common paths for Homebrew echo "Homebrew not found in PATH. Checking common paths..." for path in "${BREW_PATHS[@]}"; do if [[ -x "$path/brew" ]]; then add_to_path "$path" + break fi done fi @@ -60,7 +68,7 @@ fi # Check again if Homebrew is in PATH if ! command -v brew &> /dev/null; then echo "Homebrew still not found. Attempting to install..." - INSTALL_OUTPUT=$(/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)") + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" fi # Verifying if Homebrew has been installed successfully @@ -71,29 +79,6 @@ else exit 1 fi -# Extracting the commands to add Homebrew to the PATH -PATH_COMMANDS=$(echo "$INSTALL_OUTPUT" | awk '/Next steps:/,/Further documentation:/' | grep 'eval') - -echo "Extracted commands to add Homebrew to the PATH:" - -IFS=$'\n' # Set the Internal Field Separator to a new line -for cmd in $PATH_COMMANDS -do - echo "$cmd" -done - -# Asking the user if they want to execute them -echo "Do you want to automatically add Homebrew to your PATH by executing the commands above? (y/n)" -read -p "Are you sure you want to run these commands? (y/n) " -n 1 -r -echo -if [[ $REPLY =~ ^[Yy]$ ]]; then - IFS=$'\n' # Set the Internal Field Separator to a new line - for cmd in $PATH_COMMANDS - do - eval "$cmd" - done -fi - # Installing ffmpeg with Homebrew if [[ "$(uname)" == "Darwin" ]]; then echo "Installing ffmpeg..." @@ -116,7 +101,7 @@ fi # Check if required packages are installed and install them if not if [ -f "${requirements_file}" ]; then - installed_packages=$(python3.8 -m pip freeze) + installed_packages=$(python3.8 -m pip list --format=freeze) while IFS= read -r package; do [[ "${package}" =~ ^#.* ]] && continue package_name=$(echo "${package}" | sed 's/[<>=!].*//') @@ -130,5 +115,9 @@ else exit 1 fi +# Install onnxruntime package +echo "Installing onnxruntime..." +python3.8 -m pip install onnxruntime + # Run the main script python3.8 infer-web.py --pycmd python3.8