Skip to content

Commit 68545ed

Browse files
authored
[mpiexecjl] Accept JULIA_BINDIR as environment variable (#481)
[`JULIA_BINDIR`](https://docs.julialang.org/en/v1/manual/environment-variables/#JULIA_BINDIR) is a standard Julia environment variable pointing to the directory where the `julia` binary is present.
1 parent c5c6bf2 commit 68545ed

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

bin/mpiexecjl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,14 @@ SCRIPT='
5656
using MPI
5757
ENV["JULIA_PROJECT"] = dirname(Base.active_project())
5858
mpiexec(exe -> run(`$exe $ARGS`))'
59+
if [ -n "${JULIA_BINDIR}" ]; then
60+
JULIA_CMD="${JULIA_BINDIR}/julia"
61+
else
62+
JULIA_CMD="julia"
63+
fi
5964

6065
if [ -n "${PROJECT_ARG}" ]; then
61-
julia "${PROJECT_ARG}" --color=yes --startup-file=no -q --compile=min -O0 -e "${SCRIPT}" -- "${@}"
66+
"${JULIA_CMD}" "${PROJECT_ARG}" --color=yes --startup-file=no -q --compile=min -O0 -e "${SCRIPT}" -- "${@}"
6267
else
63-
julia --color=yes --startup-file=no -q --compile=min -O0 -e "${SCRIPT}" -- "${@}"
68+
"${JULIA_CMD}" --color=yes --startup-file=no -q --compile=min -O0 -e "${SCRIPT}" -- "${@}"
6469
fi

test/mpiexecjl.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@ using MPI
1313
mpiexecjl = joinpath(dir, "mpiexecjl")
1414
julia = joinpath(Sys.BINDIR, Base.julia_exename())
1515
example = joinpath(@__DIR__, "..", "docs", "examples", "01-hello.jl")
16-
p = run(`$(mpiexecjl) --project=$(dir) $(julia) --startup-file=no -q $(example)`)
16+
env = ["JULIA_BINDIR" => Sys.BINDIR]
17+
p = withenv(env...) do
18+
run(`$(mpiexecjl) --project=$(dir) $(julia) --startup-file=no -q $(example)`)
19+
end
1720
@test success(p)
1821
# Test help messages
1922
for help_flag in ("-h", "--help")
20-
help_message = read(`$(mpiexecjl) --project=$(dir) --help`, String)
23+
help_message = withenv(env...) do
24+
read(`$(mpiexecjl) --project=$(dir) --help`, String)
25+
end
2126
@test occursin(r"Usage:.*MPIEXEC_ARGUMENTS", help_message)
2227
end
2328
# Without arguments, or only with the `--project` option, the wrapper will fail
24-
@test !success(`$(mpiexecjl) --project=$(dir)`)
25-
@test !success(`$(mpiexecjl)`)
29+
@test !withenv(() -> success(`$(mpiexecjl) --project=$(dir)`), env...)
30+
@test !withenv(() -> success(`$(mpiexecjl)`), env...)
2631
end
2732
end

0 commit comments

Comments
 (0)