-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·50 lines (40 loc) · 1.23 KB
/
setup.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
#!/bin/bash
# Define the virtual environment directory and requirements file
VENV_DIR="./.venv"
REQUIREMENTS_FILE="./requirements.txt"
# Check if the virtual environment directory exists
if [ -d "$VENV_DIR" ]; then
echo "Virtual environment already exists at $VENV_DIR."
else
echo "Virtual environment not found. Creating one at $VENV_DIR..."
# Create the virtual environment
python3 -m venv "$VENV_DIR"
if [ $? -ne 0 ]; then
echo "Failed to create virtual environment. Ensure Python 3 is installed and accessible."
exit 1
fi
echo "Virtual environment created."
fi
# Activate the virtual environment
source "$VENV_DIR/bin/activate"
if [ $? -ne 0 ]; then
echo "Failed to activate virtual environment."
exit 1
fi
# Check if requirements.txt exists
if [ -f "$REQUIREMENTS_FILE" ]; then
echo "Installing dependencies from $REQUIREMENTS_FILE..."
# Install dependencies
pip install -r "$REQUIREMENTS_FILE"
if [ $? -ne 0 ]; then
echo "Failed to install dependencies."
deactivate
exit 1
fi
echo "Dependencies installed successfully."
else
echo "No requirements file found at $REQUIREMENTS_FILE. Skipping dependency installation."
fi
# Deactivate the virtual environment
deactivate
echo "Setup complete."