Exemple #1
0
    def prepare_step(self, *args, **kwargs):
        """Custom prepare step for LAMMPS."""
        super(EB_LAMMPS, self).prepare_step(*args, **kwargs)

        # Unset LIBS when using both KOKKOS and CUDA - it will mix lib paths otherwise
        if self.cfg['kokkos'] and get_software_root('CUDA'):
            env.unset_env_vars(['LIBS'])
Exemple #2
0
 def correct_mpich_build_env(self):
     """
     Method to correctly set the environment for MPICH and derivatives
     """
     env_vars = [
         'CFLAGS', 'CPPFLAGS', 'CXXFLAGS', 'FCFLAGS', 'FFLAGS', 'LDFLAGS',
         'LIBS'
     ]
     vars_to_unset = ['F90', 'F90FLAGS']
     for envvar in env_vars:
         envvar_val = os.getenv(envvar)
         if envvar_val:
             new_envvar = 'MPICHLIB_%s' % envvar
             new_envvar_val = os.getenv(new_envvar)
             vars_to_unset.append(envvar)
             if envvar_val == new_envvar_val:
                 self.log.debug("$%s == $%s, just defined $%s as empty",
                                envvar, new_envvar, envvar)
             elif new_envvar_val is None:
                 env.setvar(new_envvar, envvar_val)
             else:
                 raise EasyBuildError(
                     "Both $%s and $%s set, can I overwrite $%s with $%s (%s) ?",
                     envvar, new_envvar, new_envvar, envvar, envvar_val)
     env.unset_env_vars(vars_to_unset)
 def correct_mpich_build_env(self):
     """
     Method to correctly set the environment for MPICH and derivatives
     """
     env_vars = ["CFLAGS", "CPPFLAGS", "CXXFLAGS", "FCFLAGS", "FFLAGS", "LDFLAGS", "LIBS"]
     vars_to_unset = ["F90", "F90FLAGS"]
     for envvar in env_vars:
         envvar_val = os.getenv(envvar)
         if envvar_val:
             new_envvar = "MPICHLIB_%s" % envvar
             new_envvar_val = os.getenv(new_envvar)
             vars_to_unset.append(envvar)
             if envvar_val == new_envvar_val:
                 self.log.debug("$%s == $%s, just defined $%s as empty", envvar, new_envvar, envvar)
             elif new_envvar_val is None:
                 env.setvar(new_envvar, envvar_val)
             else:
                 raise EasyBuildError(
                     "Both $%s and $%s set, can I overwrite $%s with $%s (%s) ?",
                     envvar,
                     new_envvar,
                     new_envvar,
                     envvar,
                     envvar_val,
                 )
     env.unset_env_vars(vars_to_unset)
    def __init__(self, *args, **kwargs):
        """Initialize custom class variables."""
        super(PerlModule, self).__init__(*args, **kwargs)
        self.testcmd = None

        # Environment variables PERL_MM_OPT and PERL_MB_OPT cause installations to fail.
        # Therefore it is better to unset these variables.
        unset_env_vars(['PERL_MM_OPT', 'PERL_MB_OPT'])
Exemple #5
0
    def configure_step(self):
        """
        Custom configuration procedure for ParaStationMPI.
        * Sets the correct options
        * Calls the MPICH configure_step, disabling the default MPICH options
        """

        comp_opts = {
            toolchain.GCC: 'gcc',
            toolchain.INTELCOMP: 'intel',
            toolchain.PGI: 'pgi',
        }

        # ParaStationMPI defines its environment through confsets. So these should be unset
        env_vars = ['CFLAGS', 'CPPFLAGS', 'CXXFLAGS', 'FCFLAGS', 'FFLAGS', 'LDFLAGS', 'LIBS']
        env.unset_env_vars(env_vars)
        self.log.info("Unsetting the following variables: " + ' '.join(env_vars))

        # Enable CUDA
        if self.cfg['cuda']:
            self.log.info("Enabling CUDA-Awareness...")
            self.cfg.update('configopts', ' --with-cuda')

        # Set confset
        comp_fam = self.toolchain.comp_family()
        if comp_fam in comp_opts:
            self.cfg.update('configopts', ' --with-confset=%s' % comp_opts[comp_fam])
        else:
            raise EasyBuildError("Compiler %s not supported. Valid options are: %s",
                                 comp_fam, ', '.join(comp_opts.keys()))

        # Enable threading, if necessary
        if self.cfg['threaded']:
            self.cfg.update('configopts', ' --with-threading')

        # Add extra mpich options, if any
        if self.cfg['mpich_opts'] is not None:
            self.cfg.update('configopts', ' --with-mpichconf="%s"' % self.cfg['mpich_opts'])

        # Add PGO related options, if enabled
        if self.cfg['pgo']:
            self.cfg.update('configopts', ' --with-profile=gen --with-profdir=%s' % self.profdir)

        # Lastly, set pscom related variables
        if self.cfg['pscom_allin_path'] is None:
            pscom_path = get_software_root('pscom')
        else:
            pscom_path = self.cfg['pscom_allin_path'].strip()
            self.cfg.update('configopts', ' --with-pscom-allin="%s"' % pscom_path)

        pscom_flags = 'PSCOM_LDFLAGS=-L{0}/lib PSCOM_CPPFLAGS=-I{0}/include'.format(pscom_path)
        self.cfg.update('preconfigopts', pscom_flags)

        super(EB_psmpi, self).configure_step(add_mpich_configopts=False)
