-
Notifications
You must be signed in to change notification settings - Fork 0
/
GPI_Install_Latest.sh
executable file
·234 lines (215 loc) · 7.19 KB
/
GPI_Install_Latest.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
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/bin/bash
# Build the GPI-MiniConda Stack for python 3 (or 2).
# default options
PYTHON_VER=3.7
QT_VER=5.9
MINICONDA_NAME=Miniconda3
help ()
{
echo " "
echo " -------------------------------------------------------- "
echo " "
echo " Welcome to the GPI-MiniConda stack installer. This script will "
echo " install MiniConda (continuum.io) and the GPI (gpilab.com) "
echo " application packages to a given directory. "
echo " "
echo " - - - - - - - - - "
echo " "
echo "usage: $0 [options] [path]"
echo " -p specify python version (3.6 or 3.7 - default is 3.7)"
echo " -q specify qt version (5.6 or 5.9 - default is 5.9)"
echo " -c <channel> specify a different anaconda channel"
echo " (for, e.g., testing custom builds)"
echo " -h display this help"
echo " "
echo " Example: $0 ~/gpi_stack"
echo " "
echo "Alternatively, if you already have the conda package manager from a"
echo "previous Anaconda or Miniconda installation, you can install GPI"
echo "into a Python 3.6+ environment with the following commands:"
echo " "
echo " ~$ conda create -n gpi python=3.x"
echo " ~$ conda activate gpi"
echo " ~$ conda install -c conda-forge --strict-channel-priority gpi gpi_core"
echo " "
echo "Note that the --strict-channel-priority flag is not always required,"
echo "but is now recommended in the conda-forge ecosystem (and will be the"
echo "default if this script installs miniconda for you). You can add "
echo "conda-forge and set strict priority for an existing install with: "
echo " "
echo " -$ conda config --add channels conda-forge:"
echo " -$ conda config --set channel_priority strict"
echo " "
echo "For more details see:"
echo " https://conda-forge.org/docs/user/tipsandtricks.html"
exit 1
}
# user options
while getopts ":p:q:c:h:" opt; do
case $opt in
p)
PYTHON_VER=$OPTARG
if [ $PYTHON_VER != "3.6" ] && [ $PYTHON_VER != "3.7" ]
then
echo $PYTHON_VER
echo "Invalid python version passed. You specified $PYTHON_VER."
echo " Valid choices are 3.6 and 3.7."
exit 1
fi
;;
q)
QT_VER=$OPTARG
if [ $QT_VER != "5.6" ] && [ $QT_VER != "5.9" ]
then
echo "Invalid Qt version passed. You specified $QT_VER."
echo " Valid choices are 5.6 and 5.9."
exit 1
fi
;;
c)
CHANNEL=$OPTARG
echo "Using channel $CHANNEL ." >&2
;;
h)
help >&2
;;
esac
done
# Prompt for an extra dependency if running Ubuntu within WSL
if grep -q Microsoft /proc/version; then
NEEDED_PKGS="python3-pyqt5.qtwebkit build-essential ca-certificates libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6"
for pkg in $NEEDED_PKGS
do
dpkg -s $pkg > /dev/null 2>&1
if [ $? -ne 0 ]
then
echo "GPI requires extra packages to run on WSL + Ubuntu"
echo "A required package ($pkg) was not found, and others may be missing."
echo "Please run the following command, then re-run this script:"
echo "sudo apt-get install $NEEDED_PKGS"
exit 1
fi
done
fi
# Miniconda version is always 3 now.
MINICONDA_NAME=Miniconda3
# check for available commands
if command -v wget >/dev/null 2>&1; then
GET="wget -c "
elif command -v curl >/dev/null 2>&1; then
GET="curl -O -C - "
else
echo "This script requires either wget or curl."
echo "Please install one of these with yum, apt-get, etc., then re-run this script."
exit 1
fi
# check for root
if [ "$(id -u)" == "0" ]; then
echo -n "
It looks like you are attempting to install GPI as root or sudo. While
this is possible, it is recommended that you install GPI under your
home directory.
Press ENTER to continue or CTRL-c to quit.
"
read dummy
fi
# get user path
shift $(($OPTIND - 1))
MINICONDA_PATH=$1 # conda install location
CONDA=$MINICONDA_PATH/bin/conda
if [ -z "$MINICONDA_PATH" ]; then
help
fi
PATHTOTHEPATH=`dirname $MINICONDA_PATH`
if [ ! -d "$PATHTOTHEPATH" ]; then
echo "The parent path '$PATHTOTHEPATH' doesn't exit."
exit 1
fi
if [[ ! "$MINICONDA_PATH" = /* ]]; then
echo "Please provide a full path ('~' is allowed)."
exit 1
fi
# See if the directory is already in use
if [ -d "$MINICONDA_PATH" ]; then
echo "The supplied directory already exists, installation aborted."
exit 1
fi
echo "Installing the GPI stack for python $PYTHON_VER in $MINICONDA_PATH ..."
# Install MiniConda -detect OS
echo "Downloading and Installing MiniConda..."
MINICONDA_WEB=https://repo.continuum.io/miniconda
MINICONDA_OSX=$MINICONDA_NAME-latest-MacOSX-x86_64.sh
MINICONDA_LINUX=$MINICONDA_NAME-latest-Linux-x86_64.sh
# OSX
if [ "$(uname)" == "Darwin" ]; then
MINICONDA_SCRIPT=$MINICONDA_OSX
fi
# Linux
if [ "$(uname)" == "Linux" ]; then
MINICONDA_SCRIPT=$MINICONDA_LINUX
fi
install ()
{
# make a tmp working dir
TMPDIR=`mktemp -d`
cd $TMPDIR
# Run install script
$GET $MINICONDA_WEB/$MINICONDA_SCRIPT
chmod a+x $MINICONDA_SCRIPT
./$MINICONDA_SCRIPT -b -p $MINICONDA_PATH
. $MINICONDA_PATH/etc/profile.d/conda.sh
# add conda-forge channel
# priority: conda-forge > defaults
conda config --add channels conda-forge
# Set channel priority to strict per conda-forge recommendation
conda config --set channel_priority strict
# Create the new env with gpi, allowing python and pyqt to be set explicitly
$CONDA create -n gpi -y python=$PYTHON_VER pyqt=$QT_VER gpi_core
$CONDA activate gpi
echo "Removing package files..."
$CONDA clean -t -i -p -l -y
# Clean up the downloaded files
echo "Removing tmp files..."
cd ~
rm -rf $TMPDIR
}
# Run the installer
install
if [ -e $MINICONDA_PATH/envs/gpi/bin/gpi ]
then
echo " ------------------------------------"
echo "| GPI installation was successful! |"
echo " ------------------------------------"
echo " "
echo "To start GPI enter:"
echo " "
echo " \$ conda activate gpi"
echo " \$ gpi"
echo " "
echo "Run 'conda init' to enable 'conda activate' in your shell."
read -p "Would you like to do this now? [Y/n]" -n 1 -r CONDA_INIT
echo
CONDA_INIT=${CONDA_INIT:-Y}
if [[ $CONDA_INIT =~ ^[Yy]$ ]]
then
# echo ". $MINICONDA_PATH/etc/profile.d/conda.sh" >> ~/.bashrc
$MINICONDA_PATH/condabin/conda init
echo "Launch a new terminal for this to take effect."
fi
echo " "
else
echo " ----------------------------"
echo "| GPI installation FAILED! |"
echo " ----------------------------"
echo "removing $MINICONDA_PATH"
rm -rf $MINICONDA_PATH
echo " "
echo "Please try running the script again."
echo " "
echo "Scroll up to see if you can spot the error."
echo "If you still have issues, copy the output of the"
echo "installation command and report issues on the"
echo "GitHub issue tracker:"
echo "https://github.com/gpilab/conda-distro/issues"
fi
exit