Skip to content

Commit 873bc79

Browse files
authored
Merge pull request #25 from JuliaParallel/initial
Add additional error check and improve output
2 parents 16f9333 + 0bc2394 commit 873bc79

File tree

1 file changed

+16
-26
lines changed

1 file changed

+16
-26
lines changed

juhpc

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ info() {
3131
echo -e "$JUHPC $message" >&2
3232
}
3333

34-
info_start() {
35-
local message="$1"
36-
info "$message..."
37-
}
38-
39-
info_end() {
40-
local message="$1"
41-
info "... done. $message completed."
42-
}
43-
4434
cleanup() {
4535
info "cleaning up temporary juliaup installation in $TMP_JULIAUP_ROOTDIR."
4636
rm -rf "$TMP_JULIAUP_ROOTDIR"
@@ -102,8 +92,7 @@ check_dir "$JUHPC_SETUP_INSTALLDIR"
10292

10393
# Download and install julia in /tmp using juliaup
10494

105-
INFO_MSG="Installing temporary juliaup installation in $TMP_JULIAUP_ROOTDIR"
106-
info_start "$INFO_MSG"
95+
info "Installing juliaup and julia temporarily in $TMP_JULIAUP_ROOTDIR..."
10796

10897
export TMP_JULIAUP_BINDIR="$TMP_JULIAUP_ROOTDIR/bin" # juliaup and julia binaries
10998
export JULIAUP_DEPOT_PATH="$TMP_JULIAUP_ROOTDIR/depot"
@@ -117,16 +106,16 @@ curl -fsSL https://install.julialang.org | sh -s -- --add-to-path=no --yes --pat
117106

118107
if [ ! -f "$TMP_JULIAUP_BINDIR/juliaup" ]; then error "temporary juliaup installation failed."; fi
119108

120-
info_end "$INFO_MSG"
109+
info "... done: temporary installation completed."
121110

122111

123112
# Create preferences for HPC key packages that require system libraries (MPI.jl, CUDA.jl, AMDGPU.jl, HDF5.jl, ADIOS2.jl, ...)
124113

125-
INFO_MSG="Creating preferences for HPC key packages"
126-
info_start "$INFO_MSG"
114+
info "Creating preferences for HPC key packages..."
127115

128116
export JULIA_PREFDIR="$JUHPC_SETUP_INSTALLDIR/julia_preferences"
129117
export JULIA_PREF_PROJECT="$JULIA_PREFDIR/Project.toml"
118+
export JULIA_PREFS="$JULIA_PREFDIR/LocalPreferences.toml"
130119
mkdir -p "$JULIA_PREFDIR" || { error "failed to create directory: $JULIA_PREFDIR"; }
131120

132121
if [[ -n "${JUHPC_CUDA_HOME}" || -n "${JUHPC_ROCM_HOME}" ]]; then
@@ -174,12 +163,14 @@ if [ -n "${JUHPC_HDF5_HOME}" ]; then
174163
julia --project="$JULIA_PREFDIR" -e 'using HDF5; HDF5.API.set_libraries!("$(ENV["JUHPC_HDF5_HOME"])/lib/libhdf5.so", "$(ENV["JUHPC_HDF5_HOME"])/lib/libhdf5_hl.so")'
175164
fi
176165

177-
info_end "$INFO_MSG"
166+
if [ ! -s "$JULIA_PREFS" ]; then error "preferences file is missing or empty."; fi
167+
168+
info "... done: preferences created."
178169

179170

180171
# Create a wrapper for juliaup that installs juliaup (and latest julia) on scratch if it is not already installed
181172

182-
info_start "Creating wrapper for juliaup"
173+
info "Creating wrapper for juliaup..."
183174

184175
export JULIAUP_WRAPPER_BINDIR="$JUHPC_SETUP_INSTALLDIR/juliaup_wrapper"
185176
export JULIAUP_WRAPPER="$JULIAUP_WRAPPER_BINDIR/juliaup"
@@ -207,14 +198,14 @@ JULIAUP_EXE="$(ENV["JULIAUP_BINDIR"])/juliaup"
207198
208199
if [ ! -f "\$JULIAUP_EXE" ]; then
209200
print_logo
210-
info "This is the first call to juliaup; juliaup and the latest julia will now be installed. After that, you can use juliaup and julia normally. Installing in $(ENV["JULIAUP_INSTALLDIR"])..."
211-
sleep 3
201+
info "This is the first call to juliaup: installing juliaup and the latest julia..."
202+
sleep 2
212203
PATH_OLD="\$PATH"
213204
export PATH=\$(echo \$PATH | perl -pe "s|[^:]*juliaup(?:_wrapper)?[^:]*:?||g") # Remove all juliaup paths from PATH
214205
curl -fsSL https://install.julialang.org | sh -s -- --add-to-path=no --yes --path="$(ENV["JULIAUP_INSTALLDIR"])" --background-selfupdate 0 --startup-selfupdate 0 || { echo "Failed to install Juliaup (and Julia)." >&2; exit 1; }
215206
export PATH="\$PATH_OLD"
216207
if [ ! -f "\$JULIAUP_EXE" ]; then error "juliaup installation failed."; fi
217-
info "... done. Installation of juliaup and the latest julia in $(ENV["JULIAUP_INSTALLDIR"]) completed. You can use juliaup and julia normally."
208+
info "... done: installation completed (location: $(ENV["JULIAUP_INSTALLDIR"])). You can now use juliaup and julia normally."
218209
else
219210
"\$JULIAUP_EXE" \$@
220211
fi
@@ -229,7 +220,7 @@ info "... done."
229220

230221
# Create an activation script that sets environment variables for juliaup, julia and HPC key packages
231222

232-
info_start "Creating activate script"
223+
info "Creating activate script..."
233224

234225
export JULIAUP_DEPOT="$JULIAUP_INSTALLDIR/depot"
235226
export JULIA_DEPOT="$JULIAUP_INSTALLDIR/depot"
@@ -273,16 +264,15 @@ info "... done."
273264
# Optionally execute a site-specific post installation julia script (if passed a third argument)
274265

275266
if [ -n "${JUHPC_POST_INSTALL_JL}" ]; then
276-
INFO_MSG="Executing site-specific post installation julia script (using the project where preferences were set)"
277-
info_start "$INFO_MSG"
267+
info "Executing site-specific post-installation julia script (using the project where preferences were set)..."
278268
julia --project="$JULIA_PREFDIR" "$JUHPC_POST_INSTALL_JL"
279-
info_end "$INFO_MSG"
269+
info "... done: post-installation script completed."
280270
fi
281271

282272

283273
# Remove temporary juliaup installation and Manifest.toml in the preferences directory
284274

285275
cleanup
286-
rm -f "$JULIA_PREFDIR/Manifest.toml"
276+
mv "$JULIA_PREFDIR/Manifest.toml" "$JULIA_PREFDIR/Manifest.toml.bak" || { error "failed to move Manifest.toml in $JULIA_PREFDIR"; }
287277

288-
info "... Installation of HPC setup for juliaup, julia and HPC key packages requiring system libraries is complete.\n\n"
278+
info "... The installation of the HPC setup for juliaup, julia and HPC key packages is complete.\n\n"

0 commit comments

Comments
 (0)