Exemple #6
0
    def install_step(self):
        """COMSOL install procedure using 'install' command."""

        setup_script = os.path.join(self.start_dir, 'setup')

        # make sure setup script is executable
        adjust_permissions(setup_script, stat.S_IXUSR)

        # make sure $DISPLAY is not defined, which may lead to (hard to trace) problems
        # this is a workaround for not being able to specify --nodisplay to the install scripts
        env.unset_env_vars(['DISPLAY'])

        cmd = ' '.join([self.cfg['preinstallopts'], setup_script, '-s', self.configfile, self.cfg['installopts']])
        run_cmd(cmd, log_all=True, simple=True)
    def install_step(self):
        """COMSOL install procedure using 'install' command."""

        setup_script = os.path.join(self.start_dir, 'setup')

        # make sure setup script is executable
        adjust_permissions(setup_script, stat.S_IXUSR)

        # make sure $DISPLAY is not defined, which may lead to (hard to trace) problems
        # this is a workaround for not being able to specify --nodisplay to the install scripts
        env.unset_env_vars(['DISPLAY'])

        cmd = ' '.join([self.cfg['preinstallopts'], setup_script, '-s', self.configfile, self.cfg['installopts']])
        run_cmd(cmd, log_all=True, simple=True)
Exemple #8
0
    def configure_step(self):
        """
        Configure Perl build: run ./Configure instead of ./configure with some different options
        """
        # avoid that $CPATH or $C_INCLUDE_PATH include an empty entry, since that makes Perl build fail miserably
        # see https://github.com/easybuilders/easybuild-easyconfigs/issues/8859
        for key in ['CPATH', 'C_INCLUDE_PATH']:
            value = os.getenv(key, None)
            if value is not None:
                paths = value.split(os.pathsep)
                if '' in paths:
                    self.log.info(
                        "Found empty entry in $%s, filtering it out...", key)
                    os.environ[key] = os.pathsep.join(p for p in paths if p)

        majver = self.version.split('.')[0]
        configopts = [
            self.cfg['configopts'],
            '-Dcc="{0}"'.format(os.getenv('CC')),
            '-Dccflags="{0}"'.format(os.getenv('CFLAGS')),
            '-Dinc_version_list=none',
            '-Dprefix=%(installdir)s',
            # guarantee that scripts are installed in /bin in the installation directory (and not in a guessed path)
            # see https://github.com/easybuilders/easybuild-easyblocks/issues/1659
            '-Dinstallscript=%(installdir)s/bin',
            '-Dscriptdir=%(installdir)s/bin',
            '-Dscriptdirexp=%(installdir)s/bin',
            # guarantee that the install directory has the form lib/perlX/
            # see https://github.com/easybuilders/easybuild-easyblocks/issues/1700
            "-Dinstallstyle='lib/perl%s'" % majver,
        ]
        if self.cfg['use_perl_threads']:
            configopts.append('-Dusethreads')

        # see https://metacpan.org/pod/distribution/perl/INSTALL#Specifying-a-logical-root-directory
        sysroot = build_option('sysroot')
        if sysroot:
            configopts.append('-Dsysroot=%s' % sysroot)

        configopts = (' '.join(configopts)) % {'installdir': self.installdir}

        # if $COLUMNS is set to 0, 'ls' produces a warning like:
        #   ls: ignoring invalid width in environment variable COLUMNS: 0
        # this confuses Perl's Configure script and makes it fail,
        # so just unset $COLUMNS if it set to 0...
        if os.getenv('COLUMNS', None) == '0':
            unset_env_vars(['COLUMNS'])

        cmd = './Configure -de %s' % configopts
        run_cmd(cmd, log_all=True, simple=True)
    def test_unset_env_vars(self):
        """Test unset_env_vars function."""

        os.environ['TEST_ENV_VAR'] = 'test123'
        # it's fair to assume $HOME will always be set
        home = os.getenv('HOME')
        self.assertTrue(home)

        key_not_set = 'NO_SUCH_ENV_VAR'
        if key_not_set in os.environ:
            del os.environ[key_not_set]

        res = env.unset_env_vars(['HOME', 'NO_SUCH_ENV_VAR', 'TEST_ENV_VAR'])

        self.assertFalse('HOME' in os.environ)
        self.assertFalse('NO_SUCH_ENV_VAR' in os.environ)
        self.assertFalse('TEST_ENV_VAR' in os.environ)

        expected = {
            'HOME': home,
            'TEST_ENV_VAR': 'test123',
        }
        self.assertEqual(res, expected)
