forked from LMFDB/lmfdb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-deps.sh
executable file
·165 lines (161 loc) · 4.86 KB
/
install-deps.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
#/bin/bash
##
## Script to check and install dependencies under the sage shell
## Author: Fredrik Stromberg (2013)
##
# Parse the (few) parameters we take
dry_run=0
verbose=0
force_install=0
sage_exec=`which sage`
for par in $@
do
if [ `expr match $par '-h'` -ge 1 ]
then
echo "Parameters:"
echo " -h -- Print help (this) message"
echo " -n or -dry-run -- do a dry-run: check but do not install python packages"
echo " -v -- verbose; output more info"
echo " -f : force installation of packages even if version is not tested"
echo " -sage=path-to-sage -- use a specific sage, if not set we use the system default"
echo " -u --user -- do install packages in the user directory, not in the system-wide installation"
echo " Observe that some matching stuff does not work with all shell versions. Use -f in this case."
exit
fi
if [ `expr match $par '-n'` -ge 1 ] || [ `expr match $par '-dry-run'` -ge 1 ]
then
dry_run=1
echo "nothing will get installed! We do a dry run!"
fi
if [ `expr match $par '-f'` -ge 1 ]
then
force_install=1
fi
if [ `expr match $par '-v'` -ge 1 ]
then
verbose=1
fi
if [ `expr match $par '-u'` -ge 1 ] || [ `expr match $par '--user'` -ge 1 ]
then
user_install=1
easy_opts="$easy_opts --user"
fi
if [ `expr match $par '-sage'` -ge 1 ]
then
# extract executable
i=`expr index "$par" =`
sage_exec=${par:$i}
if [[ -x $sage_exec ]]
then
echo $sage_exec "is executable!"
else
echo $sage_exec "is not executable!"
exit
fi
fi
done
SAGEVERSION=`$sage_exec -v`
# Grab the major version
i=`expr index "$SAGEVERSION" .`
SAGE_MAJORVERSION=${SAGEVERSION:12:i-13}
# Grab the minor version
j=`expr index "$SAGEVERSION" ,`
SAGE_ROOT=`$sage_exec -root`
if [ $verbose = 1 ]
then
echo "sage_exec is " $sage_exec
echo "SAGE_ROOT is" $SAGE_ROOT
echo "SAGEVERSION is" $SAGEVERSION
fi
# Cut off any beta etc...
if [[ "$SAGEVERSION" =~ 'beta' ]]
then
TMP=${SAGEVERSION:i:-1}
k=`expr index "$TMP" .`
SAGE_MINORVERSION=${TMP:0:k-1}
else
SAGE_MINORVERSION=${SAGEVERSION:i:j-i-1}
fi
if [[ "$SAGE_MINORVERSION" =~ '.' ]]
then
j=`expr index "$SAGE_MINORVERSION" .`
SAGE_MINORVERSION=${SAGE_MINORVERSION:0:j-1}
fi
if [ $verbose -ge 1 ]
then
echo "SAGE_MINORVERSION is " $SAGE_MINORVERSION
fi
if [ $SAGE_MAJORVERSION -ge 5 ] && [ $SAGE_MINORVERSION -ge 7 ] || [ $SAGE_MAJORVERSION -ge 6 ]
then
echo "Sage version $SAGE_MAJORVERSION.$SAGE_MINORVERSION is ok!"
else
echo "Sage version $SAGE_MAJORVERSION.$SAGE_MINORVERSION is too old!"
t=`grep "$SAGE_ROOT"/devel/sage/sage/structure/sequence.py "13998"`
# Check if the patch has been applied...
t=`grep -c 13998 "$SAGE_ROOT"/devel/sage/sage/structure/sequence.py`
if [ $t -ge 1 ]
then
echo "This will (presumably) work since patch from 13998 is applied."
else
echo "Please update Sage (or apply patch from trac ticket 13998)"
if [ $SAGE_MINORVERSION -lt 6 ]
then
echo "This sage version is completely unsupported. Please do update!"
exit
fi
fi
fi
###
### Now check python packages and install / upgrade / downgrade
###
### TODO: add different tested versions of the dependencies (possibly different for different sage versions)
checked_versions="8 10 11"
deps="flask flask-login flask-cache flask-markdown psycopg2 pyyaml unittest2"
#deps="flask==0.10.1 flask-login==0.2.6 flask-cache==0.12 flask-markdown==0.3 psycopg2==2.7.5 pyyaml==3.10"
if ! [[ $checked_versions =~ $SAGE_MINORVERSION ]]
then
echo "This minor version is not tested. If something doesn't work please test to down/upgrade packages and add appropriate dependencies."
fi
if ([ $SAGE_MAJORVERSION -ge 5 ] && [[ $checked_versions =~ $SAGE_MINORVERSION ]] || [ $force_install = 1 ])
then
# We set the environment variables from sage (the same as when running sage -sh)
sage_env="$SAGE_ROOT/spkg/bin/sage-env"
if ! [[ -e $sage_env ]]
then
sage_env="$SAGE_ROOT/src/bin/sage-env"
fi
. ""$sage_env"" >&2
for dep in $deps
do
if [ $verbose = 1 ]
then
echo $dep
fi
if [ $dry_run = 1 ]
then
easy_install -n $easy_opts $dep
else
easy_install -U $easy_opts $dep
fi
done
fi
###
### While we are at it we can also check for and install some of the required sage packages
###
sage_packages="gap_packages database_gap"
for package in $sage_packages
do
if [ $dry_run = 1 ]
then
if [ $verbose -gt 0 ]
then
echo "Would have installed $package"
fi
else
if [ $verbose -gt 0 ]
then
echo "Installing $package"
fi
$sage_exec -i "$package"
fi
done