/
rebuildRCall.jl
50 lines (39 loc) · 909 Bytes
/
rebuildRCall.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
## Thanks to randy3k for pointing this out,
## `RCall` needs to be precompiled with the current R.
## <https://github.com/Non-Contradiction/JuliaCall/issues/9>
## as well as coming up with the solution
CurrentRhome = normpath(ARGS[1])
## println(Rhome)
ENV["R_HOME"] = CurrentRhome
const julia07 = VERSION > v"0.6.5"
if julia07
using Pkg
else
macro pkg_str(x) begin nothing end end
end
function installed(name)
@static if julia07
get(Pkg.installed(), name, nothing)
else
Pkg.installed(name)
end
end
if installed("Suppressor") == nothing
Pkg.add("Suppressor")
end;
using Suppressor
if installed("RCall") == nothing
Pkg.add("RCall")
end;
try
using RCall
catch e
Pkg.build("RCall")
end
if normpath(RCall.Rhome) != CurrentRhome
if installed("RCall") >= v"0.10.2"
Pkg.build("RCall")
else
Base.compilecache("RCall")
end
end