diff --git a/deps/kspec.jl b/deps/kspec.jl index b222c816..637ec0f3 100644 --- a/deps/kspec.jl +++ b/deps/kspec.jl @@ -54,10 +54,16 @@ else exe(s::AbstractString, e::AbstractString) = s * e end +function display_name(name::AbstractString) + debugdesc = ccall(:jl_is_debugbuild,Cint,())==1 ? "-debug" : "" + return name * " " * Base.VERSION_STRING * debugdesc +end + """ installkernel(name::AbstractString, options::AbstractString...; julia::Cmd, specname::AbstractString, + displayname::AbstractString, env=Dict()) 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")) creates a new Julia kernel in which `julia` is launched with the `-O3` optimization flag and `FOO=yes` is included in the environment variables. +The `displayname` argument can be used to customize the name displayed in the +Jupyter kernel list. + The returned `kernelpath` is the path of the installed kernel directory, something like `/...somepath.../kernels/julia-o3-1.6` (in Julia 1.6). The `specname` argument can be passed to alter the name of this directory (which @@ -96,6 +105,7 @@ installkernel( function installkernel(name::AbstractString, julia_options::AbstractString...; julia::Cmd = `$(joinpath(Sys.BINDIR,exe("julia")))`, specname::AbstractString = kernelspec_name(name), + displayname::AbstractString = display_name(name), env::Dict{<:AbstractString}=Dict{String,Any}()) # Is IJulia being built from a debug build? If so, add "debug" to the description. debugdesc = ccall(:jl_is_debugbuild,Cint,())==1 ? "-debug" : "" @@ -112,7 +122,7 @@ function installkernel(name::AbstractString, julia_options::AbstractString...; ks = Dict( "argv" => kernelcmd_array, - "display_name" => name * " " * Base.VERSION_STRING * debugdesc, + "display_name" => displayname, "language" => "julia", "env" => env, # Jupyter's signal interrupt mode is not supported on Windows diff --git a/test/install.jl b/test/install.jl index 4698feb7..9db40275 100644 --- a/test/install.jl +++ b/test/install.jl @@ -22,9 +22,13 @@ import IJulia, JSON end end - let kspec = IJulia.installkernel("ahzAHZ019.-_ ~!@#%^&*()") + let kspec = IJulia.installkernel("ahzAHZ019.-_ ~!@#%^&*()"; displayname="foo") try @test occursin("ahzahz019.-_-__________", basename(kspec)) + + let k = open(JSON.parse, joinpath(kspec, "kernel.json")) + @test k["display_name"] == "foo" + end finally rm(kspec, force=true, recursive=true) end