Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move Pkg out of the sysimage (take 2) #51189

Merged
merged 8 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,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)
Expand Down
13 changes: 1 addition & 12 deletions contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,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)
Expand Down Expand Up @@ -192,7 +183,6 @@ if InteractiveUtils !== nothing
end

const JULIA_PROMPT = "julia> "
const PKG_PROMPT = "pkg> "
const SHELL_PROMPT = "shell> "
const HELP_PROMPT = "help?> "

Expand Down Expand Up @@ -366,7 +356,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)
Expand Down Expand Up @@ -455,7 +444,7 @@ generate_precompile_statements() = try # Make sure `ansi_enablecursor` is printe
println()
# Seems like a reasonable number right now, adjust as needed
# comment out if debugging script
n_succeeded > (have_repl ? 900 : 90) || @warn "Only $n_succeeded precompile statements"
n_succeeded > (have_repl ? 650 : 90) || @warn "Only $n_succeeded precompile statements"

fetch(step1) == :ok || throw("Step 1 of collecting precompiles failed.")
fetch(step2) == :ok || throw("Step 2 of collecting precompiles failed.")
Expand Down
2 changes: 1 addition & 1 deletion pkgimage.mk
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,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))
Expand Down
25 changes: 25 additions & 0 deletions stdlib/REPL/src/REPL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,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"))
KristofferC marked this conversation as resolved.
Show resolved Hide resolved
# 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
vchuravy marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
4 changes: 2 additions & 2 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,8 @@ precompile_test_harness(false) do dir
[:ArgTools, :Artifacts, :Base64, :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]
),
Expand Down