forked from limix/limix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
126 lines (101 loc) · 2.53 KB
/
install
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
#!/bin/bash
function yes_or_no {
while true; do
read -p "$* [y/n]: " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*) echo "Aborted" ; return 1 ;;
esac
done
}
echo "[0/4] Installing development limix 2.0.0 version"
if [ command -v python >/dev/null 2>&1 ]
then
echo >&2 "python command has not been found. Aborting."
exit 1
fi
if [ command -v pip >/dev/null 2>&1 ]
then
echo >&2 "pip command has not been found. Aborting."
exit 1
fi
USE_CONDA="no"
if ! [ command -v conda >/dev/null 2>&1 ]
then
echo "Looks like you have conda package manager."
msg="Shall we use it to install the C libraries? (Recommended.)"
yes_or_no $msg && USE_CONDA="yes" || USE_CONDA="no"
fi
tmpdir=`mktemp -d 2>/dev/null || mktemp -d -t 'tmpdir'`
logfile="$tmpdir/limix.log"
exec 3>"$logfile"
function cleanup
{
rm -rf "$tmpdir" >/dev/null 2>&1 || true
}
trap cleanup EXIT
if [[ $USE_CONDA == "no" ]]
then
if [ command -v cmake >/dev/null 2>&1 ]
then
echo >&2 "cmake command has not been found. Aborting."
exit 1
fi
fi
function silent_run
{
eval "$@ >&3 2>&1"
}
function silent_trun
{
eval "$@ >&3 2>&1 || true"
}
function do_then_sudo
{
eval "$@"
if [ $? != 0 ]; then
eval "sudo $@"
fi
}
function failed
{
echo "FAILED."
echo "[_/_] LOG OUTPUT:"
cat $logfile
exit 1
}
GIT_URL=https://github.com/limix/limix.git
GIT_FOLDER="$tmpdir/limix"
silent_run pip uninstall limix --yes
silent_run pip uninstall limix --yes
silent_run pip uninstall limix --yes
echo -n "[1/4] Cloning repository... "
silent_run git clone -b 2.0.0 $GIT_URL $GIT_FOLDER
cd $GIT_FOLDER
[ $? == 0 ] && echo "done." || failed
function install_deps
{
if [[ $USE_CONDA == "yes" ]]
then
conda install --yes -c conda-forge bgen liknorm
else
bash <(curl -fsSL https://raw.githubusercontent.com/limix/liknorm/master/install)
bash <(curl -fsSL https://raw.githubusercontent.com/limix/bgen/master/install)
fi
}
echo -n "[2/4] Installing C dependencies... "
silent_run install_deps
[ $? == 0 ] && echo "done." || failed
echo -n "[3/4] Installing Python dependencies... "
if [[ $USE_CONDA == "yes" ]]
then
silent_run conda install --yes numpy scipy matplotlib netcdf4 h5py xarray
else
silent_run pip install numpy
fi
silent_run pip install -r requirements.txt
[ $? == 0 ] && echo "done." || failed
echo -n "[4/4] Installing limix itself... "
silent_run pip install .
[ $? == 0 ] && echo "done." || failed
rm "$logfile" || true