-
Notifications
You must be signed in to change notification settings - Fork 10
/
installer
192 lines (167 loc) · 5.71 KB
/
installer
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
#!/usr/bin/env bash
#
# This is the guided installer for the SolveBio Python Client:
#
# curl -skL install.solvebio.com/python | bash
#
echo
echo " ____ _ ____ _"
echo " / ___| ___ | |_ _____| __ )(_) ___"
echo " \___ \ / _ \| \ \ / / _ \ _ \| |/ _ \\"
echo " ___) | (_) | |\ V / __/ |_) | | (_) |"
echo " |____/ \___/|_| \_/ \___|____/|_|\___/"
echo
echo " Copyright © Solve, Inc. <https://www.solvebio.com>. All rights reserved."
echo
shopt -s extglob
function fail_exit() {
echo
echo " ##################################################"
echo
echo " Sorry, SolveBio for Python could not be installed."
echo
echo " You can try manually installing the module with:"
echo " pip install solvebio"
echo
echo " Contact us at [email protected] for help."
echo " In your email, please copy/paste the output of:"
echo " cat ${LOG}"
echo
echo " ##################################################"
echo
exit
}
trap ctrl_c INT
function ctrl_c() {
echo
echo
echo " Installation was aborted..."
fail_exit
}
echo " Installing the SolveBio Python Client..."
# Setup the log
LOG=/tmp/solvebio-python.log
echo "SolveBio Python Guided Installer log" > $LOG
echo `date` >> $LOG
# Check Python versions
echo " Looking for a supported Python installation..."
PATHS=`echo $PATH | sed -e 's/:/ /g'`
# For each path in $PATH, look for python
for path in $PATHS; do
PYTHONS=`find $path -regex ".*/python*" -o -regex ".*/python2.[567]" 2>> $LOG | sort`
for PYTHON in $PYTHONS; do
if [[ ! -x $PYTHON ]] ; then
continue
fi
PYTHON_VERSION=`$PYTHON -V 2>&1 | cut -d " " -f 2`
if [[ $PYTHON_VERSION =~ 2.[67].[0-9] ]]; then
PYTHON_FOUND='1'
break
fi
done
if [ "$PYTHON_FOUND" == '1' ]; then
break
fi
done
if [ "$PYTHON_FOUND" == '1' ]; then
echo " Found Python ${PYTHON_VERSION} at ${PYTHON}!"
# TODO: allow optional Python path
# echo -n "Which Python do you want to use (press enter for: ${PYTHON}) ? "
# read PYTHON_ALT
# if [[ -x $PYTHON_ALT ]]; then
# PYTHON=$PYTHON_ALT
# fi
echo " Using ${PYTHON}..."
else
echo "Error: SolveBio for Python requires Python >= 2.6.5 and < 3.0"
fail_exit
fi
# Check OpenSSL version
OPENSSL_VERSION=`$PYTHON -c "import ssl; print ssl.OPENSSL_VERSION" 2>> $LOG`
if [ "$OPENSSL_VERSION" == "" ]; then
echo
echo
echo "Error: SolveBio for Python requires a more recent version of Python-OpenSSL."
fail_exit
fi
OPENSSL_VERSION_MAJOR=`$PYTHON -c "import ssl; print ssl.OPENSSL_VERSION_INFO[0]"`
OPENSSL_VERSION_MINOR=`$PYTHON -c "import ssl; print ssl.OPENSSL_VERSION_INFO[1]"`
OPENSSL_VERSION_PATCH=`$PYTHON -c "import ssl; print ssl.OPENSSL_VERSION_INFO[2]"`
if [ "$OPENSSL_VERSION_MAJOR" -lt "1" ]; then
if [ "$OPENSSL_VERSION_MINOR" -lt "9" ] || [ "$OPENSSL_VERSION_PATCH" -lt "8" ]; then
echo
echo "Error: SolveBio for Python requires OpenSSL >= 0.9.8"
echo " Your Python SSL module is linked to $OPENSSL_VERSION"
fail_exit
fi
fi
# Detect if in Virtualenv (use sudo if not)
VIRTUALENV=`$PYTHON -c "import sys; print sys.real_prefix" 2>> $LOG`
if [ "$VIRTUALENV" == "" ]; then
PYTHON_SUDO="sudo ${PYTHON}"
echo " IMPORTANT: Your computer's password may be required. It will NOT be sent to SolveBio."
else
PYTHON_SUDO=$PYTHON
fi
# Check for working pip
PIP_VERSION=`$PYTHON -m pip --version 2>&1`
if [[ ! "$PIP_VERSION" =~ (^pip .*) ]]; then
echo " It looks like pip is not installed. We will now attempt to install it."
$PYTHON_SUDO -m easy_install -q pip 2>&1 >> $LOG
PIP_VERSION=`$PYTHON -m pip --version 2>&1`
if [[ ! "$PIP_VERSION" =~ (^pip .*) ]]; then
echo
echo "Error: There seems to be a problem installing pip..."
echo " To install pip manually, run the following command:"
echo " curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | ${PYTHON}"
echo
fail_exit
else
echo " pip was successfully installed!"
fi
fi
PIP_FLAGS=""
# disable the use of wheels if pip supports them
if [ $($PYTHON -m pip install --help | grep "\-\-no\-use\-wheel" -c) -ne 0 ]; then
# force-reinstall in case the user has the .whl installed already
PIP_FLAGS="--force-reinstall --no-use-wheel"
fi
# Detect/install gnureadline only on Mac OS X
UNAME=`uname`
if [[ "$UNAME" == 'Darwin' ]]; then
READLINE=`$PYTHON -c "import gnureadline; print gnureadline.__name__" 2>> $LOG`
if [ "$READLINE" != "gnureadline" ]; then
echo " Installing gnureadline..."
$PYTHON_SUDO -m pip install gnureadline $PIP_FLAGS 2>&1 >> $LOG
if [ $? -ne 0 ]; then
echo
echo "Warning: gnureadline could not be installed."
echo
fi
fi
fi
IPYTHON=`$PYTHON -c "import IPython; print IPython.__name__" 2>> $LOG`
if [ "$IPYTHON" != "IPython" ]; then
echo " Installing IPython..."
$PYTHON_SUDO -m pip install ipython $PIP_FLAGS 2>&1 >> $LOG
if [ $? -ne 0 ]; then
fail_exit
fi
fi
echo " Installing SolveBio for Python..."
$PYTHON_SUDO -m pip install solvebio $PIP_FLAGS --upgrade 2>&1 >> $LOG
INSTALL_COUNT=`$PYTHON -m pip freeze | grep "^solvebio=" -c`
if [ "$INSTALL_COUNT" -ge "0" ]; then
VERSION=`$PYTHON -c "import solvebio; print solvebio.version.VERSION"`
echo
echo " ##############################################"
echo
echo " Success! SolveBio for Python v${VERSION} is now installed."
echo
echo " Please run 'solvebio login' to finish the setup."
echo
echo " ##############################################"
echo
else
fail_exit
fi