-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_miniconda.sh
executable file
·188 lines (143 loc) · 4.83 KB
/
setup_miniconda.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
#!/usr/bin/env bash
# All initial credits to:
# - https://github.com/mitchellkrogza
# - https://mypdns.org/funilrys
#
# Modified by https://mypdns.org/spirillen
# License: https://mypdns.org/mypdns/support/-/wikis/License
# Issues: https://mypdns.org/pyfunceble/pyfunceble-templates/pyfunceble-miniconda/-/issues
# Project: https://mypdns.org/pyfunceble/pyfunceble-templates/pyfunceble-miniconda
# -------------------------------
# Setup Conda Python Environments
# -------------------------------
# Stop on any error
set -e
# Set python version
# to find the latest version
# `conda search --full-name python`
# pythonVersion="3.10"
# Set conda install dir
condaInstallDir="${HOME}/miniconda"
function version () {
echo ""
echo "Python version"
python -VVV
echo ""
echo "pip version"
pip --version
echo ""
echo "PyFunceble version"
pyfunceble --version
# echo ""
# echo "uhb-whitelist version"
# uhb-whitelist --version
}
function copy_config () {
# Copy default .pyfunceble-env and .PyFunceble.overwrite.yaml to new
# environment
cp "$HOME/.config/PyFunceble/.pyfunceble-env" \
"${condaInstallDir}/envs/${PYFUNCEBLEPACKAGENAME}"
cp "$HOME/.config/PyFunceble/.PyFunceble.overwrite.yaml" \
"${condaInstallDir}/envs/${PYFUNCEBLEPACKAGENAME}"
echo ""
echo "List copied files"
ls -lha "${condaInstallDir}/envs/${PYFUNCEBLEPACKAGENAME}"
}
if [[ ! -d ${condaInstallDir} ]]
then
if [ $(uname -m) == 'x86_64' ]
then
# Download Conda
wget -O miniconda.sh \
'https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh'
elif [ $(uname -m) == 'x86' ]
then
wget -O miniconda.sh \
'https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86.sh'
elif [ $(uname -m) == 'ppc64le' ]
then
wget -O miniconda.sh \
'https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-ppc64le.sh'
fi
# Install Conda
bash miniconda.sh -b -f -p "${condaInstallDir}"
source "$HOME/miniconda/etc/profile.d/conda.sh"
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda info -a
else
echo "We assume that conda is already installed."
echo "We are updating the environment"
source "$HOME/miniconda/etc/profile.d/conda.sh"
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda info -a
echo ${?}
echo "Updated completed"
fi
if [[ ! -d ${condaInstallDir}/envs/pyfunceble ]]
then
# Setup pyfunceble@ version to be used
export PYFUNCEBLEPACKAGENAME="pyfunceble"
# Get the conda CLI.
source "${condaInstallDir}/etc/profile.d/conda.sh"
hash conda
# Update Conda
conda update -yq conda
conda update -n base conda
# Create an Environment (EXAMPLE: creating an environment called
# pyfuncebletesting with Python version "pythonVersion")
# conda create -y -q -n "${PYFUNCEBLEPACKAGENAME}" python="${pythonVersion}"
conda env update -f ".environment.${PYFUNCEBLEPACKAGENAME}.yaml" --prune -q
# Activate this environment you just created
# According to the https://docs.conda.io/projects/conda/en/latest/_downloads/843d9e0198f2a193a3484886fa28163c/conda-cheatsheet.pdf
# We shall replace source with conda activate vs source
conda activate "${PYFUNCEBLEPACKAGENAME}"
# Calling function: version
version
# uhb-whitelist --version
# prepared for installing through conda package
#conda install -c pyfunceble "${PYFUNCEBLEPACKAGENAME}"
# Copy default .pyfunceble-env to new environment
# Calling function: copy_config
copy_config
# When finished - Deactivate the environment
conda deactivate
else
echo "We assume that Pyfunceble envs is already installed."
fi
if [[ ! -d ${condaInstallDir}/envs/pyfunceble-dev ]]
then
# Setup pyfunceble@ version to be used
export PYFUNCEBLEPACKAGENAME="pyfunceble-dev"
# Get the conda CLI.
source "${condaInstallDir}/etc/profile.d/conda.sh"
hash conda
# Update Conda
conda update -yq conda
# Create an Environment (EXAMPLE: creating an environment called
# conda create -y -q -n "${PYFUNCEBLEPACKAGENAME}" python="${pythonVersion}"
conda env update -f ".environment.${PYFUNCEBLEPACKAGENAME}.yaml" --prune -q
# Activate this environment you just created
# According to the https://docs.conda.io/projects/conda/en/latest/_downloads/843d9e0198f2a193a3484886fa28163c/conda-cheatsheet.pdf
# We shall replace source with conda activate vs source
conda activate "${PYFUNCEBLEPACKAGENAME}"
# Calling function: version
version
# Calling function: copy_config
copy_config
# When finished - Deactivate the environment
conda deactivate
else
echo "We assume that Pyfunceble-dev envs is already installed."
fi
echo "Script exited with code: ${?}"
# Now you should be ready to run the pyfunceble.sh
# For testing only
# conda env list
# conda env remove -n pyfunceble
# conda env remove -n pyfunceble-dev
# Cleanup
rm miniconda.sh