Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions easybuild/easyblocks/generic/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
from easybuild.tools.run import run_cmd


PREPEND_TO_PATH_DEFAULT = ['']

class Binary(EasyBlock):
"""
Support for installing software that comes in binary form.
Expand All @@ -58,6 +60,9 @@ def extra_options(extra_vars=None):
'install_cmd': [None, "Install command to be used.", CUSTOM],
# staged installation can help with the hard (potentially faulty) check on available disk space
'staged_install': [False, "Perform staged installation via subdirectory of build directory", CUSTOM],
'prepend_to_path': [PREPEND_TO_PATH_DEFAULT, "Prepend the given directories (relative to install-dir) to "
"the environment variable PATH in the module file. Default "
"is the install-dir itself.", CUSTOM],
})
return extra_vars

Expand All @@ -66,7 +71,7 @@ def __init__(self, *args, **kwargs):
super(Binary, self).__init__(*args, **kwargs)

self.actual_installdir = None
if self.cfg['staged_install']:
if self.cfg.get('staged_install', False):
self.actual_installdir = self.installdir
self.installdir = os.path.join(self.builddir, 'staged')
mkdir(self.installdir, parents=True)
Expand Down Expand Up @@ -97,21 +102,22 @@ def build_step(self):

def install_step(self):
"""Copy all files in build directory to the install directory"""
if self.cfg['install_cmd'] is None:
install_cmd = self.cfg.get('install_cmd', None)
if install_cmd is None:
try:
# shutil.copytree doesn't allow the target directory to exist already
rmtree2(self.installdir)
shutil.copytree(self.cfg['start_dir'], self.installdir, symlinks=self.cfg['keepsymlinks'])
except OSError, err:
raise EasyBuildError("Failed to copy %s to %s: %s", self.cfg['start_dir'], self.installdir, err)
else:
cmd = ' '.join([self.cfg['preinstallopts'], self.cfg['install_cmd'], self.cfg['installopts']])
cmd = ' '.join([self.cfg['preinstallopts'], install_cmd, self.cfg['installopts']])
self.log.info("Installing %s using command '%s'..." % (self.name, cmd))
run_cmd(cmd, log_all=True, simple=True)

def post_install_step(self):
"""Copy installation to actual installation directory in case of a staged installation."""
if self.cfg['staged_install']:
if self.cfg.get('staged_install', False):
staged_installdir = self.installdir
self.installdir = self.actual_installdir
try:
Expand All @@ -131,9 +137,11 @@ def sanity_check_rpath(self):
self.__class__.__name__)

def make_module_extra(self):
"""Add the install directory to the PATH."""
"""Add the specified directories to the PATH."""

txt = super(Binary, self).make_module_extra()
txt += self.module_generator.prepend_paths("PATH", [''])
prepend_to_path = self.cfg.get('prepend_to_path', PREPEND_TO_PATH_DEFAULT)
if prepend_to_path:
txt += self.module_generator.prepend_paths("PATH", prepend_to_path)
self.log.debug("make_module_extra added this: %s" % txt)
return txt