Esempio n. 1
0
    def ExtractInfo(self):
        theCommands = [self.bin_path + '/fastjet-config', '--version']
        ok, out, err = ShellCommand.ExecuteWithCapture(theCommands, './')
        if not ok:
            msg = 'fastjet-config program does not work properly.'
            return False, msg
        out = out.lstrip()
        out = out.rstrip()
        self.version = str(out)
        if self.debug:
            self.logger.debug("  version:       " + self.version)

        # Using fastjet-config for getting lib and header paths
        self.logger.debug("Trying to get library and header paths ...")
        theCommands = [
            self.bin_path + '/fastjet-config', '--libs', '--plugins'
        ]
        ok, out, err = ShellCommand.ExecuteWithCapture(theCommands, './')
        if not ok:
            msg = 'fastjet-config program does not work properly.'
            return False, msg

        # Extracting FastJet library and header path
        out = out.lstrip()
        out = out.rstrip()
        self.logger.debug("  Lib flags:     " + str(out))
        words = out.split()
        for word in words:
            if word.startswith('-L') and not word[2:] in self.lib_paths:
                self.lib_paths.append(word[2:])
        if self.debug:
            self.logger.debug("  Lib path:      " + str(self.lib_paths))

        # Ok
        return True
Esempio n. 2
0
    def ExtractInfo(self):
        # Which all
        if self.debug:
            result = ShellCommand.Which('make',all=True,mute=True)
            if len(result)==0:
                self.logger.error('GNU Make not found. Please install it before ' + \
                 'using MadAnalysis 5')
                return False
            self.logger.debug("  which-all:     ")
            for file in result:
                self.logger.debug("    - "+str(file))

        # Getting the version
        ok, out, err = ShellCommand.ExecuteWithCapture(['make','--version'],'./')
        if not ok:
            self.logger.error('GNU Make not found. Please install it before ' + \
             'using MadAnalysis 5')
            return False
        lines=out.split('\n')
        if len(lines)==0:
             self.logger.error('command "make --version" seems to not give the GNU Make version')
             return False
        firstline=lines[0]
        firstline=firstline.lstrip()
        firstline=firstline.rstrip()
        self.version = str(firstline)
        if self.debug:
            self.logger.debug("  version:       " + self.version)


        # Ok
        return True
Esempio n. 3
0
    def ExtractInfo(self):
        # Using root-config for getting lib and header paths as well as the version number
        self.logger.debug("Trying to get library and header paths ...") 
        theCommands = [self.bin_path+'/root-config','--libdir','--incdir', '--version']
        ok, out, err = ShellCommand.ExecuteWithCapture(theCommands,'./')
        if not ok:
            msg = 'ROOT module called "root-config" is not detected.\n'\
                  +'Two explanations :n'\
                  +' - ROOT is not installed. You can download it '\
                  +'from http://root.cern.ch\n'\
                  +' - ROOT binary folder must be placed in the '\
                  +'global environment variable $PATH'
            return False,msg

        # Extracting ROOT library and header path
        out=out.lstrip()
        out=out.rstrip()
        root_tmp = out.split()
        self.version  = root_tmp[2].replace('/','.').split('.')
        self.inc_path = os.path.normpath(root_tmp[1])
        self.lib_path = os.path.normpath(root_tmp[0])
        self.logger.debug("-> root-config found")
        self.logger.debug("-> root version: "+'.'.join(self.version))
        self.logger.debug("-> root header  folder: "+self.inc_path)
        self.logger.debug("-> root library folder: "+self.lib_path)

        # Check: looking for files
        FilesToFind=[os.path.normpath(self.lib_path+'/libCore.so'), \
                     os.path.normpath(self.inc_path+'/TH1F.h')]
        for file in FilesToFind:
            self.logger.debug("Try to find "+file+" ...")
            if os.path.isfile(file):
                self.libraries[file.split('/')[-1]]=file+":"+str(os.stat(file).st_mtime)
            else:
                msg = "ROOT file called '"+file+"' is not found\n"\
                 + "Please check that ROOT is properly installed."
                return False,msg

        # Getting the features
        theCommands = [self.bin_path+'/root-config','--features']
        ok, out, err = ShellCommand.ExecuteWithCapture(theCommands,'./')
        if not ok:
            self.logger.error('problem with root-config')
            return False
        out=out.lstrip()
        out=out.rstrip()
        features = str(out).split()
        features.sort()
        for feature in features:
            self.features.append(feature)
        if self.debug:
            self.logger.debug("  features:      " + str(self.features))

        # Getting the compiler
        theCommands = [self.bin_path+'/root-config','--cxx']
        ok, out, err = ShellCommand.ExecuteWithCapture(theCommands,'./')
        if not ok:
            self.logger.error('impossible to get C++ compiler from root-config')
            return False
        out=out.lstrip()
        out=out.rstrip()
        self.compiler = out
        if self.debug:
            self.logger.debug("  C++ compiler:      " + str(self.compiler))

        # Ok
        return True
Esempio n. 4
0
    def ExtractInfo(self):

        # Which all
        if self.debug:
            result = ShellCommand.Which('g++', all=True, mute=True)
            if len(result) == 0:
                self.logger.error('g++ compiler not found. Please install it before ' + \
                 'using MadAnalysis 5')
                return False
            self.logger.debug("  which-all:     ")
            for file in result:
                self.logger.debug("    - " + str(file))

        # Getting the version
        ok, out, err = ShellCommand.ExecuteWithCapture(['g++', '-dumpversion'],
                                                       './')
        if not ok:
            self.logger.error('g++ compiler not found. Please install it before ' + \
             'using MadAnalysis 5')
            return False
        out = out.lstrip()
        out = out.rstrip()
        self.version = str(out)
        if self.debug:
            self.logger.debug("  version:       " + self.version)

        # Getting include path
        ok, out, err = ShellCommand.ExecuteWithCapture(
            ['g++', '-E', '-x', 'c++', '-', '-v'], './', stdin=True)
        if not ok:
            self.logger.warning('unexpected error with g++')
            return True
        toKeep = False
        self.header_paths = []
        self.library_paths = []
        for line in out.split('\n'):
            line = line.lstrip()
            line = line.rstrip()
            if line.startswith('#include <...>'):
                toKeep = True
                continue
            elif line.startswith('End of search list'):
                toKeep = False
            if toKeep:
                if os.path.isdir(line):
                    self.header_paths.append(os.path.normpath(line))
            if line.startswith('LIBRARY_PATH='):
                paths = line[13:].split(':')
                for path in paths:
                    if os.path.isdir(path):
                        self.library_paths.append(os.path.normpath(path))

        if self.debug:
            self.logger.debug("  search path for headers:")
            for line in self.header_paths:
                self.logger.debug('    - ' + line)
            self.logger.debug("  search path for libraries:")
            for line in self.library_paths:
                self.logger.debug('    - ' + line)

        # Ok
        return True