forked from strnad/CrewAI-Studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_conda.sh
executable file
·81 lines (67 loc) · 2.67 KB
/
install_conda.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Get the directory of the current script
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
# Path to your Miniconda installation
CONDA_PATH="$SCRIPT_DIR/miniconda"
# Function to prompt the user for yes/no response
prompt_yes_no() {
while true; do
read -p "$1 (y/n): " yn
case $yn in
[Yy]* ) return 0;;
[Nn]* ) return 1;;
* ) echo "Please answer yes (y) or no (n).";;
esac
done
}
# Check if Miniconda is already installed
if [ ! -d "$CONDA_PATH" ]; then
# Download Miniconda installer
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
# Install Miniconda
bash miniconda.sh -b -p "$CONDA_PATH"
# Clean up installer
rm miniconda.sh
else
echo "Miniconda is already installed in $CONDA_PATH. Skipping installation."
fi
# Initialize Conda for this script session only
if [ -f "$CONDA_PATH/etc/profile.d/conda.sh" ]; then
source "$CONDA_PATH/etc/profile.d/conda.sh"
else
echo "ERROR: Miniconda installation not found at $CONDA_PATH"
exit 1
fi
# Prompt to remove the existing environment if it exists
if conda info --envs | grep -q 'crewai'; then
if prompt_yes_no "The Conda environment 'crewai' already exists. Do you want to reinstall it?"; then
echo "Removing existing Conda environment..."
conda remove --name crewai --all -y || { echo "Failed to remove existing Conda environment"; exit 1; }
else
echo "Installation canceled."
exit 0
fi
fi
# Create a new environment
conda create -n crewai python=3.11 -y || { echo "Failed to create Conda environment"; exit 1; }
# Prompt for cache usage
USE_CACHE="--no-cache"
if prompt_yes_no "Do you want to use the cache for pip installation?"; then
USE_CACHE=""
fi
# Ensure the environment is activated and install the necessary packages
conda run -n crewai conda install -y packaging || { echo "Failed to install Conda packages"; exit 1; }
conda run -n crewai pip install -r requirements.txt $USE_CACHE || { echo "Failed to install requirements"; exit 1; }
# Agentops
echo "Do you want to install agentops? (y/n)"
read agentops
if [ "$agentops" == "y" ]; then
echo "Installing agentops..."
conda run -n crewai pip install agentops || { echo "Failed to install agentops"; }
fi
# Check if .env file exists, if not copy .env_example to .env
if [ ! -f "$SCRIPT_DIR/.env" ]; then
echo ".env file does not exist. Copying .env_example to .env..."
cp "$SCRIPT_DIR/.env_example" "$SCRIPT_DIR/.env"
fi
echo "Installation completed successfully. Do not forget to update the .env file with your credentials. Then run run_conda.sh to start the app."