1 | import sys
|
---|
2 | import os
|
---|
3 |
|
---|
4 | if len(sys.argv) > 1:
|
---|
5 | path_to_libz_so = sys.argv[1]
|
---|
6 | else:
|
---|
7 | path_to_libz_so = None
|
---|
8 |
|
---|
9 | def readlinkabs(l):
|
---|
10 | """
|
---|
11 | Return an absolute path for the destination
|
---|
12 | of a symlink
|
---|
13 | """
|
---|
14 | assert (os.path.islink(l))
|
---|
15 | p = os.readlink(l)
|
---|
16 | if os.path.isabs(p):
|
---|
17 | return p
|
---|
18 | return os.path.join(os.path.dirname(l), p)
|
---|
19 |
|
---|
20 | def find_libz():
|
---|
21 | print "Searching for libz.so ..."
|
---|
22 | search_pathes = ['/usr']
|
---|
23 | found_pathes = []
|
---|
24 |
|
---|
25 | for sp in search_pathes:
|
---|
26 | find_result = os.popen("find %s | grep libz.so"%sp).readlines()
|
---|
27 | for line in find_result:
|
---|
28 | found_pathes.append(line.split())
|
---|
29 | if len(found_pathes) == 0:
|
---|
30 | print "Error: libz.so not found!"
|
---|
31 | return None
|
---|
32 | elif len(found_pathes) > 1:
|
---|
33 | print "Error: Multiple Possibilities found, please choose one from:"
|
---|
34 | print found_pathes
|
---|
35 | return None
|
---|
36 | else:
|
---|
37 | print "Found libz.so in", found_pathes[0]
|
---|
38 | return found_pathes[0]
|
---|
39 |
|
---|
40 |
|
---|
41 | print "Welcome to the pyfact installer"
|
---|
42 | print "-------------------------------"
|
---|
43 |
|
---|
44 | print "Trying to import ROOT"
|
---|
45 | try:
|
---|
46 | import ROOT
|
---|
47 | root_available = True
|
---|
48 | except ImportError:
|
---|
49 | root_available = False
|
---|
50 |
|
---|
51 | if not root_available:
|
---|
52 | print "Was not able to import ROOT ... aborting"
|
---|
53 | sys.exit(1)
|
---|
54 |
|
---|
55 | print "Found ROOT Version", ROOT.gROOT.GetVersion(), "in", ROOT.__file__
|
---|
56 | print
|
---|
57 | print "Checking if libz is already loaded into ROOT."
|
---|
58 | print "(Please ignore ROOT ouput):"
|
---|
59 | libz_loaded_check = ROOT.gSystem.Load("libz")
|
---|
60 | print " End of ROOT output"
|
---|
61 | if libz_loaded_check != 1:
|
---|
62 | print "libz is not loaded into ROOT"
|
---|
63 | if not path_to_libz_so:
|
---|
64 | print "Searching for libz.so ..."
|
---|
65 | path_to_libz_so = find_libz()
|
---|
66 | if not path_to_libz_so:
|
---|
67 | print "Was not able to find unique libz.so path ... aborting"
|
---|
68 | sys.exit(1)
|
---|
69 | ROOT.gSystem.Load(path_to_libz_so)
|
---|
70 |
|
---|
71 | print "Compiling C++ headers with ACliC"
|
---|
72 | ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/izstream.h+O");
|
---|
73 | ROOT.gROOT.ProcessLine(".L fits.h+O");
|
---|
74 | ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/zfits.h+O");
|
---|
75 | ROOT.gROOT.ProcessLine(".L extern_Mars_mcore/factfits.h+O");
|
---|
76 | ROOT.gROOT.ProcessLine(".L calfactfits.h+O");
|
---|
77 |
|
---|
78 | print
|
---|
79 | print "done."
|
---|
80 | sys.exit(0)
|
---|