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
}
# Map of dependencies to their binaries (used to check if they are installed)
declare -A dependencies=(
["git"]="git"
["rust"]="rustc"
["gcc"]="gcc"
["openssl"]="openssl"
["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."
# Check each dependency is installed
local deps=("git" "rustc" "gcc" "openssl" "conda" "pip" "pg_config")
local names=("git" "rust" "gcc" "openssl" "conda" "pip" "libpq")
for i in "${!deps[@]}"; do
if ! command_exists "${deps[$i]}"; then
echo "Error: '${names[$i]}' is not installed."
exit 1
fi
done
@@ -31,7 +20,10 @@ echo "All dependencies are installed. Proceeding with setup..."
# Variables
ENV_NAME="tycho-protocol-sdk-testing"
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
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
conda activate $ENV_NAME
echo "Setup complete."
echo "----------------------------------------"
echo "SETUP COMPLETE."
echo "Run 'conda activate $ENV_NAME' to activate the environment."