Skip to content

Commit 51e1938

Browse files
authored
Merge pull request #1201 from JuliaLang/juliaup
Add juliaup integration to add kernels for minor versions by default
2 parents fb4c6a6 + bf1c6e4 commit 51e1938

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

deps/kspec.jl

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,22 @@ end
8181

8282
function display_name(name::AbstractString)
8383
debugdesc = ccall(:jl_is_debugbuild,Cint,())==1 ? "-debug" : ""
84-
return name * " " * Base.VERSION_STRING * debugdesc
84+
return name * " $(VERSION.major).$(VERSION.minor)" * debugdesc
85+
end
86+
87+
function julia_cmd(bindir=Sys.BINDIR)
88+
bindir_components = splitpath(bindir)
89+
juliaup_idx = findlast(==("juliaup"), bindir_components)
90+
91+
if !isnothing(juliaup_idx)
92+
juliaup_dir = joinpath(bindir_components[1:juliaup_idx])
93+
julia_exe = joinpath(juliaup_dir, joinpath("bin", exe("julia")))
94+
julia_version = "$(VERSION.major).$(VERSION.minor)"
95+
96+
`$(julia_exe) +$(julia_version)`
97+
else
98+
`$(joinpath(bindir, exe("julia")))`
99+
end
85100
end
86101

87102
"""
@@ -129,11 +144,10 @@ installkernel(
129144
```
130145
"""
131146
function installkernel(name::AbstractString, julia_options::AbstractString...;
132-
julia::Cmd = `$(joinpath(Sys.BINDIR,exe("julia")))`,
133-
specname::AbstractString = kernelspec_name(name),
134-
displayname::AbstractString = display_name(name),
135-
env::Dict{<:AbstractString}=Dict{String,Any}())
136-
147+
julia::Cmd = julia_cmd(),
148+
specname::AbstractString = kernelspec_name(name),
149+
displayname::AbstractString = display_name(name),
150+
env::Dict{<:AbstractString}=Dict{String,Any}())
137151
if isnothing(match(r"^[a-zA-Z0-9._-]+$", specname))
138152
error("Invalid specname=$(repr(specname)): Must contain only ASCII letters, ASCII numbers, and the simple separators: - hyphen, . period, _ underscore")
139153
end

docs/src/_changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ Changelog](https://keepachangelog.com).
2020
Julia 1.12.
2121
- Switched the default matplotlib backend for [`IJulia.init_matplotlib()`](@ref)
2222
to `widget`, which should be more backwards compatible ([#1205]).
23+
- IJulia now checks if juliaup is used during the build step when installing the
24+
default kernel, and if it is used then it will set the kernel command to the
25+
equivalent of `julia +major.minor` ([#1201]). This has the advantage of not
26+
needing to rebuild IJulia to update the kernel after every patch release of
27+
Julia, but it does mean that IJulia will only create kernels for each Julia
28+
minor release instead of each patch release.
2329

2430
## [v1.31.1] - 2025-10-20
2531

docs/src/manual/installation.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,22 @@ Pkg.update()
6262
If you download and install a new version of Julia from the Julia web
6363
site, you will also probably want to update the packages with
6464
`Pkg.update()` (in case newer versions of the packages are required
65-
for the most recent Julia). In any case, if you install a new Julia
66-
binary (or do anything that *changes the location of Julia* on your
67-
computer), you *must* update the IJulia installation (to tell Jupyter
68-
where to find the new Julia) by running
65+
for the most recent Julia). If you're using juliaup to manage Julia, then for
66+
every Julia *minor release* you will need to explicitly update the IJulia
67+
installation to tell Jupyter where to find the new Julia version:
6968
```julia
7069
Pkg.build("IJulia")
7170
```
7271

73-
!!! important
72+
This is because IJulia creates default kernels for every minor version if
73+
juliaup is used.
74+
75+
If you are not using juliaup to manage Julia, then you *must* update the IJulia
76+
installation every time you install a new Julia binary (or do anything that
77+
*changes the location of Julia* on your computer).
7478

79+
80+
!!! important
7581
`Pkg.build("IJulia")` **must** be run at the Julia command line.
7682
It will error and fail if run within IJulia.
7783

test/install.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import IJulia: JSONX
44

55
@testset "installkernel" begin
66
let kspec = IJulia.installkernel("ijuliatest", "-O3", "-p2",
7-
env=Dict("FOO"=>"yes"), specname="Yef1rLr4kXKxq9rbEh3m")
7+
env=Dict("FOO"=>"yes"), specname="Yef1rLr4kXKxq9rbEh3m")
88
try
99
@test basename(kspec) == "Yef1rLr4kXKxq9rbEh3m" # should not contain Julia version suffix
1010
@test dirname(kspec) == IJulia.kerneldir()
@@ -13,7 +13,7 @@ import IJulia: JSONX
1313
@test isfile(joinpath(kspec, "logo-64x64.png"))
1414
let k = JSONX.parsefile(joinpath(kspec, "kernel.json"))
1515
debugdesc = ccall(:jl_is_debugbuild,Cint,())==1 ? "-debug" : ""
16-
@test k["display_name"] == "ijuliatest" * " " * Base.VERSION_STRING * debugdesc
16+
@test k["display_name"] == "ijuliatest $(VERSION.major).$(VERSION.minor)$(debugdesc)"
1717
@test k["argv"][end] == "{connection_file}"
1818
@test k["argv"][end-4:end-3] == ["-O3", "-p2"]
1919
@test k["language"] == "julia"
@@ -35,4 +35,10 @@ import IJulia: JSONX
3535
rm(kspec, force=true, recursive=true)
3636
end
3737
end
38+
39+
# Test juliaup detection
40+
julia_exe = IJulia.exe("julia")
41+
@test IJulia.julia_cmd("bin") == `$(joinpath("bin", julia_exe))`
42+
juliaup_dir = joinpath("foo", "juliaup")
43+
@test IJulia.julia_cmd(juliaup_dir) == `$(joinpath(juliaup_dir, "bin", julia_exe)) +$(VERSION.major).$(VERSION.minor)`
3844
end

0 commit comments

Comments
 (0)