fix: fix script dependency check and paths (#186)

Allows you to run the script from outside of the testing directory.
This commit is contained in:
Louise Poole
2025-03-27 16:55:37 +01:00
committed by GitHub
parent 63f9c89429
commit 97cab90b58

View File

@@ -5,23 +5,12 @@ command_exists() {
command -v "$1" >/dev/null 2>&1 command -v "$1" >/dev/null 2>&1
} }
# Map of dependencies to their binaries (used to check if they are installed) # Check each dependency is installed
declare -A dependencies=( local deps=("git" "rustc" "gcc" "openssl" "conda" "pip" "pg_config")
["git"]="git" local names=("git" "rust" "gcc" "openssl" "conda" "pip" "libpq")
["rust"]="rustc" for i in "${!deps[@]}"; do
["gcc"]="gcc" if ! command_exists "${deps[$i]}"; then
["openssl"]="openssl" echo "Error: '${names[$i]}' is not installed."
["pkg-config"]="pkg-config"
["conda"]="conda"
["pip"]="pip"
["libpq"]="pg_config"
)
# Check each dependency
for dep in "${!dependencies[@]}"; do
binary=${dependencies[$dep]}
if ! command_exists "$binary"; then
echo "Error: '$dep' is not installed."
exit 1 exit 1
fi fi
done done
@@ -31,7 +20,10 @@ echo "All dependencies are installed. Proceeding with setup..."
# Variables # Variables
ENV_NAME="tycho-protocol-sdk-testing" ENV_NAME="tycho-protocol-sdk-testing"
PYTHON_VERSION="3.9" PYTHON_VERSION="3.9"
REQUIREMENTS_FILE="requirements.txt" # Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR="$( cd "$SCRIPT_DIR/.." && pwd )" # Assuming the script is in a subdirectory of the root
REQUIREMENTS_FILE="$ROOT_DIR/testing/requirements.txt"
# Create conda environment # Create conda environment
echo "Creating conda environment ${ENV_NAME} with Python ${PYTHON_VERSION}..." echo "Creating conda environment ${ENV_NAME} with Python ${PYTHON_VERSION}..."
@@ -46,5 +38,6 @@ echo "Installing the requirements from ${REQUIREMENTS_FILE}..."
pip install -r $REQUIREMENTS_FILE --index-url https://pypi.org/simple pip install -r $REQUIREMENTS_FILE --index-url https://pypi.org/simple
conda activate $ENV_NAME conda activate $ENV_NAME
echo "Setup complete." echo "----------------------------------------"
echo "SETUP COMPLETE."
echo "Run 'conda activate $ENV_NAME' to activate the environment." echo "Run 'conda activate $ENV_NAME' to activate the environment."