Skip to content

Commit

Permalink
Precomp: Missing fix from #2251 (Work around precompiling packages wi…
Browse files Browse the repository at this point in the history
…th no `version` entry) (#2261)

* missing change from workaround packages with no version entry #2251

* ensure one more print loop to tidy up the last task

* put a bit of random offset into the spinner animations

* include a package with no version number in tests

(cherry picked from commit f9b60d4)
  • Loading branch information
IanButterworth authored and staticfloat committed Jan 6, 2021
1 parent 1d83f1a commit 999d0ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ function precompile(ctx::Context; internal_call::Bool=false, kwargs...)
println(io, " Interrupted: Exiting precompilation...")
end
else
rethrow(err)
@error "Pkg.precompile error" exception=(err, catch_backtrace())
end
end

Expand All @@ -1023,6 +1023,7 @@ function precompile(ctx::Context; internal_call::Bool=false, kwargs...)
bar = MiniProgressBar(; indent=2, header = "Progress", color = Base.info_color(), percentage=false, always_reprint=true)
n_total = length(depsmap)
bar.max = n_total - n_already_precomp
final_loop = false
while !printloop_should_exit
lock(print_lock) do
term_size = Base.displaysize(stdout)::Tuple{Int,Int}
Expand Down Expand Up @@ -1053,7 +1054,9 @@ function precompile(ctx::Context; internal_call::Bool=false, kwargs...)
filter!(!isequal(dep), pkg_queue)
end
elseif started[dep]
anim_char = anim_chars[i % length(anim_chars) + 1]
# Offset each spinner animation using the first character in the package name as the seed.
# If not offset, on larger terminal fonts it looks odd that they all sync-up
anim_char = anim_chars[(i + Int(dep.name[1])) % length(anim_chars) + 1]
anim_char_colored = dep in direct_deps ? anim_char : color_string(anim_char, :light_black)
str *= string(" $anim_char_colored ", name, "\n")
else
Expand All @@ -1063,7 +1066,8 @@ function precompile(ctx::Context; internal_call::Bool=false, kwargs...)
last_length = length(pkg_queue_show)
print(io, str)
end
printloop_should_exit = interrupted_or_done.set
printloop_should_exit = interrupted_or_done.set && final_loop
final_loop = interrupted_or_done.set # ensures one more loop to tidy last task after finish
i += 1
wait(t)
end
Expand Down Expand Up @@ -1092,7 +1096,8 @@ function precompile(ctx::Context; internal_call::Bool=false, kwargs...)

suspended = if haskey(man, pkg.uuid) # to handle the working environment uuid
pkgent = man[pkg.uuid]
precomp_suspended(PackageSpec(uuid = pkg.uuid, name = pkgent.name, version = pkgent.version, tree_hash = pkgent.tree_hash))
pkgver = something(pkgent.version, VersionSpec())
precomp_suspended(PackageSpec(uuid = pkg.uuid, name = pkgent.name, version = pkgver, tree_hash = pkgent.tree_hash))
else
false
end
Expand Down
5 changes: 5 additions & 0 deletions test/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ end
Pkg.generate("Dep3")
Pkg.generate("Dep4")
Pkg.generate("Dep5")
Pkg.generate("NoVersion")
open(joinpath("NoVersion","Project.toml"), "w") do io
write(io, "name = \"NoVersion\"\nuuid = \"$(UUIDs.uuid4())\"")
end
Pkg.generate("BrokenDep")
open(joinpath("BrokenDep","src","BrokenDep.jl"), "w") do io
write(io, "module BrokenDep\nerror()\nend")
Expand All @@ -128,6 +132,7 @@ end
ENV["JULIA_PKG_PRECOMPILE_AUTO"]=1
println("Auto precompilation enabled")
Pkg.develop(Pkg.PackageSpec(path="packages/Dep4"))
Pkg.develop(Pkg.PackageSpec(path="packages/NoVersion")) # a package with no version number
Pkg.build(io=iob) # should trigger auto-precomp
@test occursin("Precompiling", String(take!(iob)))
Pkg.precompile(io=iob)
Expand Down

0 comments on commit 999d0ba

Please sign in to comment.