Skip to content

Commit af5b3ed

Browse files
authored
Merge pull request #1137 from JamesWrigley/displayname
Allow customizing the kernel display name
2 parents 07f30e4 + b93499c commit af5b3ed

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

deps/kspec.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,16 @@ else
5454
exe(s::AbstractString, e::AbstractString) = s * e
5555
end
5656

57+
function display_name(name::AbstractString)
58+
debugdesc = ccall(:jl_is_debugbuild,Cint,())==1 ? "-debug" : ""
59+
return name * " " * Base.VERSION_STRING * debugdesc
60+
end
61+
5762
"""
5863
installkernel(name::AbstractString, options::AbstractString...;
5964
julia::Cmd,
6065
specname::AbstractString,
66+
displayname::AbstractString,
6167
env=Dict())
6268
6369
Install a new Julia kernel, where the given `options` are passed to the `julia`
@@ -71,6 +77,9 @@ kernelpath = installkernel("Julia O3", "-O3", env=Dict("FOO"=>"yes"))
7177
creates a new Julia kernel in which `julia` is launched with the `-O3`
7278
optimization flag and `FOO=yes` is included in the environment variables.
7379
80+
The `displayname` argument can be used to customize the name displayed in the
81+
Jupyter kernel list.
82+
7483
The returned `kernelpath` is the path of the installed kernel directory,
7584
something like `/...somepath.../kernels/julia-o3-1.6` (in Julia 1.6). The
7685
`specname` argument can be passed to alter the name of this directory (which
@@ -96,6 +105,7 @@ installkernel(
96105
function installkernel(name::AbstractString, julia_options::AbstractString...;
97106
julia::Cmd = `$(joinpath(Sys.BINDIR,exe("julia")))`,
98107
specname::AbstractString = kernelspec_name(name),
108+
displayname::AbstractString = display_name(name),
99109
env::Dict{<:AbstractString}=Dict{String,Any}())
100110
# Is IJulia being built from a debug build? If so, add "debug" to the description.
101111
debugdesc = ccall(:jl_is_debugbuild,Cint,())==1 ? "-debug" : ""
@@ -112,7 +122,7 @@ function installkernel(name::AbstractString, julia_options::AbstractString...;
112122

113123
ks = Dict(
114124
"argv" => kernelcmd_array,
115-
"display_name" => name * " " * Base.VERSION_STRING * debugdesc,
125+
"display_name" => displayname,
116126
"language" => "julia",
117127
"env" => env,
118128
# Jupyter's signal interrupt mode is not supported on Windows

test/install.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ import IJulia, JSON
2222
end
2323
end
2424

25-
let kspec = IJulia.installkernel("ahzAHZ019.-_ ~!@#%^&*()")
25+
let kspec = IJulia.installkernel("ahzAHZ019.-_ ~!@#%^&*()"; displayname="foo")
2626
try
2727
@test occursin("ahzahz019.-_-__________", basename(kspec))
28+
29+
let k = open(JSON.parse, joinpath(kspec, "kernel.json"))
30+
@test k["display_name"] == "foo"
31+
end
2832
finally
2933
rm(kspec, force=true, recursive=true)
3034
end

0 commit comments

Comments
 (0)