scripts/venv.sh

31 lines
879 B
Bash
Raw Normal View History

2024-10-14 12:04:47 +11:00
#!/bin/bash
# This script is used to create a virtual environment for the project
2024-11-07 14:37:03 +11:00
if [ "$1" = "exit" ]; then
echo "Exiting virtual environment"
deactivate
else
# Check if the virtual environment already exists
if [ -d ".venv" ]; then
2024-10-14 12:04:47 +11:00
# Check if the virtual environment is active
if [ -n "$VIRTUAL_ENV" ]; then
echo "Virtual environment is active"
else
echo "Activating existing virtual environment"
source .venv/bin/activate
fi
2024-11-07 14:37:03 +11:00
else
# Create the virtual environment
python3 -m venv .venv
2024-10-14 12:04:47 +11:00
2024-11-07 14:37:03 +11:00
# Activate the virtual environment
source .venv/bin/activate
2024-10-14 12:04:47 +11:00
2024-11-07 14:37:03 +11:00
# Install the required packages
if [ -f "requirements.txt" ]; then
echo "Installing required packages"
python3 -m pip install -r requirements.txt
fi
2024-10-14 12:04:47 +11:00
fi
fi