@@ -26,28 +26,43 @@ include("iROOT.jl")
26
26
27
27
TF1!kDefault = 0
28
28
29
+ module Internals
30
+ import Conda
31
+ function get_conda_build_sysroot ()
32
+ cxx = joinpath (Conda. PREFIX, " bin" , " c++" )
33
+ cmd = ` $cxx -DNDEBUG -xc++ -E -v /dev/null`
34
+ sysroot= " "
35
+ err = Pipe ()
36
+ run (pipeline (ignorestatus (cmd), stdout = devnull , stderr = err), wait= true )
37
+ close (err. in)
38
+ for l in eachline (err)
39
+ if occursin (r" sysroot/usr/include$" , l)
40
+ sysroot = strip (l)
41
+ break
42
+ end
43
+ end
44
+ replace (normpath (sysroot), normpath (" /usr/include" ) => " " )
45
+ end
46
+ end
47
+
48
+ import . Internals
49
+
29
50
function __init__ ()
30
51
# Some required environment cleanup before loading the ROOT libraries
31
- saved_path = ENV [" PATH" ]
32
- saved_ld_library_path = get (ENV , " LD_LIBRARY_PATH" , nothing )
33
- saved_dyld_library_path = get (ENV , " DYLD_LIBRARY_PATH" , nothing )
34
- # Prevent mix-up of root library version is another version than ours is in LD_LIBRARY_PATH:
35
- isnothing (saved_ld_library_path) || (ENV [" LD_LIBRARY_PATH" ] = " " )
36
- isnothing (saved_dyld_library_path) || (ENV [" DYLD_LIBRARY_PATH" ] = " " )
37
- # Workaroud to prevent a crash with root installed with Conda linker to
38
- # the c++ compiler called by cling to get the include directories and
39
- # missing in the PATH list. In the Conda install, compiler is same directory as ROOT
40
- # binaries, rootbindir
41
- ENV [" PATH" ] *= " :" * rootbindir
42
-
43
- @initcxx
44
- global gROOT = ROOT!GetROOT ()
45
-
46
- # Restore the environment:
47
- ENV [" PATH" ] = saved_path
48
- isnothing (saved_ld_library_path) || (ENV [" LD_LIBRARY_PATH" ] = saved_ld_library_path)
49
- isnothing (saved_dyld_library_path) || (ENV [" DYLD_LIBRARY_PATH" ] = saved_dyld_library_path)
50
-
52
+ withenv (
53
+ # Prevent mix-up of root library version is another version than ours is in LD_LIBRARY_PATH:
54
+ " LD_LIBRARY_PATH" => " " ,
55
+ " DYLD_LIBRARY_PATH" => " " ,
56
+ # Workaroud to prevent a crash with root installed with Conda linker to
57
+ # the c++ compiler called by cling to get the include directories and
58
+ # missing in the PATH list. In the Conda install, compiler is same directory as ROOT
59
+ # binaries, rootbindir
60
+ " PATH" => ENV [" PATH" ] * " :" * rootbindir,
61
+ # Fix "assert.h not found" issue:
62
+ " CONDA_BUILD_SYSROOT" => Internals. get_conda_build_sysroot ()) do
63
+ @initcxx
64
+ global gROOT = ROOT!GetROOT ()
65
+ end
51
66
isinteractive () && _init_event_loop ()
52
67
end
53
68
0 commit comments