diff --git a/easybuild/easyblocks/h/hpcc.py b/easybuild/easyblocks/h/hpcc.py new file mode 100644 index 00000000000..57893788b22 --- /dev/null +++ b/easybuild/easyblocks/h/hpcc.py @@ -0,0 +1,81 @@ +## +# Copyright 2009-2023 Ghent University +# +# This file is part of EasyBuild, +# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), +# with support of Ghent University (http://ugent.be/hpc), +# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), +# Flemish Research Foundation (FWO) (http://www.fwo.be/en) +# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). +# +# https://github.com/easybuilders/easybuild +# +# EasyBuild is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation v2. +# +# EasyBuild is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with EasyBuild. If not, see . +## +""" +EasyBuild support for building and installing HPCC, implemented as an easyblock + +@author: Samuel Moors (Vrije Universiteit Brussel) +""" + +import os + +from easybuild.easyblocks.hpl import EB_HPL +from easybuild.tools.filetools import copy_file, mkdir + + +class EB_HPCC(EB_HPL): + """ + Support for building HPCC (HPC Challenge) + - create Make.UNKNOWN + - build with make and install + """ + + def configure_step(self): + """ + Create Make.UNKNOWN file to build from + """ + # the build script file should be created in the hpl subdir + super(EB_HPCC, self).configure_step(subdir='hpl') + + def build_step(self): + """ + Build with make and correct make options + """ + # TOPdir should always be ../../.. regardless of what it was in the HPL build script file + super(EB_HPCC, self).build_step(topdir='../../..') + + def install_step(self): + """ + Install by copying files to install dir + """ + srcdir = self.cfg['start_dir'] + destdir = os.path.join(self.installdir, 'bin') + mkdir(destdir) + for filename in ["hpcc", "_hpccinf.txt"]: + srcfile = os.path.join(srcdir, filename) + copy_file(srcfile, destdir) + + def sanity_check_step(self): + """ + Custom sanity check for HPL + """ + + custom_paths = { + 'files': ['bin/hpcc', 'bin/_hpccinf.txt'], + 'dirs': [] + } + + custom_commands = ['hpcc'] + + super(EB_HPL, self).sanity_check_step(custom_paths=custom_paths, custom_commands=custom_commands) diff --git a/easybuild/easyblocks/h/hpl.py b/easybuild/easyblocks/h/hpl.py index d408a7b05ed..3599b3004a7 100644 --- a/easybuild/easyblocks/h/hpl.py +++ b/easybuild/easyblocks/h/hpl.py @@ -33,10 +33,10 @@ """ import os -import shutil from easybuild.easyblocks.generic.configuremake import ConfigureMake from easybuild.tools.build_log import EasyBuildError +from easybuild.tools.filetools import change_dir, copy_file, mkdir, remove_file, symlink from easybuild.tools.run import run_cmd @@ -61,26 +61,22 @@ def configure_step(self, subdir=None): makeincfile = os.path.join(basedir, 'Make.UNKNOWN') setupdir = os.path.join(basedir, 'setup') - try: - os.chdir(setupdir) - except OSError as err: - raise EasyBuildError("Failed to change to to dir %s: %s", setupdir, err) + change_dir(setupdir) cmd = "/bin/bash make_generic" run_cmd(cmd, log_all=True, simple=True, log_output=True) - try: - os.symlink(os.path.join(setupdir, 'Make.UNKNOWN'), os.path.join(makeincfile)) - except OSError as err: - raise EasyBuildError("Failed to symlink Make.UNKNOWN from %s to %s: %s", setupdir, makeincfile, err) + remove_file(makeincfile) + symlink(os.path.join(setupdir, 'Make.UNKNOWN'), makeincfile) # go back - os.chdir(self.cfg['start_dir']) + change_dir(self.cfg['start_dir']) - def build_step(self): + def build_step(self, topdir=None): """ Build with make and correct make options + - provide topdir argument so this can be reused in HPCC easyblock """ for envvar in ['MPICC', 'LIBLAPACK_MT', 'CPPFLAGS', 'LDFLAGS', 'CFLAGS']: @@ -89,7 +85,9 @@ def build_step(self): raise EasyBuildError("Required environment variable %s not found (no toolchain used?).", envvar) # build dir - extra_makeopts = 'TOPdir="%s" ' % self.cfg['start_dir'] + if not topdir: + topdir = self.cfg['start_dir'] + extra_makeopts = 'TOPdir="%s" ' % topdir # compilers extra_makeopts += 'CC="%(mpicc)s" MPICC="%(mpicc)s" LINKER="%(mpicc)s" ' % {'mpicc': os.getenv('MPICC')} @@ -116,14 +114,10 @@ def install_step(self): """ srcdir = os.path.join(self.cfg['start_dir'], 'bin', 'UNKNOWN') destdir = os.path.join(self.installdir, 'bin') - srcfile = None - try: - os.makedirs(destdir) - for filename in ["xhpl", "HPL.dat"]: - srcfile = os.path.join(srcdir, filename) - shutil.copy2(srcfile, destdir) - except OSError as err: - raise EasyBuildError("Copying %s to installation dir %s failed: %s", srcfile, destdir, err) + mkdir(destdir) + for filename in ["xhpl", "HPL.dat"]: + srcfile = os.path.join(srcdir, filename) + copy_file(srcfile, destdir) def sanity_check_step(self): """