Skip to content

Instantly share code, notes, and snippets.

@Byrth
Created November 14, 2020 12:49
Show Gist options
  • Select an option

  • Save Byrth/998e38b7af1d4ca9669711afb0876c8d to your computer and use it in GitHub Desktop.

Select an option

Save Byrth/998e38b7af1d4ca9669711afb0876c8d to your computer and use it in GitHub Desktop.
using Pkg
Pkg.add("PackageCompiler")
Pkg.instantiate()
using PackageCompiler
# Switch back to the default if currently using a custom sysimage
try restore_default_sysimage() catch end
# Make Manifest.toml
manifest = Pkg.TOML.parsefile(joinpath(pwd(),"Manifest.toml"))
cd("..")
!isdir("tmp") && mkdir("tmp")
open("tmp/Manifest.toml","w") do io
Pkg.TOML.print(io, manifest)
end
# Make Project.toml
lines = String[]
push!(lines, "name = \"Fake\"")
push!(lines, "version = \"1.0.0\"")
push!(lines, "")
push!(lines, "[deps]")
append!(lines, [ "$k = \"$(v[1]["uuid"])\"" for (k,v) in manifest])
push!(lines, "")
open("tmp/Project.toml","w") do io
write(io, join(lines, "\n"))
end
# Make/Deploy sysimage
Pkg.activate("tmp")
Pkg.instantiate()
Pkg.resolve() # not necessary, but sorts things
create_sysimage(Symbol.(collect(keys(manifest))); replace_default=true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment