-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall_anaconda3
executable file
·95 lines (77 loc) · 2.55 KB
/
install_anaconda3
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
#! /usr/bin/env bash
#
# install anaconda3, plus a sourceable python_start.$SHELL script
# 18-mar-2024 NEMO/PJT original - see $NEMO/src/scripts/install_anaconda3
# 20-aug-2023 annotated for LMTOY
#--HELP
# default parameters
url=https://repo.anaconda.com/archive/Anaconda3-%s-%s-%s.sh
# anaconda3 versions available:
version=2020.07 # 3.8.3
version=2020.11 # 3.8.5
version=2021.04 # 3.8.8 BROKEN
version=2021.11 # 3.9.8 BROKEN
version=2022.05 # 3.9.12 OK
version=2022.10 # 3.9.13 OK
version=2023.03-0 # 3.10.9
version=2023.03-1 # 3.10.14 OK
#version=2023.07-2 # 3.11.4 BROKEN for m2r
#version=2023.09-0 # 3.11.5 BROKEN for m2r
#version=2024.02-1 # 3.11.7 BROKEN for m2r
#version=2024.06-1 # 3.12.4 BROKEN for m2r (installs very fast)
#version=2024.10-1 # 3.12.7
dir=$(pwd)/anaconda3 # where anaconda will be located
wget=wget # use wgetc is you have my cashing version (wget=curl is also allowed)
os=$(uname -s) # Handles Linux or Darwin, sorry no Windows
cpu=$(uname -m) # Handles Linux or Darwin, sorry no Windows
dry=0 # dry run?
# At the conclusion of the install, sourceable python_start.[c]sh scripts
# are placed in the root directory (dir=) of anaconda3
#--HELP
# some help?
if [ "$1" == "--help" ] || [ "$1" == "-h" ]; then
set +x
awk 'BEGIN{s=0} {if ($1=="#--HELP") s=1-s; else if(s) print $0; }' $0
exit 0
fi
# override parameters
for arg in "$@"; do
export "$arg"
done
if [ "$os" = "Darwin" ]; then
os=MacOSX
fi
mc3=$(printf $url $version $os $cpu)
msh=$(basename $mc3)
if [ $dry = 1 ]; then
echo $mc3
exit 0
fi
if [ ! -e $msh ]; then
if [ $wget = "curl" ]; then
# curl $mc3 -o $msh
curl -OL $mc3
else
$wget $mc3
fi
fi
if [ ! -e $msh ]; then
echo "File $msh not found. Wrong version=$version ?"
exit 0
fi
bash $msh -b -p $dir
export PATH="$dir/bin:$PATH"
conda update -y conda
pip3 install --upgrade pip
# ensure we have a bash kernel in jupyter notebooks
pip install bash_kernel
python -m bash_kernel.install
# write sourceable shell startup recipes
echo "set path = ($dir/bin "'$path); rehash' > $dir/python_start.csh
echo "export PATH=${dir}/bin:"'$PATH' > $dir/python_start.sh
pip freeze > $dir/freeze.log
echo "Created python_start files for $version in $dir ; no modifications were made to your HOME startup files!"
python --version
echo "typically you would need to "
echo " source $dir/python_start.sh"
echo "to add this python to your shell environment."