-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-venv.sh
50 lines (40 loc) · 1.38 KB
/
setup-venv.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
get_os(){
platform='unknown'
unamestr=$(uname)
if [[ "$unamestr" == "Linux" ]]; then
echo "Linux"
elif [[ "$unamestr" == "MINGW32_NT" ]]; then
echo "Windows"
fi
}
# Check if virtualenv is installed
if ! command -v virtualenv &> /dev/null; then
echo "Error: virtual env is not installed. Please install it using the following command. 'pip insatall virtualenv' and try again"
exit 1
fi
# Name of virtual environment
VENV_NAME="tracker"
# check the OS Of the machine
OS=$(get_os)
# Create Virtual Environment
echo "========== CREATING VIRTUAL ENVIRONMENT =========="
virtualenv "${VENV_NAME}"
echo "========== VIRTUAL ENVIRONMENT CREATED =========="
# Activate the environment
echo "========== ACTIVATING VIRTUAL ENVIRONMENT =========="
if [ "$OS" == "Linux" ]; then
source "$VENV_NAME/bin/activate"
elif [ "$OS" == "Windows" ]; then
"$VENV_NAME/Scripts/Activate"
fi
echo "========== VIRTUAL ENVIRONMENT ACTIVATED =========="
#Install dependencies
echo "========== INITIATING DEPENDENCY INSTALLATION =========="
pip install -r requirements.txt
echo "========== DEPENDENCY INSTALLATION COMPLETE =========="
# Deactivate Environment
echo "========== DEACTIVATING VIRTUAL ENVIRONMENT =========="
deactivate
echo "========== VIRTUAL ENVIRONMENT DEACTIVATED =========="
echo "========== Virtual environment created and dependencies installed successfully! =========="