New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Easyblock for MCR (REVIEW) #623
Changes from all commits
138c75d
2c3d92d
0d15b2e
87f22db
8dfec4a
26b43e4
72078cc
5195bc9
8656dfc
218237a
2813a94
50c5ad5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
## | ||
# Copyright 2009-2015 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://vscentrum.be/nl/en), | ||
# the Hercules foundation (http://www.herculesstichting.be/in_English) | ||
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). | ||
# | ||
# http://github.com/hpcugent/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 <http://www.gnu.org/licenses/>. | ||
## | ||
""" | ||
EasyBuild support for installing MCR, implemented as an easyblock | ||
|
||
@author: Stijn De Weirdt (Ghent University) | ||
@author: Dries Verdegem (Ghent University) | ||
@author: Kenneth Hoste (Ghent University) | ||
@author: Pieter De Baets (Ghent University) | ||
@author: Jens Timmerman (Ghent University) | ||
@author: Fotis Georgatos (Uni.Lu, NTUA) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this a new easyblock? if so, you're the only author There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, it is taken from matlab easyblock, and heavily simplified, so I am not really the author..... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I somehow missed that. You're not the original author, sure, but since you have modified it to make it work for MCR, you should add yourself as an author here. |
||
@author: Balazs Hajgato (Vrije Universiteit Brussel) | ||
""" | ||
import re | ||
import os | ||
import shutil | ||
import stat | ||
|
||
from distutils.version import LooseVersion | ||
from easybuild.framework.easyblock import EasyBlock | ||
from easybuild.framework.easyconfig import CUSTOM | ||
from easybuild.tools.build_log import EasyBuildError | ||
from easybuild.tools.filetools import adjust_permissions, read_file, write_file | ||
from easybuild.tools.run import run_cmd | ||
|
||
|
||
class EB_MCR(EasyBlock): | ||
"""Support for installing MCR.""" | ||
|
||
def __init__(self, *args, **kwargs): | ||
"""Add extra config options specific to MCR.""" | ||
super(EB_MCR, self).__init__(*args, **kwargs) | ||
self.comp_fam = None | ||
self.configfilename = "my_installer_input.txt" | ||
self.subdir = '' | ||
|
||
@staticmethod | ||
def extra_options(): | ||
"""Custom easyconfig parameters for MCR.""" | ||
extra_vars = { | ||
'java_options': ['-Xmx256m', "$_JAVA_OPTIONS value set for install and in module file.", CUSTOM], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taken form Matlab easyblock, dunno why that was there chosen. I though that might be useful here as well... |
||
} | ||
return EasyBlock.extra_options(extra_vars) | ||
|
||
def configure_step(self): | ||
"""Configure MCR installation: create license file.""" | ||
|
||
configfile = os.path.join(self.builddir, self.configfilename) | ||
if LooseVersion(self.version) < LooseVersion('2015a'): | ||
shutil.copyfile(os.path.join(self.cfg['start_dir'], 'installer_input.txt'), configfile) | ||
config = read_file(configfile) | ||
config = re.sub(r"^# destinationFolder=.*", "destinationFolder=%s" % self.installdir, config, re.M) | ||
config = re.sub(r"^# agreeToLicense=.*", "agreeToLicense=Yes", config, re.M) | ||
config = re.sub(r"^# mode=.*", "mode=silent", config, re.M) | ||
else: | ||
config = '\n'.join([ | ||
"destinationFolder=%s" % self.installdir, | ||
"agreeToLicense=Yes", | ||
"mode=silent", | ||
]) | ||
|
||
write_file(configfile, config) | ||
|
||
self.log.debug("configuration file written to %s:\n %s", configfile, config) | ||
|
||
def build_step(self): | ||
"""No building of MCR, no sources available.""" | ||
pass | ||
|
||
def install_step(self): | ||
"""MCR install procedure using 'install' command.""" | ||
|
||
src = os.path.join(self.cfg['start_dir'], 'install') | ||
|
||
# make sure install script is executable | ||
adjust_permissions(src, 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 | ||
if 'DISPLAY' in os.environ: | ||
os.environ.pop('DISPLAY') | ||
|
||
if not '_JAVA_OPTIONS' in self.cfg['preinstallopts']: | ||
java_options = 'export _JAVA_OPTIONS="%s" && ' % self.cfg['java_options'] | ||
self.cfg['preinstallopts'] = java_options + self.cfg['preinstallopts'] | ||
|
||
configfile = "%s/%s" % (self.builddir, self.configfilename) | ||
cmd = "%s ./install -v -inputFile %s %s" % (self.cfg['preinstallopts'], configfile, self.cfg['installopts']) | ||
run_cmd(cmd, log_all=True, simple=True) | ||
|
||
# determine subdirectory (e.g. v84 (2014a, 2014b), v85 (2015a), ...) | ||
subdirs = os.listdir(self.installdir) | ||
if len(subdirs) == 1: | ||
self.subdir = subdirs[0] | ||
else: | ||
raise EasyBuildError("Found multiple subdirectories, don't know which one to pick: %s", subdirs) | ||
|
||
def sanity_check_step(self): | ||
"""Custom sanity check for MCR.""" | ||
custom_paths = { | ||
'files': [], | ||
'dirs': [os.path.join(self.subdir, x, 'glnxa64') for x in ['runtime', 'bin', 'sys/os']], | ||
} | ||
super(EB_MCR, self).sanity_check_step(custom_paths=custom_paths) | ||
|
||
def make_module_extra(self): | ||
"""Extend PATH and set proper _JAVA_OPTIONS (e.g., -Xmx).""" | ||
txt = super(EB_MCR, self).make_module_extra() | ||
|
||
xapplresdir = os.path.join(self.installdir, self.subdir, 'X11', 'app-defaults') | ||
txt += self.module_generator.set_environment('XAPPLRESDIR', xapplresdir) | ||
for ldlibdir in ['runtime', 'bin', os.path.join('sys', 'os')]: | ||
libdir = os.path.join(self.subdir, ldlibdir, 'glnxa64') | ||
txt += self.module_generator.prepend_paths('LD_LIBRARY_PATH', libdir) | ||
|
||
txt += self.module_generator.set_environment('_JAVA_OPTIONS', self.cfg['java_options']) | ||
|
||
return txt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2015-2015?