forked from StochSS/stochss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_mac_install.sh
executable file
·91 lines (82 loc) · 2.44 KB
/
run_mac_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
#!/usr/bin/env bash
WD=`pwd`
cd $1
echo "Starting installation of StochSS dependencies." >> run_mac_install.log
echo "old_wd=$WD script=$0 wd=$1" >> run_mac_install.log
MY_PATH="`pwd`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
STOCHSS_HOME=$MY_PATH
STOCHSS_HOME="`( cd \"$STOCHSS_HOME\" && pwd )`"
LIBXML="$(xcodebuild -version Path -sdk macosx)/usr/include/libxml2"
#################
function check_for_lib {
if [ -z "$1" ];then
return 1 #False
fi
if [ "$1" = "mysql-connector-python" ]; then
RET=`python -c "import mysql.connector" 2>/dev/null`
RC=$?
else
RET=`python -c "import $1" 2>/dev/null`
RC=$?
fi
if [[ $RC != 0 ]];then
return 1 #False
fi
return 0 #True
}
function install_lib {
if [ -z "$1" ];then
return 1 #False
fi
export ARCHFLAGS='-Wno-error=unused-command-line-argument-hard-error-in-future'
if [ "$1" = "libsbml" ]; then
CMD="sudo CFLAGS=\"-I$LIBXML\" pip install python-libsbml"
elif [ "$1" = "mysql-connector-python" ]; then
CMD="sudo pip install --allow-external $1 $1"
else
CMD="sudo pip install $1"
fi
echo $CMD >> run_mac_install.log
eval $CMD
}
function check_and_install_dependencies {
if ! check_pip;then
install_pip
fi
deps=("numpy" "scipy" "matplotlib" "h5py" "libsbml" "mysql-connector-python")
for dep in "${deps[@]}"
do
echo "Checking for $dep" >> run_mac_install.log
if check_for_lib "$dep";then
echo "$dep detected successfully." >> run_mac_install.log
else
install_lib "$dep"
if check_for_lib "$dep";then
echo "$dep installed successfully." >> run_mac_install.log
else
echo "$dep install failed." >> run_mac_install.log
return 1 #False
fi
fi
done
return 0 #True
}
function check_pip {
if which pip > /dev/null;then
echo "pip is installed on your system, using it." >> run_mac_install.log
return 0 #True
else
echo "pip is not installed on your system." >> run_mac_install.log
return 1 #False
fi
}
function install_pip {
CMD="curl -o get-pip.py https://bootstrap.pypa.io/get-pip.py"
echo $CMD >> run_mac_install.log
eval $CMD
CMD="sudo python get-pip.py"
echo $CMD >> run_mac_install.log
eval $CMD
}
check_and_install_dependencies