diff --git a/scripts/freeze_deps.sh b/scripts/freeze_deps.sh new file mode 100755 index 0000000..2b7a688 --- /dev/null +++ b/scripts/freeze_deps.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +# Check if the script is running in the root directory of the project +PROJECT_ROOT="freq-split-enhance" +CURRENT_DIR=$(basename "$PWD") + +if [ "$CURRENT_DIR" != "$PROJECT_ROOT" ]; then + echo "This script must be run in the root directory of the project: '$PROJECT_ROOT'." + exit 1 +fi + +# Check if the envs/ directory exists +if [ ! -d "envs" ]; then + echo "Directory 'envs/' does not exist. Please make sure it exists and contains the required environments. Please run the scripts/setup_env.sh script." + exit 1 +fi + +# Check if the requirements/ directory exists, create it if not +if [ ! -d "requirements" ]; then + echo "Directory 'requirements/' does not exist. Creating it..." + mkdir requirements +fi + +# Function to freeze the dependencies of an environment +freeze_env_deps() { + local env_dir=$1 + local requirements_file=$2 + + echo "Freezing dependencies for environment '$env_dir'..." + source "$env_dir/bin/activate" # Activate the environment + pip freeze > "$requirements_file" # Freeze the dependencies + deactivate # Deactivate the environment + echo "Dependencies for '$env_dir' saved to '$requirements_file'." +} + +# Loop through all the environments inside envs/ +for env_dir in envs/*; do + if [ -d "$env_dir" ]; then + env_name=$(basename "$env_dir") + requirements_file="requirements/$env_name.txt" + freeze_env_deps "$env_dir" "$requirements_file" + fi +done + +echo "Dependencies for all environments have been successfully frozen." + diff --git a/scripts/install_module.sh b/scripts/install_module.sh new file mode 100755 index 0000000..e9ef60c --- /dev/null +++ b/scripts/install_module.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# Check if the script is running in the root directory of the project +PROJECT_ROOT="freq-split-enhance" +CURRENT_DIR=$(basename "$PWD") + +if [ "$CURRENT_DIR" != "$PROJECT_ROOT" ]; then + echo "This script must be run in the root directory of the project: '$PROJECT_ROOT'." + exit 1 +fi + +# Check if the envs/ directory exists +if [ ! -d "envs" ]; then + echo "Directory 'envs/' does not exist. Please make sure it exists and contains the required environments. Please run the scripts/setup_env.sh script." + exit 1 +fi + +# List all environments in the envs/ directory +echo "Available environments:" +env_count=0 +envs_list=() + +for env_dir in envs/*; do + if [ -d "$env_dir" ]; then + env_name=$(basename "$env_dir") + envs_list+=("$env_name") + echo "$((env_count + 1)). $env_name" + ((env_count++)) + fi +done + +# Check if any environments exist +if [ "$env_count" -eq 0 ]; then + echo "No environments found in 'envs/'. Please create them first." + exit 1 +fi + +# Ask the user to select an environment +read -p "Select an environment (1-$env_count): " env_choice + +# Validate the user's choice +if [[ ! "$env_choice" =~ ^[0-9]+$ ]] || [ "$env_choice" -lt 1 ] || [ "$env_choice" -gt "$env_count" ]; then + echo "Invalid choice. Please select a number between 1 and $env_count." + exit 1 +fi + +# Get the selected environment name +selected_env="${envs_list[$((env_choice - 1))]}" + +# Ask the user for the module they want to install +read -p "Enter the module you want to install in the '$selected_env' environment: " module_name + +# Function to install a module in the selected environment +install_module() { + local env_dir=$1 + local module=$2 + + echo "Activating environment '$env_dir' and installing module '$module'..." + source "$env_dir/bin/activate" # Activate the environment + pip install "$module" # Install the module + deactivate # Deactivate the environment + echo "Module '$module' installed successfully in '$env_dir'." +} + +# Install the module in the selected environment +install_module "envs/$selected_env" "$module_name" + +echo "Module installation complete." + diff --git a/setup_env.sh b/scripts/setup_env.sh similarity index 69% rename from setup_env.sh rename to scripts/setup_env.sh index 3eab299..628b7ee 100755 --- a/setup_env.sh +++ b/scripts/setup_env.sh @@ -1,3 +1,14 @@ +#!/bin/bash + +# Check if the script is running in the root directory of the project +PROJECT_ROOT="freq-split-enhance" +CURRENT_DIR=$(basename "$PWD") + +if [ "$CURRENT_DIR" != "$PROJECT_ROOT" ]; then + echo "This script must be run in the root directory of the project: '$PROJECT_ROOT'." + exit 1 +fi + echo "Setting up virtual environments" mkdir envs