How can I precompile all modules in Julia from my first session instead of waiting for a while everytime Julia uses a new module?
Is there any fast way to install all Julia available packages or the most common ones without going one per one? Maybe a bunch of common useful packages.
"Precompile all packages"
function precompile_pkgs end
try
@eval using ProgressMeter
@eval function precompile_pkgs()
@showprogress for pkg in collect(keys(Pkg.installed()))
if !isdefined(Symbol(pkg))
info("Importing $(pkg)...")
try (@eval import $(Symbol(pkg))) catch end
end
end
end
catch
function precompile_pkgs()
for pkg in collect(keys(Pkg.installed()))
if !isdefined(Symbol(pkg))
info("Importing $(pkg)...")
try (@eval import $(Symbol(pkg))) catch end
end
end
end
end
One modification that makes it work here, is that the command doesn’t seemed to hang up on Compat.jl.
So I modified the loop to exclude Compat, as below:
function precompile_pkgs()
for pkg in collect(keys(Pkg.installed()))
if !isdefined(Symbol(pkg)) && pkg != "Compat.jl"
info("Importing $(pkg)...")
try (@eval import $(Symbol(pkg))) catch end
end
end
end
Also that bit with ProgressMeter doesn’t work, so at some point I’ll just remove that cleverness. But the function does indeed make everything precompile.