How to use julia's PackageCompiler to build a quick launch environment for PlotStats?

654 Views Asked by At

I want to use 'DataFrames,CSV,StatsPlots' packages without waiting time after reboot machine, I'm trying to use PackageCompiler, but the README or help is hard to understand.

using using PackageCompiler
syso, sys = compile_incremental(:DataFrames,:CSV,:StatsPlots)

Well, I'm afraid to destroy the system image, so, at first, I don't use the 'force=true' option. It shows error messages:

...
Resolving package versions... 
ERROR: LoadError: Unsatisfiable requirements detected for package WinRPM [c17dfb99]:
 WinRPM [c17dfb99] log:                                                                                                                                             
 ├─possible versions are: [0.3.3, 0.4.0-0.4.3] or uninstalled                     
 ├─restricted by compatibility requirements with PackageCompiler [9b87118b] to versions: [0.3.3, 0.4.0-0.4.3]                                                       
 │ └─PackageCompiler [9b87118b] log: 
 │   ├─possible versions are: [0.5.0-0.5.1, 0.6.0-0.6.5] or uninstalled
 │   └─restricted to versions * by an explicit requirement, leaving only versions [0.5.0-0.5.1, 0.6.0-0.6.5]
 ├─restricted by compatibility requirements with Compat [34da2185] to versions: 0.4.3 or uninstalled, leaving only versions: 0.4.3
 │ └─Compat [34da2185] log:
 │   ├─possible versions are: [1.0.0-1.0.1, 1.1.0, 1.2.0, 1.3.0, 1.4.0, 1.5.0-1.5.1, 2.0.0, 2.1.0, 2.2.0, 3.0.0, 3.1.0, 3.2.0] or uninstalled
 │   └─restricted to versions 3.2.0 by an explicit requirement, leaving only versions 3.2.0
 └─restricted by compatibility requirements with HTTPClient [0862f596] to versions: uninstalled — no versions left
   └─HTTPClient [0862f596] log:
     ├─possible versions are: 0.2.1 or uninstalled
     └─restricted by compatibility requirements with Compat [34da2185] to versions: uninstalled
       └─Compat [34da2185] log: see above
1

There are 1 best solutions below

0
Daniel YC Lin On

It seems workable by PackageCompilerX. At first, the package's version is very sensitive, it require correct version to let everything work.

Here are two of my testing environment for julia 1.3.1

  • debian: apt -t unstable install julia libjulia-dev
  • archlinux: pacman -S julia

check Julia's version(PackageCompilerX only work after 1.3.1)

julia> versioninfo()
Julia Version 1.3.1
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU @ 2.20GHz

Add PackageCompilerX and all package which you want to plot to repository

pkg> add https://github.com/KristofferC/PackageCompilerX.jl
pkg> status
Status `~/.julia/environments/v1.3/Project.toml`
...

Copy system's Project.toml to current directory for customize your development environment, use editor(here vim) to remove some package which can't compile or not required.

shell> rm Project.toml
shell> cp ~/.julia/environments/v1.3/Project.toml .
shell> vim Project.toml

activate local package environment

julia> using PackageCompilerX
pkg> activate .
pkg> status  # double check all package which you want have installed
    Status `~/prj/julia/Project.toml`
  [336ed68f] CSV v0.5.22
  [a93c6f00] DataFrames v0.20.0
  ...

generated sybmol array automatically in julia prompt

s=split(read("Project.toml", String),"\n")
pkgs=Symbol[]
for i in s
  if (length(i) > 0) && !(i[1] in ['[','#'])
    push!(pkgs, Symbol(split(i," ")[1]))
  end
end

show pkgs

julia> pkgs
10-element Array{Symbol,1}:
 :CSV
 :DataFrames
 ...

compile it and output to "dev.so" by

julia> create_sysimage(pkgs, sysimage_path="dev.so")

exit julia, and re-launch julia by

julia -J dev.so

Benchmark these two launch method and result:

time julia -q -e 'using Plots,UnicodePlots; unicodeplots(); display(plot(sin))'
# result: 35.175s
time julia -J dev.so -q -e 'using Plots,UnicodePlots; unicodeplots(); display(plot(sin))'
# result: 15.2365s