-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·207 lines (177 loc) · 4.09 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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/bin/bash
UN=""
UP=""
FORCE=false
pvers="false"
P3=false
P2=false
LOCAL=false
for i in "$@"; do
case $i in
-up|--update)
UP="--upgrade"
UN=""
shift
;;
-un|--uninstall)
UP=""
UN="un"
shift
;;
-p=*|--python=*)
pvers="${i#*=}"
if [ "$pvers" = "2" ]; then
P2=true
fi
if [ "$pvers" = "3" ]; then
P3=true
fi
shift
;;
-f|--force)
FORCE=true
shift
;;
-l|--local)
LOCAL=true
shift
;;
*)
>&2 cat <<EOF
ERROR: install.sh [OPTIONS]
[OPTIONS]
-f | --force )
force default values:
Install python dependencies and
Install UNIX packages
-l | --local )
Install local version with local modifications.
Otherwise, git repository version will be installed.
-up | --update )
Update or Upgrade all the packages.
-un | --uninstall )
Uninstall all except UNIX packages.
-p=[VERSION] | --python=[VERSION] )
Install only for python version number [VERSION].
It has to be 2 or 3.
EOF
exit -1
;;
esac
done
exists(){
command -v "$1" >/dev/null 2>&1
}
if [ "$pvers" = "false" ]; then
if exists python2; then
P2=true
else
P2=false
fi
if exists python3; then
P3=true
else
P3=false
fi
fi
flags=""
# check sudo permission
if [ "$EUID" -ne 0 ]; then
flags=$flags" --user"
fi
# get base folder
if [ "$(uname -s)" = 'Linux' ]; then
basedir=$(dirname "$(readlink -f "$0" )")
else
basedir=$(dirname "$(readlink "$0" )")
fi
# Python 2 or 3 or both?
while [ "$pvers" = "false" -a "$P2" = "true" -a "$P3" = "true" ]; do
read -p "Which python version do you want to use? [2/3/B] (default: B - Both)" yn
case $yn in
[2]*)
P3=false
break;;
[3]* )
P2=false
break;;
""|[bB])
break;;
* ) echo "Invalid option."; echo $yn;;
esac
done
if [ "$FORCE" = "true" ]; then
pdepen=true
udepen=true
else
pdepen=true
while true; do
read -p "Do you want to install the standar Python dependencies? [Y/n]" yn
case $yn in
[yY][eE][sS]|[yY])
break;;
[nN][oO]|[nN])
echo "Be sure to have them already installed, otherwise the installation will crash."
pdepen=false
break;;
"")
break;;
* ) echo "Invalid option."; echo $yn;;
esac
done
udepen=$pdepen
while [[ $pdepen == true ]]; do
read -p "Do you want to install the UNIX dependencies? [Y/n]" yn
case $yn in
[yY][eE][sS]|[yY])
break;;
[nN][oO]|[nN])
echo "Be sure to have them already installed, otherwise the installation will crash."
udepen=false
break;;
"")
break;;
* ) echo "Invalid option."; echo $yn;;
esac
done
fi
python$vers -m pip $UN"install" $flags git+https://github.com/jesusjda/pyLPi.git#egg=pyLPi
if [ "$udepen" = "true" ]; then
sudo apt-get install python-nose
sudo apt-get install libgmp-dev
sudo apt-get install libmpfr-dev
sudo apt-get install libmpc-dev
sudo apt-get install libppl-dev
fi
install()
{
if [ "$UN" = "un" ]; then
lflags=" -y"
else
lflags=$flags" $UP"
fi
vers=$1
echo "----------------------------------"
echo "Installing pyLPi on Python $vers"
echo "----------------------------------"
if [ "$pdepen" = "true" ]; then
python$vers -m pip $UN"install" $lflags z3 'Cython==0.26' virtualenv
python$vers -m pip $UN"install" $lflags cysignals
python$vers -m pip $UN"install" $lflags git+https://github.com/aleaxit/[email protected]#egg=gmpy2
python$vers -m pip $UN"install" $lflags git+https://github.com/videlec/pplpy.git#egg=pplpy
fi
if [ "$LOCAL" = "true" ]; then
python$vers -m pip $UN"install" $lflags .
else
python$vers -m pip $UN"install" $lflags git+https://github.com/jesusjda/pyLPi.git#egg=pyLPi
fi
}
if [ "$P2" = "true" ]; then
easy_install $flags pip
install 2
fi
if [ "$P3" = "true" ]; then
easy_install3 $flags pip
install 3
fi
echo "Success!"