From 22ee08924748ca82b6717c59b01b2316fba8f39d Mon Sep 17 00:00:00 2001 From: KristofferC Date: Fri, 24 Mar 2023 13:42:12 +0100 Subject: [PATCH 1/2] WIP: move Pkg out of the sysimage --- base/sysimg.jl | 3 --- contrib/generate_precompile.jl | 14 +------------- pkgimage.mk | 2 +- stdlib/REPL/src/REPL.jl | 25 +++++++++++++++++++++++++ test/precompile.jl | 4 ++-- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/base/sysimg.jl b/base/sysimg.jl index b0eeffa5757ba..3bb79b0fde842 100644 --- a/base/sysimg.jl +++ b/base/sysimg.jl @@ -70,9 +70,6 @@ let # 5-depth packages :Downloads, - - # 6-depth packages - :Pkg, ] # PackageCompiler can filter out stdlibs so it can be empty maxlen = maximum(textwidth.(string.(stdlibs)); init=0) diff --git a/contrib/generate_precompile.jl b/contrib/generate_precompile.jl index c99e6c646ec1c..64ffc4df65fa3 100644 --- a/contrib/generate_precompile.jl +++ b/contrib/generate_precompile.jl @@ -147,16 +147,6 @@ if Artifacts !== nothing """ end - -Pkg = get(Base.loaded_modules, - Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg"), - nothing) - -if Pkg !== nothing - # TODO: Split Pkg precompile script into REPL and script part - repl_script = Pkg.precompile_script * repl_script # do larger workloads first for better parallelization -end - FileWatching = get(Base.loaded_modules, Base.PkgId(Base.UUID("7b1f6079-737a-58dc-b8bc-7a2ca5c1b5ee"), "FileWatching"), nothing) @@ -179,7 +169,6 @@ end const JULIA_PROMPT = "julia> " -const PKG_PROMPT = "pkg> " const SHELL_PROMPT = "shell> " const HELP_PROMPT = "help?> " @@ -352,7 +341,6 @@ generate_precompile_statements() = try # Make sure `ansi_enablecursor` is printe while !eof(output_copy) strbuf *= String(readavailable(output_copy)) occursin(JULIA_PROMPT, strbuf) && break - occursin(PKG_PROMPT, strbuf) && break occursin(SHELL_PROMPT, strbuf) && break occursin(HELP_PROMPT, strbuf) && break sleep(0.1) @@ -439,7 +427,7 @@ generate_precompile_statements() = try # Make sure `ansi_enablecursor` is printe if have_repl # Seems like a reasonable number right now, adjust as needed # comment out if debugging script - n_succeeded > 1500 || @warn "Only $n_succeeded precompile statements" + n_succeeded > 650 || @warn "Only $n_succeeded precompile statements" end fetch(step1) == :ok || throw("Step 1 of collecting precompiles failed.") diff --git a/pkgimage.mk b/pkgimage.mk index caf30a91c1d18..13a27d83dfed8 100644 --- a/pkgimage.mk +++ b/pkgimage.mk @@ -114,7 +114,7 @@ $(eval $(call sysimg_builder,LibCURL,LibCURL_jll MozillaCACerts_jll)) $(eval $(call sysimg_builder,Downloads,ArgTools FileWatching LibCURL NetworkOptions)) # 6-depth packages -$(eval $(call sysimg_builder,Pkg,Dates LibGit2 Libdl Logging Printf Random SHA UUIDs)) # Markdown REPL +$(eval $(call pkgimg_builder,Pkg,Dates LibGit2 Libdl Logging Printf Random SHA UUIDs)) # Markdown REPL # 7-depth packages $(eval $(call pkgimg_builder,LazyArtifacts,Artifacts Pkg)) diff --git a/stdlib/REPL/src/REPL.jl b/stdlib/REPL/src/REPL.jl index c951f302359f2..12225946984ef 100644 --- a/stdlib/REPL/src/REPL.jl +++ b/stdlib/REPL/src/REPL.jl @@ -1096,6 +1096,31 @@ function setup_interface( edit_insert(s, '?') end end, + ']' => function (s::MIState,o...) + if isempty(s) || position(LineEdit.buffer(s)) == 0 + pkgid = Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg") + if Base.locate_package(pkgid) !== nothing # Only try load Pkg if we can find it + Pkg = Base.require(Base.PkgId(Base.UUID("44cfe95a-1eb2-52ea-b672-e2afdf69b78f"), "Pkg")) + # Pkg should have loaded its REPL mode by now, let's find it so we can transition to it. + pkg_mode = nothing + for mode in repl.interface.modes + if mode isa LineEdit.Prompt && mode.complete isa Pkg.REPLMode.PkgCompletionProvider + pkg_mode = mode + break + end + end + # TODO: Cache the `pkg_mode`? + if pkg_mode !== nothing + buf = copy(LineEdit.buffer(s)) + transition(s, pkg_mode) do + LineEdit.state(s, pkg_mode).input_buffer = buf + end + return + end + end + end + edit_insert(s, ']') + end, # Bracketed Paste Mode "\e[200~" => (s::MIState,o...)->begin diff --git a/test/precompile.jl b/test/precompile.jl index 37498068fd39c..36f33046a68ad 100644 --- a/test/precompile.jl +++ b/test/precompile.jl @@ -397,8 +397,8 @@ precompile_test_harness(false) do dir [:ArgTools, :Artifacts, :Base64, :CompilerSupportLibraries_jll, :CRC32c, :Dates, :Downloads, :FileWatching, :Future, :InteractiveUtils, :libblastrampoline_jll, :LibCURL, :LibCURL_jll, :LibGit2, :Libdl, :LinearAlgebra, - :Logging, :Markdown, :Mmap, :MozillaCACerts_jll, :NetworkOptions, :OpenBLAS_jll, :Pkg, :Printf, - :p7zip_jll, :REPL, :Random, :SHA, :Serialization, :Sockets, + :Logging, :Markdown, :Mmap, :MozillaCACerts_jll, :NetworkOptions, :OpenBLAS_jll, :Printf, + :REPL, :Random, :SHA, :Serialization, :Sockets, :TOML, :Tar, :Test, :UUIDs, :Unicode, :nghttp2_jll] ), From ba9c45566ac0f668a674397f0d84d641e107cab4 Mon Sep 17 00:00:00 2001 From: Kristoffer Date: Tue, 18 Apr 2023 14:46:17 +0200 Subject: [PATCH 2/2] bump Pkg to latest version --- .../Pkg-2618945685d32b1e595f00ef809d545067ae01f1.tar.gz/md5 | 1 + .../Pkg-2618945685d32b1e595f00ef809d545067ae01f1.tar.gz/sha512 | 1 + .../Pkg-7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc.tar.gz/md5 | 1 - .../Pkg-7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc.tar.gz/sha512 | 1 - stdlib/Pkg.version | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 deps/checksums/Pkg-2618945685d32b1e595f00ef809d545067ae01f1.tar.gz/md5 create mode 100644 deps/checksums/Pkg-2618945685d32b1e595f00ef809d545067ae01f1.tar.gz/sha512 delete mode 100644 deps/checksums/Pkg-7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc.tar.gz/md5 delete mode 100644 deps/checksums/Pkg-7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc.tar.gz/sha512 diff --git a/deps/checksums/Pkg-2618945685d32b1e595f00ef809d545067ae01f1.tar.gz/md5 b/deps/checksums/Pkg-2618945685d32b1e595f00ef809d545067ae01f1.tar.gz/md5 new file mode 100644 index 0000000000000..b7f96f9d33c6c --- /dev/null +++ b/deps/checksums/Pkg-2618945685d32b1e595f00ef809d545067ae01f1.tar.gz/md5 @@ -0,0 +1 @@ +99234d899798a88e8b3ce3021dba7740 diff --git a/deps/checksums/Pkg-2618945685d32b1e595f00ef809d545067ae01f1.tar.gz/sha512 b/deps/checksums/Pkg-2618945685d32b1e595f00ef809d545067ae01f1.tar.gz/sha512 new file mode 100644 index 0000000000000..26b61ade7e7a1 --- /dev/null +++ b/deps/checksums/Pkg-2618945685d32b1e595f00ef809d545067ae01f1.tar.gz/sha512 @@ -0,0 +1 @@ +64124b687d78cf386248b80724131780da09f224a2848d09e6017795fe297b95702edd507f8818ee730bb1e6fb8cea4d1dad774bbc71443ac17c17ad82d6fcf3 diff --git a/deps/checksums/Pkg-7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc.tar.gz/md5 b/deps/checksums/Pkg-7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc.tar.gz/md5 deleted file mode 100644 index 7a0f31b8bec01..0000000000000 --- a/deps/checksums/Pkg-7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc.tar.gz/md5 +++ /dev/null @@ -1 +0,0 @@ -2885181bffe95462f1877668ccea7057 diff --git a/deps/checksums/Pkg-7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc.tar.gz/sha512 b/deps/checksums/Pkg-7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc.tar.gz/sha512 deleted file mode 100644 index f8231bbf2833f..0000000000000 --- a/deps/checksums/Pkg-7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc.tar.gz/sha512 +++ /dev/null @@ -1 +0,0 @@ -5f3ded1970a6d8bfc779de54e61b1dd58fa770799aac3a031b2ea536d159bf672e9490f53ecdfbf1c175adfe93b0868a88330619506da802218a98f07e64dd94 diff --git a/stdlib/Pkg.version b/stdlib/Pkg.version index 4274859b10120..a06ec5b6df3f2 100644 --- a/stdlib/Pkg.version +++ b/stdlib/Pkg.version @@ -1,4 +1,4 @@ PKG_BRANCH = master -PKG_SHA1 = 7ebf98b4365e3b68a3d0784f7470baa7b2c4b6bc +PKG_SHA1 = 2618945685d32b1e595f00ef809d545067ae01f1 PKG_GIT_URL := https://github.com/JuliaLang/Pkg.jl.git PKG_TAR_URL = https://api.github.com/repos/JuliaLang/Pkg.jl/tarball/$1