Skip to content

Commit 33016b6

Browse files
authored
Merge pull request #37 from JuliaParallel/wrapper
add opt-in Julia wrapper and IJulia installer
2 parents e89f067 + 117f7bc commit 33016b6

File tree

1 file changed

+86
-1
lines changed

1 file changed

+86
-1
lines changed

juhpc

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ if [ ! -f "\$JULIAUP_EXE" ]; then
285285
if [ ! -f "\$JULIAUP_EXE" ]; then error "juliaup installation failed."; fi
286286
info "... done: installation completed (location: $(ENV["JULIAUP_INSTALLDIR"])). You can now use juliaup and julia normally."
287287
else
288-
"\$JULIAUP_EXE" \$@
288+
exec "\$JULIAUP_EXE" "\$@"
289289
fi
290290
""")
291291
' > "$JULIAUP_WRAPPER"
@@ -296,6 +296,91 @@ chmod +x "$JULIAUP_WRAPPER"
296296
info "... done: wrapper created."
297297

298298

299+
# Create an opt-in wrapper for julia that calls the juliaup wrapper to install juliaup and latest julia on scratch if it is not already installed
300+
301+
info "Creating opt-in wrapper for julia..."
302+
303+
export JULIA_WRAPPER_BINDIR="$JUHPC_SETUP_INSTALLDIR/julia_wrapper"
304+
export JULIA_WRAPPER="$JULIA_WRAPPER_BINDIR/julia"
305+
mkdir -p "$JULIA_WRAPPER_BINDIR" || { error "failed to create directory: $JULIA_WRAPPER_BINDIR"; }
306+
307+
julia -e '
308+
println("""#!/bin/bash
309+
310+
info() {
311+
local message="\$1"
312+
echo -e "$(ENV["JUHPC"]) \$message" >&2
313+
}
314+
315+
error() {
316+
local message="\$1"
317+
info "\e[1;31mERROR:\e[0m \$message"
318+
exit 1
319+
}
320+
321+
JULIA_EXE="$(ENV["JULIAUP_BINDIR"])/julia"
322+
323+
if [ ! -f "\$JULIA_EXE" ]; then
324+
info "Julia is not yet installed, calling juliaup to install it..."
325+
"$(ENV["JULIAUP_WRAPPER"])" || error "juliaup failed to install julia."
326+
fi
327+
328+
exec "\$JULIA_EXE" "\$@"
329+
""")
330+
' > "$JULIA_WRAPPER"
331+
332+
if [ ! -s "$JULIA_WRAPPER" ]; then error "julia wrapper is missing or empty."; fi
333+
chmod +x "$JULIA_WRAPPER"
334+
335+
info "... done: wrapper created."
336+
337+
338+
# Create an opt-in IJulia installer that installs also the basic Julia kernel; furthermore, it can install further kernels in function of the JUHPC environment variables.
339+
340+
info "Creating an opt-in IJulia installer..."
341+
342+
export IJULIA_INSTALLER_BINDIR="$JUHPC_SETUP_INSTALLDIR/ijulia_installer"
343+
export IJULIA_INSTALLER="$IJULIA_INSTALLER_BINDIR/install_ijulia"
344+
mkdir -p "$IJULIA_INSTALLER_BINDIR" || { error "failed to create directory: $IJULIA_INSTALLER_BINDIR"; }
345+
346+
347+
julia -e '
348+
println("""#!/bin/bash
349+
350+
info() {
351+
local message="\$1"
352+
echo -e "$(ENV["JUHPC"]) \$message" >&2
353+
}
354+
355+
info "Installing IJulia and the basic Julia kernel..."
356+
"$(ENV["JULIA_WRAPPER"])" -e '\''
357+
using Pkg
358+
Pkg.add("IJulia")
359+
using IJulia
360+
installkernel("Julia")
361+
'\''
362+
info "... done: installation completed."
363+
""")
364+
' > "$IJULIA_INSTALLER"
365+
366+
if [ -n "${JUHPC_CUDA_HOME}" ]; then
367+
julia -e 'println("""
368+
info "Installing a kernel for Julia under Nsight Systems..."
369+
"$(ENV["JULIA_WRAPPER"])" -e '\''
370+
using IJulia
371+
installkernel("Julia under Nsight Systems"; julia = \`$(ENV["JUHPC_CUDA_HOME"])/bin/nsys launch --trace=cuda julia -i --color=yes --project=@.\`)
372+
'\''
373+
info "... done: installation completed."
374+
""")
375+
' >> "$IJULIA_INSTALLER"
376+
fi
377+
378+
if [ ! -s "$IJULIA_INSTALLER" ]; then error "IJulia installer is missing or empty."; fi
379+
chmod +x "$IJULIA_INSTALLER"
380+
381+
info "... done: installer created."
382+
383+
299384
# Create an activation script that sets environment variables for juliaup, julia and HPC key packages
300385

301386
info "Creating activate script..."

0 commit comments

Comments
 (0)