Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • fixadd
  • dfs
  • exp
  • workercrash
  • s-dev
  • dev
  • v0.10
  • v0.9
  • v0.8
  • v0.7
  • v0.6
  • v0.4
  • v0.3
  • v0.2
15 results

conf.py

Blame
  • it4i_module_naming_scheme.py 4.35 KiB
    #!/usr/bin/env python
    #
    #  Copyright (C) 2015 IT4Innovations
    #  Lumir Jasiok
    #  lumir.jasiok@vsb.cz
    #  http://www.it4i.cz
    #
    #
    
    import os
    
    from easybuild.tools.config import install_path
    from easybuild.tools.module_naming_scheme import ModuleNamingScheme
    
    
    class IT4IModuleNamingScheme(ModuleNamingScheme):
        """Class implementing an example module naming scheme."""
    
        REQUIRED_KEYS = []
    
        def det_install_subdir(self, ec):
            """
            Determine name of software installation subdirectory of install path.
            @param ec: dict-like object with easyconfig parameter values; for now
                        only the 'name', 'version', 'versionsuffix' and
                        'toolchain' parameters are guaranteed to be available
            @return: string with name of subdirectory, e.g.:
                        '<compiler>/<mpi_lib>/<name>/<version>'
            """
            # by default: use full module name as name for install subdir
    
            # fetch required values
            name = ec['name']
            version = ec['version']
            tc_name = ec['toolchain']['name']
            tc_version = ec['toolchain']['version']
            moduleclass = ec['moduleclass']
            version_suffix = ec['versionsuffix']
    
            if version_suffix != '':
                self.log.info("IT4I found version_suffix %s" % version_suffix)
            else:
                self.log.info("IT4I version_suffix not found")
    
            # Get the install path from configuration
            installpath = install_path()
            self.log.info("IT4I Install path for software is %s" % installpath)
            self.log.info("IT4I This application moduleclass is %s" % moduleclass)
            moduleclass_dir = os.path.join(installpath, moduleclass)
    
            if (tc_name == "dummy" and (tc_version == "dummy" or not tc_version)):
                self.software_full_version = version
                self.log.info("IT4I Software full name (dummy toolchain) is %s"
                              % self.software_full_version)
            else:
                self.software_full_version = version + "-" + tc_name + "-" \
                                             + tc_version
                self.log.info("IT4I Software full name is %s"
                              % self.software_full_version)
    
            if (version_suffix != ''):
                self.software_full_version += version_suffix
                self.log.info("IT4I Software full name (with version_suffix) is %s"
                              % self.software_full_version)
    
            if not os.path.isdir(moduleclass_dir):
                self.log.info("IT4I software moduleclass directory %s \
                               missing, creating" % moduleclass_dir)
                os.mkdir(moduleclass_dir)
    
            software_dir = os.path.join(moduleclass_dir, name)
            if not os.path.isdir(software_dir):
                self.log.info("IT4I software application directory %s \
                              missing, creating" % software_dir)
                os.mkdir(software_dir)
    
            symlink_path = os.path.join(software_dir, self.software_full_version)
            if not os.path.islink(symlink_path):
                self.log.info("IT4I Missing application symlink %s, creating"
                              % symlink_path)
                os.symlink(os.path.join(installpath, 'all', name, self.software_full_version), symlink_path)
            return os.path.join('all', name, self.software_full_version)
    
        def det_full_module_name(self, ec):
            """
            Determine full module name from given easyconfig, according to and
            example module naming scheme.
    
            @param ec: dict-like object with easyconfig parameter values
                        (e.g. 'name', 'version', etc.)
    
            @return: string representing full module name, e.g.:
                        'goolf/1.4.10/gzip/1.5'
            """
    
            # fetch required values
            name = ec['name']
            version = ec['version']
            tc_name = ec['toolchain']['name']
            tc_version = ec['toolchain']['version']
            version_suffix = ec['versionsuffix']
    
            if (tc_name == "dummy" and (tc_version == "dummy" or not tc_version)):
                self.module_full_version = version
            else:
                self.module_full_version = version + "-" + tc_name + "-" + tc_version
    
            if (version_suffix != ''):
                self.module_full_version += version_suffix
    
            self.log.debug("IT4I Full module name is %s"
                           % self.module_full_version)
    
            return os.path.join(name, self.module_full_version)