-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
47 lines (36 loc) · 1.32 KB
/
install.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
#!/bin/bash
# 1. First check to see if the correct version of Python is installed on the local machine
echo "Checking Python version..."
REQ_PYTHON_V="370"
ACTUAL_PYTHON_V=$(python -c 'import sys; version=sys.version_info[:3]; print("{0}{1}{2}".format(*version))')
ACTUAL_PYTHON3_V=$(python3 -c 'import sys; version=sys.version_info[:3]; print("{0}{1}{2}".format(*version))')
if [[ $ACTUAL_PYTHON_V > $REQ_PYTHON_V ]] || [[ $ACTUAL_PYTHON_V == $REQ_PYTHON_V ]]; then
PYTHON="python"
elif [[ $ACTUAL_PYTHON3_V > $REQ_PYTHON_V ]] || [[ $ACTUAL_PYTHON3_V == $REQ_PYTHON_V ]]; then
PYTHON="python3"
else
echo -e "\tPython 3.7 is not installed on this machine. Please install Python 3.7 before continuing."
exit 1
fi
echo -e "\t--Python 3.7 is installed"
# 2. Create Virtual environment
# Remove the env directory if it exists
if [[ -d env ]]; then
rm -rf env
fi
echo -e "Creating virtual environment..."
$PYTHON -m venv env
if [[ ! -d env ]]; then
echo -e "\t--Could not create virutal environment...Please make sure venv is installed"
exit 1
fi
# 3. Install requirements
echo -e "Installing Requirements"
if [[ ! -e "requirements.txt" ]]; then
echo -e "\t--Need to requirements.txt to install packages."
exit 1
fi
source env/bin/activate
pip install -r requirements.txt
deactivate
echo -e "Done."