Skip to content

Commit a841bfc

Browse files
authored
Add kwarg julia to installkernel (to support JupyterHub with containers, etc.) (#948)
1 parent 9b10fa9 commit a841bfc

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

deps/kspec.jl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ end
4747

4848
"""
4949
installkernel(name::AbstractString, options::AbstractString...;
50+
julia::Cmd,
5051
specname::AbstractString,
5152
env=Dict())
5253
@@ -66,8 +67,23 @@ The returned `kernelpath` is the path of the installed kernel directory, somethi
6667
directory (which defaults to `name` with spaces replaced by hyphens).
6768
6869
You can uninstall the kernel by calling `rm(kernelpath, recursive=true)`.
70+
71+
You can specify a custom command to execute Julia via keyword argument
72+
`julia`. For example, you may want specify that the Julia kernel is running
73+
in a Docker container (but Jupyter will run outside of it), by calling
74+
`installkernel` from within such a container instance like this (or similar):
75+
76+
```
77+
installkernel(
78+
"Julia via Docker",
79+
julia = `docker run --rm --net=host
80+
--volume=/home/USERNAME/.local/share/jupyter:/home/USERNAME/.local/share/jupyter
81+
some-container /opt/julia-1.x/bin/julia`
82+
)
83+
```
6984
"""
7085
function installkernel(name::AbstractString, julia_options::AbstractString...;
86+
julia::Cmd = `$(joinpath(Sys.BINDIR,exe("julia")))`,
7187
specname::AbstractString = replace(lowercase(name), " "=>"-"),
7288
env::Dict{<:AbstractString}=Dict{String,Any}())
7389
# Is IJulia being built from a debug build? If so, add "debug" to the description.
@@ -78,7 +94,7 @@ function installkernel(name::AbstractString, julia_options::AbstractString...;
7894
@info("Installing $name kernelspec in $juliakspec")
7995
rm(juliakspec, force=true, recursive=true)
8096
try
81-
kernelcmd_array = String[joinpath(Sys.BINDIR,exe("julia")), "-i",
97+
kernelcmd_array = String[julia.exec..., "-i",
8298
"--startup-file=yes", "--color=yes"]
8399
append!(kernelcmd_array, julia_options)
84100
ijulia_dir = get(ENV, "IJULIA_DIR", dirname(@__DIR__)) # support non-Pkg IJulia installs

0 commit comments

Comments
 (0)