From 25f4197df40123dc17f485ee98768df8832afa88 Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Mon, 14 Oct 2024 12:46:18 +0200 Subject: [PATCH] Fix precompilation Julia 1.11 (#3054) --- src/packages/Packages.jl | 16 ++++++++++------ src/packages/PkgCompat.jl | 7 ++++++- src/packages/precompile_isolated.jl | 3 +++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/packages/Packages.jl b/src/packages/Packages.jl index 9b1f63a43..9b0a64944 100644 --- a/src/packages/Packages.jl +++ b/src/packages/Packages.jl @@ -237,10 +237,12 @@ function sync_nbpkg_core( used_tier = tier try - Pkg.add(notebook.nbpkg_ctx, [ - Pkg.PackageSpec(name=p) - for p in to_add - ]; preserve=used_tier) + withenv("JULIA_PKG_PRECOMPILE_AUTO" => 0) do + Pkg.add(notebook.nbpkg_ctx, [ + Pkg.PackageSpec(name=p) + for p in to_add + ]; preserve=used_tier) + end break catch e @@ -581,10 +583,12 @@ function update_nbpkg_core( phasemessage(iolistener, "Updating packages") # We temporarily clear the "semver-compatible" [deps] entries, because it is difficult to update them after the update 🙈. TODO PkgCompat.clear_auto_compat_entries!(notebook.nbpkg_ctx) - + try ### - Pkg.update(notebook.nbpkg_ctx; level=level) + withenv("JULIA_PKG_PRECOMPILE_AUTO" => 0) do + Pkg.update(notebook.nbpkg_ctx; level=level) + end ### finally PkgCompat.write_auto_compat_entries!(notebook.nbpkg_ctx) diff --git a/src/packages/PkgCompat.jl b/src/packages/PkgCompat.jl index f9da062c8..636261fdc 100644 --- a/src/packages/PkgCompat.jl +++ b/src/packages/PkgCompat.jl @@ -163,7 +163,12 @@ end # I'm a pirate harrr 🏴‍☠️ @static if isdefined(Pkg, :can_fancyprint) - Pkg.can_fancyprint(io::Union{IOContext{IOBuffer},IOContext{Base.BufferStream}}) = get(io, :sneaky_enable_tty, false) === true + Pkg.can_fancyprint(io::Union{IOContext{IOBuffer},IOContext{Base.BufferStream}}) = + get(io, :sneaky_enable_tty, false) === true +end +@static if isdefined(Base, :Precompilation) && isdefined(Base.Precompilation, :can_fancyprint) + Base.Precompilation.can_fancyprint(io::Union{IOContext{IOBuffer},IOContext{Base.BufferStream}}) = + get(io, :sneaky_enable_tty, false) === true end ### diff --git a/src/packages/precompile_isolated.jl b/src/packages/precompile_isolated.jl index aaf488b01..ef58308df 100644 --- a/src/packages/precompile_isolated.jl +++ b/src/packages/precompile_isolated.jl @@ -16,6 +16,9 @@ function precompile_isolated( @static if isdefined(Pkg, :can_fancyprint) Pkg.can_fancyprint(io::IO) = true end + @static if isdefined(Base, :Precompilation) && isdefined(Base.Precompilation, :can_fancyprint) + Base.Precompilation.can_fancyprint(io::IO) = true + end Pkg.activate($(repr(environment)); io=out_stream) Pkg.precompile(; already_instantiated=true, io=out_stream)