-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdevobs.sh
42 lines (31 loc) · 1.09 KB
/
devobs.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
#!/bin/bash
# Exit immediately if any command exits with a non-zero status
set -e
# Check the Python version
if ! python3 --version 2>&1 | grep -q "Python 3"; then
echo "Error: Python 3 is required to run this application."
exit 1
fi
# Set the name of your virtual environment
VENV_NAME="myenv"
# Set the path where the virtual environment will be created
VENV_PATH="$(dirname "$0")/$VENV_NAME"
# Check if the dummy file exists
if [ ! -d "$VENV_PATH" ]; then
echo "For first time use, creating virtual environment and installing dependencies. This will take some while."
# Create the virtual environment
python3 -m venv "$VENV_PATH"
# Activate the virtual environment
source "$VENV_PATH/bin/activate"
# Install required packages using pip
pip install -r requirements.txt
echo "Virtual environment \"$VENV_NAME\" has been created and activated."
echo
else
# Activate the virtual environment
source "$VENV_PATH/bin/activate"
fi
python3 app.py "$@"
# Deactivate the virtual environment when finished
deactivate
echo "Virtual environment has been deactivated."