-
Notifications
You must be signed in to change notification settings - Fork 1
/
prepare_conda.sh
executable file
·211 lines (162 loc) · 5.22 KB
/
prepare_conda.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
#!/bin/bash
cd `dirname $0`
. ./common.sh
usage="
Prepares conda with current Python and jupyter and no other packages, all for the current user.
Usage:
$(basename $0) [--conda-dir <conda dir>] [--pip-cacher <ip[:port]]
[--help] [--debug] [--log <output file>]
where
--repo-path - Alternative directory where to look for (and save)
downloaded files. Defaults to /media/adam-minipc/other/debs
if exists or /tmp/repo-path if it does not.
--conda-dir - Directory where to install conda. Defaults to /opt/conda
--pip-cacher - Host name and port to the pip cacher. If specified it will
install appropriate ~/.pip/pip.conf so all pip operations will
be cached
--debug - Flag that sets debugging mode.
--log - Path to the log file that will log all meaningful commands
Example2:
$(basename $0)
"
#if [ -z "$1" ]; then
# echo "$usage" >&2
# exit 0
#fi
set -x
conda_dir="/opt/conda"
pip_cacher=""
user="$USER"
if [ -d /media/adam-minipc/other/debs/ ]; then
repo_path=/media/adam-minipc/other/debs
else
repo_path=/tmp/repo_path
fi
while [[ $# > 0 ]]
do
key="$1"
shift
case $key in
--debug)
debug=1
;;
--log)
log=$1
shift
;;
--conda-dir)
conda_dir=$1
shift
;;
--repo-path)
repo_path=$1
shift
;;
--pip-cacher)
pip_cacher=$1
shift
;;
--help)
echo "$usage"
exit 0
;;
-*)
echo "Error: Unknown option: $1" >&2
echo "$usage" >&2
exit 1
;;
esac
done
if [ -n "$debug" ]; then
if [ -z "$log" ]; then
log=/dev/stdout
fi
fi
conda_path=${conda_dir}/bin/conda
need_to_install=1
if [ -f "${conda_path}" ]; then
if $(${conda_path} --version >/dev/null); then
need_to_install=0
fi
fi
if [[ ${need_to_install} == 1 ]]; then
installer_path=$(get_cached_file Miniconda3-latest-Linux-x86_64.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh)
if [ -z "${installer_path}" ]; then
errcho "Cannot download the installer"
exit 0
fi
logmkdir /opt $USER
logexec bash ${installer_path} -b -p "${conda_dir}"
logmkdir /opt root
logmkdir /opt/conda $USER
export PATH="${conda_dir}/bin:$PATH"
logexec /opt/conda/bin/conda init
fi
if ! $(conda --version >/dev/null); then
export PATH="${conda_dir}/bin:$PATH"
fi
if ! $(conda --version >/dev/null); then
errcho "Still cannot run conda"
exit 0
fi
source ${conda_dir}/bin/activate
logexec conda install --yes python
if [ -n "${pip_cacher}" ]; then
logmkdir $HOME/.pip
parse_URI "${pip_cacher}"
textfile ~/.pip/pip.conf "[global]
index-url = http://${pip_cacher}/root/pypi/+simple/
trusted-host=${ip}
[search]
index = http://${pip_cacher}/root/pypi/
"
fi
# logexec pip install ipython jupyter jupyter_contrib_nbextensions jupyterthemes
# logexec jt -t onedork
# logexec jupyter contrib nbextension install --user
node_key=$(get_cached_file nodesource.gpg.key https://deb.nodesource.com/gpgkey/nodesource.gpg.key)
add_apt_source_manual nodesource "deb https://deb.nodesource.com/node_11.x $(get_ubuntu_codename) main
deb-src https://deb.nodesource.com/node_11.x $(get_ubuntu_codename) main" https://deb.nodesource.com/gpgkey/nodesource.gpg.key nodesource.gpg.key
refresh_apt_redirections
install_apt_packages nodejs
logexec pip install jupyterlab
npm_packages="$(get_home_dir ${USER})/.npm-packages"
logmkdir "$npm_packages" ${USER}
logexec npm config set prefix "$npm_packages"
textfile "$(get_home_dir ${USER}/.node_bashrc" "export NPM_PACKAGES='${$npm_packages}'
export NODE_PATH=\"\$NPM_PACKAGES/lib/node_modules\${NODE_PATH:+:\$NODE_PATH}\"
export PATH=\"\$NPM_PACKAGES/bin:\$PATH\"
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
export MANPATH=\"\$NPM_PACKAGES/share/man:\$(manpath)\"" ${USER}
linetextfile "$(get_home_dir ${USER}/.bashrc" "source $(get_home_dir ${USER}/.node_bashrc"
logexec npm install -g yarn
line=$(npm install -g yarn | grep -e "yarn -> .*/yarn\.js\$")
pattern='yarn -> (.*/yarn\.js)$'
if [[ "$line" =~ $pattern ]]; then
yarn_dir="${BASH_REMATCH[1]}"
else
errcho "Cannot set new yarn. Possible problems with jupyterlab extensions expected."
fi
#pip install jupyterlab-discovery ?
#jupyter labextension install jupyterlab-drawio
#jupyter labextension install @krassowski/jupyterlab-lsp
#jupyter labextension install jupyterlab-drawio @jupyterlab/theme-dark-extension @ryantam626/jupyterlab_code_formatter @jupyter-widgets/jupyterlab-manager
#jupyter labextension install @jupyterlab/theme-dark-extension
#jupyter labextension install @krassowski/jupyterlab-lsp
#jupyter labextension install @ryantam626/jupyterlab_code_formatter
#pip install jupyterlab_code_formatter
#pip install jupyter-conda
#jupyter serverextension enable --py jupyterlab_code_formatter
#jupyter labextension install jupyterlab_toastify jupyterlab_conda
#jupyter labextension list
#To add a specific kernel to jupyterlab:
#
#ipython kernel install --user --name=<any_name_for_kernel>
#To update jupyter extensions:
#
#jupyter labextension update --all
# To install latex support:
#
#pip install jupyterlab_latex
#jupyter labextension install @jupyterlab/latex
# <install latex>