-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·58 lines (51 loc) · 1.37 KB
/
setup.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
51
52
53
54
55
56
57
58
#!/bin/sh
if [ "$(id -u)" = 0 ]
then
echo "The setup script should not be run with sudo."
echo "Aborting."
exit 1
fi
skel_home="$(dirname "$(readlink -f "$0")")"
virtual_env="$skel_home/.venv"
report_broken_venv() {
echo "Something is wrong with the virtual environment."
echo "Delete the \"$virtual_env\" directory and try again."
exit 1
}
if [ ! -d "$virtual_env" ]
then
# Create virtual environment
echo "Creating virtual environment..."
if python -m venv "$virtual_env"
then
echo "Virtual environment created at \"$virtual_env\""
else
echo "Cannot create virtual environment."
echo "Aborting"
exit 1
fi
else
if [ ! -f "$virtual_env/bin/activate" ]
then
# Missing activation script
echo "The activation script for the virtual environment is missing."
report_broken_venv
fi
fi
# Activate virtual environment
echo "Activating virtual environment..."
. "$virtual_env/bin/activate"
echo "Virtual environment activated."
# Install dependencies
if command -v pip > /dev/null 2>&1
then
echo "Installing dependencies..."
pip install -r "$skel_home/requirements.txt"
else
# Pip should be available once the virtual environment is activated
echo "The executable for 'pip' is missing."
report_broken_venv
fi
chmod +x "$skel_home/bin/skel"
echo ""
echo "Setup complete."