Exemple #10
0
    def install_step(self):
        """Custom build, test & install procedure for Amber."""

        # unset $LIBS since it breaks the build
        env.unset_env_vars(['LIBS'])

        # define environment variables for MPI, BLAS/LAPACK & dependencies
        mklroot = get_software_root('imkl')
        openblasroot = get_software_root('OpenBLAS')
        if mklroot:
            env.setvar('MKL_HOME', mklroot)
        elif openblasroot:
            lapack = os.getenv('LIBLAPACK')
            if lapack is None:
                raise EasyBuildError(
                    "LIBLAPACK (from OpenBLAS) not found in environment.")
            else:
                env.setvar('GOTO', lapack)

        mpiroot = get_software_root(self.toolchain.MPI_MODULE_NAME[0])
        if mpiroot and self.toolchain.options.get('usempi', None):
            env.setvar('MPI_HOME', mpiroot)
            self.with_mpi = True
            if self.toolchain.mpi_family() == toolchain.INTELMPI:
                self.mpi_option = '-intelmpi'
            else:
                self.mpi_option = '-mpi'

        common_configopts = [self.cfg['configopts'], '--no-updates']

        if get_software_root('X11') is None:
            common_configopts.append('-noX11')

        if self.name == 'Amber' and self.cfg['static']:
            common_configopts.append('-static')

        netcdfroot = get_software_root('netCDF')
        if netcdfroot:
            common_configopts.extend(["--with-netcdf", netcdfroot])

        netcdf_fort_root = get_software_root('netCDF-Fortran')
        if netcdf_fort_root:
            common_configopts.extend(["--with-netcdf-fort", netcdf_fort_root])

        pythonroot = get_software_root('Python')
        if pythonroot:
            common_configopts.extend(
                ["--with-python",
                 os.path.join(pythonroot, 'bin', 'python')])

            self.pylibdir = det_pylibdir()
            pythonpath = os.environ.get('PYTHONPATH', '')
            env.setvar(
                'PYTHONPATH',
                os.pathsep.join(
                    [os.path.join(self.installdir, self.pylibdir),
                     pythonpath]))

        comp_fam = self.toolchain.comp_family()
        if comp_fam == toolchain.INTELCOMP:
            comp_str = 'intel'

        elif comp_fam == toolchain.GCC:
            comp_str = 'gnu'

        else:
            raise EasyBuildError(
                "Don't know how to compile with compiler family '%s' -- check EasyBlock?",
                comp_fam)

        # The NAB compiles need openmp flag
        if self.toolchain.options.get('openmp', None):
            env.setvar('CUSTOMBUILDFLAGS', self.toolchain.get_flag('openmp'))

        # compose list of build targets
        build_targets = [('', 'test')]

        if self.with_mpi:
            build_targets.append((self.mpi_option, 'test.parallel'))
            # hardcode to 4 MPI processes, minimal required to run all tests
            env.setvar('DO_PARALLEL', 'mpirun -np 4')

        cudaroot = get_software_root('CUDA')
        if cudaroot:
            env.setvar('CUDA_HOME', cudaroot)
            self.with_cuda = True
            build_targets.append(('-cuda', 'test.cuda'))
            if self.with_mpi:
                build_targets.append(
                    ("-cuda %s" % self.mpi_option, 'test.cuda_parallel'))

        ld_lib_path = os.environ.get('LD_LIBRARY_PATH', '')
        env.setvar(
            'LD_LIBRARY_PATH',
            os.pathsep.join(
                [os.path.join(self.installdir, 'lib'), ld_lib_path]))

        for flag, testrule in build_targets:
            # configure
            cmd = "%s ./configure %s" % (self.cfg['preconfigopts'],
                                         ' '.join(common_configopts +
                                                  [flag, comp_str]))
            (out, _) = run_cmd(cmd, log_all=True, simple=False)

            # build in situ using 'make install'
            # note: not 'build'
            super(EB_Amber, self).install_step()

            # test
            if self.cfg['runtest']:
                run_cmd("make %s" % testrule, log_all=True, simple=False)

            # clean, overruling the normal 'build'
            run_cmd("make clean")
    def install_step(self):
        """Custom build, test & install procedure for Amber."""

        # unset $LIBS since it breaks the build
        env.unset_env_vars(['LIBS'])

        # define environment variables for MPI, BLAS/LAPACK & dependencies
        mklroot = get_software_root('imkl')
        openblasroot = get_software_root('OpenBLAS')
        if mklroot:
            env.setvar('MKL_HOME', mklroot)
        elif openblasroot:
            lapack = os.getenv('LIBLAPACK')
            if lapack is None:
                raise EasyBuildError("LIBLAPACK (from OpenBLAS) not found in environment.")
            else:
                env.setvar('GOTO', lapack)

        mpiroot = get_software_root(self.toolchain.MPI_MODULE_NAME[0])
        if mpiroot and self.toolchain.options.get('usempi', None):
            env.setvar('MPI_HOME', mpiroot)
            self.with_mpi = True
            if self.toolchain.mpi_family() == toolchain.INTELMPI:
                self.mpi_option = '-intelmpi'
            else:
                self.mpi_option = '-mpi'

        common_configopts = [self.cfg['configopts'], '--no-updates']

        if get_software_root('X11') is None:
            common_configopts.append('-noX11')

        if self.name == 'Amber' and self.cfg['static']:
            common_configopts.append('-static')

        netcdfroot = get_software_root('netCDF')
        if netcdfroot:
            common_configopts.extend(["--with-netcdf", netcdfroot])

        netcdf_fort_root = get_software_root('netCDF-Fortran')
        if netcdf_fort_root:
            common_configopts.extend(["--with-netcdf-fort", netcdf_fort_root])

        pythonroot = get_software_root('Python')
        if pythonroot:
            common_configopts.extend(["--with-python", os.path.join(pythonroot, 'bin', 'python')])

            self.pylibdir = det_pylibdir()
            pythonpath = os.environ.get('PYTHONPATH', '')
            env.setvar('PYTHONPATH', os.pathsep.join([os.path.join(self.installdir, self.pylibdir), pythonpath]))

        comp_fam = self.toolchain.comp_family()
        if comp_fam == toolchain.INTELCOMP:
            comp_str = 'intel'

        elif comp_fam == toolchain.GCC:
            comp_str = 'gnu'

        else:
            raise EasyBuildError("Don't know how to compile with compiler family '%s' -- check EasyBlock?", comp_fam)

        # The NAB compiles need openmp flag
        if self.toolchain.options.get('openmp', None):
            env.setvar('CUSTOMBUILDFLAGS', self.toolchain.get_flag('openmp'))

        # compose list of build targets
        build_targets = [('', 'test')]

        if self.with_mpi:
            build_targets.append((self.mpi_option, 'test.parallel'))
            # hardcode to 4 MPI processes, minimal required to run all tests
            env.setvar('DO_PARALLEL', 'mpirun -np 4')

        cudaroot = get_software_root('CUDA')
        if cudaroot:
            env.setvar('CUDA_HOME', cudaroot)
            self.with_cuda = True
            build_targets.append(('-cuda', 'test.cuda'))
            if self.with_mpi:
                build_targets.append(("-cuda %s" % self.mpi_option, 'test.cuda_parallel'))

        ld_lib_path = os.environ.get('LD_LIBRARY_PATH', '')
        env.setvar('LD_LIBRARY_PATH', os.pathsep.join([os.path.join(self.installdir, 'lib'), ld_lib_path]))

        for flag, testrule in build_targets:
            # configure
            cmd = "%s ./configure %s" % (self.cfg['preconfigopts'], ' '.join(common_configopts + [flag, comp_str]))
            (out, _) = run_cmd(cmd, log_all=True, simple=False)

            # build in situ using 'make install'
            # note: not 'build'
            super(EB_Amber, self).install_step()

            # test
            if self.cfg['runtest']:
                run_cmd("make %s" % testrule, log_all=True, simple=False)

            # clean, overruling the normal 'build'
            run_cmd("make clean")