-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·47 lines (37 loc) · 1.2 KB
/
setup.sh
File metadata and controls
executable file
·47 lines (37 loc) · 1.2 KB
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
#!/bin/bash
# Location of the Python virtual environment.
VENV_DIR=".venv"
# Check if Python 3 is installed
if ! command -v python3 &> /dev/null; then
echo "Error: Python 3 is not installed. Please install Python 3.9 or higher."
exit 1
fi
# Create and set up the virtual environment if it does not already exist.
if [ ! -d "$VENV_DIR" ]; then
echo "Creating virtual environment..."
python3 -m venv "$VENV_DIR"
if [ $? -ne 0 ]; then
echo "Error: Failed to create virtual environment."
exit 1
fi
source "$VENV_DIR/bin/activate"
# Install dependencies if a requirements file is provided.
if [ -f "requirements.txt" ]; then
echo "Installing dependencies..."
pip install --upgrade pip
pip install -r requirements.txt
if [ $? -ne 0 ]; then
echo "Error: Failed to install dependencies."
deactivate
exit 1
fi
echo "Dependencies installed successfully."
else
echo "Warning: No requirements.txt found. Skipping dependency installation."
fi
else
# If the virtual environment already exists, just activate it.
echo "Virtual environment already exists. Activating..."
source "$VENV_DIR/bin/activate"
fi
echo "✓ Environment ready."