-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv_install.sh
executable file
·77 lines (63 loc) · 1.89 KB
/
env_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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# DO NOT USE SUDO WHEN CALLING THIS SCRIPT
programname=$0
function usage {
echo "usage: $programname"
}
usage
if [[ $EUID == 0 ]]; then
echo "ERROR: This script must NOT be run as root! This is so that pip3 does"\
"not try to install into root directories."
exit 1
fi
if [ $OSTYPE != linux-gnu ]; then
echo "Warning: script is designed for Linux installation. You must manually"\
"setup python3 and pip3 on your machine if you are not using Linux."\
"The rest of the script should work fine otherwise."
fi
PACKAGE_MANAGER=""
if [ "$(command which yum)" ]; then
echo "Using yum install"
PACKAGE_MANAGER="yum"
elif [ -n "$(command which apt-get)" ] || [ -n "$(command which apt)" ] ; then
echo "Using apt-get install"
PACKAGE_MANAGER="apt-get"
else
echo "Script only supports yum and apt-get package managers. Please"
echo "manually install python3 and pip3"
fi
sudo -s <<EOF
if [ $PACKAGE_MANAGER ]; then
echo "Installing python3.5, dev tools, pip3 using package manager."
$PACKAGE_MANAGER install python3.5 --upgrade
$PACKAGE_MANAGER install python3.5-dev libxml2-dev libxslt-dev \
python3-pycurl --upgrade
$PACKAGE_MANAGER install python3-pip --upgrade
fi
EOF
if [ -a .env ]; then
echo
while true ; do
read -p "Delete the existing environment? [Y/n]" -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]] ; then
rm -rf .env
break
elif [[ $REPLY =~ ^[Nn]$ ]] ; then
break
else
continue
fi
done
fi
echo "Updating pip3, installing virtualenv with pip3 and setting up "\
"environment."
pip3 install virtualenv --upgrade
virtualenv --no-site-packages --distribute .env
source .env/bin/activate
if [ -a pip3_requirements.txt ] ; then
pip3 install -r pip3_requirements.txt --upgrade
else
echo "Note: pip3_requirements.txt file does not exist, so pip3 will not" \
"install any packages."
fi