forked from solvebio/solvebio-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller
executable file
·161 lines (140 loc) · 4.65 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
#!/usr/bin/env bash
#
# This is the guided installer for the SolveBio Python Client:
#
# curl -kL install.solvebio.com | bash
#
echo
echo " ____ _ ____ _"
echo "/ ___| ___ | |_ _____| __ )(_) ___"
echo "\___ \ / _ \| \ \ / / _ \ _ \| |/ _ \\"
echo " ___) | (_) | |\ V / __/ |_) | | (_) |"
echo "|____/ \___/|_| \_/ \___|____/|_|\___/"
echo
echo "Copyright © 2014 Solve, Inc. <http://www.solvebio.com>. All rights reserved."
echo
shopt -s extglob
function fail_exit() {
echo
echo "#####################################"
echo
echo "Failed to install SolveBio."
echo "If you need some help, email us at [email protected]"
echo "or chat with our engineers at http://chat.solvebio.com/"
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..."
echo
# Check Python versions
PYTHON_PATHS=`echo $PATH | sed -e 's/:/ /g'`
PYTHON_VERSIONS=`find $PYTHON_PATHS -regex ".*/python*" -o -regex ".*/python2.[567]" 2> /dev/null | sort`
echo "Looking for a supported Python installation..."
# try in order of $PATH
for PYTHON in $PYTHON_VERSIONS ; 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
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 "The SolveBio Python Client requires Python >= 2.6.5 and < 3.0"
# TODO: instructions for installing Python
fail_exit
fi
# Check OpenSSL version
OPENSSL_VERSION=`$PYTHON -c "import ssl; print ssl.OPENSSL_VERSION" 2> /dev/null`
if [ "$OPENSSL_VERSION" == "" ]; then
echo
echo
echo "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 "SolveBio for Python requires OpenSSL >= 0.9.8"
echo "Your Python SSL module is linked to $OPENSSL_VERSION"
fail_exit
fi
fi
# Install readline with easy_install
echo "Installing readline through easy_install (enhances IPython)..."
echo "(Your user or system password may be required)"
sudo $PYTHON -m easy_install readline
# 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."
echo "(Your user or system password may be required)"
sudo $PYTHON -m easy_install pip
# TODO: use this instead: curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python
PIP_VERSION=`$PYTHON -m pip --version 2>&1`
if [[ ! "$PIP_VERSION" =~ (^pip .*) ]]; then
echo
echo "There seems to be a problem installing pip..."
fail_exit
else
echo "pip install successful!"
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
PIP_FLAGS="--no-use-wheel"
fi
# Are we installing or upgrading?
if [ $(pip freeze | grep solvebio -c) -ne 0 ]; then
echo "SolveBio for Python is already installed, we will try to upgrade it..."
PIP_FLAGS="${PIP_FLAGS} --upgrade"
ACTION="Upgrading"
else
ACTION="Installing"
fi
echo
echo "${ACTION} the SolveBio module via pip..."
echo "(Your user or system password may be required)"
sudo $PYTHON -m pip install solvebio $PIP_FLAGS && SUCCESS="1"
if [ $? -eq 0 ]; then
echo
echo "#####################################"
echo
echo "Success! SolveBio for Python is now installed."
echo
echo "Run 'solvebio login' to start."
echo
echo "Check out the Get Started guide:"
echo "https://www.solvebio.com/documentation/get-started"
echo "If you need some help, email [email protected]"
echo "or chat with our engineers at http://chat.solvebio.com/"
echo
echo "#####################################"
echo
else
fail_exit
fi