Exemplo n.º 1
0
def architecture():
    """Detect the host's architecture.
        
    Mostly relies on Python's platform module but may also probe 
    environment variables and file systems in cases where the arch 
    isn't immediately known to Python.  These tests may be expensive
    so the detected value is cached to improve performance. 
    
    Returns:
        Architecture: The matching architecture description.
        
    Raises:
        ConfigurationError: Host architecture not supported.
    """
    try:
        inst = architecture.inst
    except AttributeError:
        if os.path.exists("/bgsys/drivers/ppcfloor/gnu-linux/bin/powerpc-bgp-linux-gcc"):
            inst = IBM_BGP_ARCH
        elif os.path.exists("/bgsys/drivers/ppcfloor/gnu-linux/bin/powerpc64-bgq-linux-gcc"):
            inst = IBM_BGQ_ARCH
        else:
            python_arch = platform.machine()
            try:
                inst = Architecture.find(python_arch)
            except KeyError:
                raise ConfigurationError("Host architecture '%s' is not yet supported" % python_arch)
        architecture.inst = inst
    return inst
Exemplo n.º 2
0
 def __init__(self, name, prefix, src, dst, target_arch, target_os, compilers, 
              sources, commands, libraries):
     """Initializes the installation object.
     
     To set up a new installation, pass `src` as a URL, file path, or the special keyword 'download'.
     Attributes `src` and `src_prefix` will be set to the appropriate paths.
     
     To set up an interface to an existing installation, pass ``src=/path/to/existing/installation``. 
     Attributes `src` and `src_prefix` will be set to None.
     
     Args:
         name (str): Human readable name of the software package, e.g. 'TAU'.
         prefix (str): Path to a directory to contain subdirectories for 
                       installation files, source file, and compilation files.
         src (str): Path to a directory where the software has already been 
                    installed, or a path to a source archive file, or the special
                    keyword 'download'.
         dst (str): Installation destination to be created below `prefix`.
         target_arch (str): Target architecture name.
         target_os (str): Target operating system name.
         compilers (InstalledCompilerSet): Compilers to use if software must be compiled.
         sources (dict): Dictionary of URLs for source code archives indexed by architecture and OS.  
                         `None` specifies the default (i.e. universal) source.
         commands (dict): Dictionary of commands that must be installed indexed by architecture and OS.
                          `None` specifies the universal commands.
         libraries (dict): Dictionary of libraries that must be installed indexed by architecture and OS.
                           `None` specifies the universal libraries.
     """
     self.name = name
     self.prefix = prefix
     self.target_arch = Architecture.find(target_arch)
     self.target_os = OperatingSystem.find(target_os)
     self.compilers = compilers
     self.archive_prefix = os.path.join(prefix, 'src')
     self.src_prefix = None
     if os.path.isdir(src):
         self.src = None
         self.install_prefix = src
     else:
         if src.lower() == 'download':
             self.src = self._lookup_target_os_list(sources)
         else:
             self.src = src
         md5sum = hashlib.md5()
         md5sum.update(self.src)
         self.install_prefix = os.path.join(prefix, dst, name, md5sum.hexdigest())
     self.commands = self._lookup_target_os_list(commands)
     self.libraries = self._lookup_target_os_list(libraries)
     self.include_path = os.path.join(self.install_prefix, 'include')
     self.bin_path = os.path.join(self.install_prefix, 'bin')
     self.lib_path = os.path.join(self.install_prefix, 'lib')
     self._lockfile = LockFile(os.path.join(self.install_prefix, '.tau_lock'))
     LOGGER.debug("%s installation prefix is %s", self.name, self.install_prefix)