-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_virtual_env.sh
More file actions
executable file
·54 lines (42 loc) · 1.72 KB
/
setup_virtual_env.sh
File metadata and controls
executable file
·54 lines (42 loc) · 1.72 KB
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
51
# bin/bash
VENV_NAME='samba'
# ==========================================================
# Checking necessary language and libraries that must be
# install by the user.
# ==========================================================
# Checks that python3 is installed as well as pip3
if (! type "python3" > /dev/null); then
echo "python3 is not installed on your system."
echo "Install it before to launch this program".
exit 1
fi
# ===========================================================
# Creating Python virtual environment
# ===========================================================
if [ ! -d $VENV_NAME ]; then
echo "Creating Python virtual environment..."
python3 -m venv $VENV_NAME
echo "Virtual environment created successfully"
else
if [ -f $VENV_NAME ]; then
echo "Virtual environment cannot be created: a file called $VENV_NAME already exists"
exit 1
elif [ ! -f $VENV_NAME/bin/python3 ]; then
echo "Virtual environment cannot be created: Python3 binary not found inside the virtual environment"
exit 2
else
echo "Virtual environment already exists"
fi
fi
# updating pip
"$VENV_NAME/bin/python3" -m pip install --upgrade pip
# ==========================================================
# Initializing Python virtual environment
# ==========================================================
echo "Initializing virtual environment..."
# installing requires dependencies detailed in the requirements.txt file
"$VENV_NAME/bin/python3" -m pip install -r requirements.txt
echo '------------------------------------'
echo 'Virtual environment ready to be used.'
echo "Type this command to enter in environment: source $VENV_NAME/bin/activate"
echo "Type this commant to exit the environment: deactivate"