Fix testing env stup script
- Fails now if any command errors - Conda environment activation is more stable now
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# To run: ./setup_env.sh
|
# To run: ./setup_env.sh
|
||||||
|
set -e
|
||||||
|
|
||||||
command_exists() {
|
command_exists() {
|
||||||
command -v "$1" >/dev/null 2>&1
|
command -v "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check each dependency is installed
|
# Check each dependency is installed
|
||||||
local deps=("git" "rustc" "gcc" "openssl" "conda" "pip" "pg_config")
|
deps=("git" "rustc" "gcc" "openssl" "conda" "pip" "pg_config")
|
||||||
local names=("git" "rust" "gcc" "openssl" "conda" "pip" "libpq")
|
names=("git" "rust" "gcc" "openssl" "conda" "pip" "libpq")
|
||||||
for i in "${!deps[@]}"; do
|
for i in "${!deps[@]}"; do
|
||||||
if ! command_exists "${deps[$i]}"; then
|
if ! command_exists "${deps[$i]}"; then
|
||||||
echo "Error: '${names[$i]}' is not installed."
|
echo "Error: '${names[$i]}' is not installed."
|
||||||
@@ -31,7 +32,8 @@ conda create --name $ENV_NAME python=$PYTHON_VERSION -y
|
|||||||
|
|
||||||
# Activate the environment
|
# Activate the environment
|
||||||
echo "Activating the environment..."
|
echo "Activating the environment..."
|
||||||
source activate $ENV_NAME
|
eval "$(conda shell.bash hook)"
|
||||||
|
conda activate $ENV_NAME
|
||||||
|
|
||||||
# Install the requirements
|
# Install the requirements
|
||||||
echo "Installing the requirements from ${REQUIREMENTS_FILE}..."
|
echo "Installing the requirements from ${REQUIREMENTS_FILE}..."
|
||||||
@@ -40,4 +42,4 @@ conda activate $ENV_NAME
|
|||||||
|
|
||||||
echo "----------------------------------------"
|
echo "----------------------------------------"
|
||||||
echo "SETUP COMPLETE."
|
echo "SETUP COMPLETE."
|
||||||
echo "Run 'conda activate $ENV_NAME' to activate the environment."
|
echo "Run 'conda activate $ENV_NAME' to activate the environment."
|
||||||
|
|||||||
Reference in New Issue
Block a user