def install_step(self): """Install CUDA using Perl install script.""" # define how to run the installer # script has /usr/bin/perl hardcoded, but we want to have control over which perl is being used if LooseVersion(self.version) <= LooseVersion("5"): install_interpreter = "perl" install_script = "install-linux.pl" self.cfg.update('installopts', '--prefix=%s' % self.installdir) elif LooseVersion(self.version) > LooseVersion("5") and LooseVersion(self.version) < LooseVersion("10.1"): install_interpreter = "perl" install_script = "cuda-installer.pl" # note: also including samples (via "-samplespath=%(installdir)s -samples") would require libglut self.cfg.update('installopts', "-verbose -silent -toolkitpath=%s -toolkit" % self.installdir) else: install_interpreter = "" install_script = "./cuda-installer" # note: also including samples (via "-samplespath=%(installdir)s -samples") would require libglut self.cfg.update('installopts', "--silent --toolkit --toolkitpath=%s --defaultroot=%s" % ( self.installdir, self.installdir)) cmd = "%(preinstallopts)s %(interpreter)s %(script)s %(installopts)s" % { 'preinstallopts': self.cfg['preinstallopts'], 'interpreter': install_interpreter, 'script': install_script, 'installopts': self.cfg['installopts'] } # prepare for running install script autonomously qanda = {} stdqa = { # this question is only asked if CUDA tools are already available system-wide r"Would you like to remove all CUDA files under .*? (yes/no/abort): ": "no", } noqanda = [ r"^Configuring", r"Installation Complete", r"Verifying archive integrity.*", r"^Uncompressing NVIDIA CUDA", r".* -> .*", ] # patch install script to handle Q&A autonomously if install_interpreter == "perl": patch_perl_script_autoflush(os.path.join(self.builddir, install_script)) # make sure $DISPLAY is not defined, which may lead to (weird) problems # this is workaround for not being able to specify --nox11 to the Perl install scripts if 'DISPLAY' in os.environ: os.environ.pop('DISPLAY') # overriding maxhits default value to 300 (300s wait for nothing to change in the output without seeing a known # question) run_cmd_qa(cmd, qanda, std_qa=stdqa, no_qa=noqanda, log_all=True, simple=True, maxhits=300) # check if there are patches to apply if len(self.src) > 1: for patch in self.src[1:]: self.log.debug("Running patch %s", patch['name']) run_cmd("/bin/sh " + patch['path'] + " --accept-eula --silent --installdir=" + self.installdir)
def install_step(self): """Install CUDA using Perl install script.""" # define how to run the installer # script has /usr/bin/perl hardcoded, but we want to have control over which perl is being used if LooseVersion(self.version) <= LooseVersion("5"): install_script = "install-linux.pl" install_script_path = os.path.join(self.builddir, install_script) cmd = "perl ./%s --prefix=%s" % (install_script, self.installdir) else: # the following would require to include "osdependencies = 'libglut'" because of samples # installparams = "-samplespath=%(x)s/samples/ -toolkitpath=%(x)s -samples -toolkit" % {'x': self.installdir} install_script = "cuda-installer.pl" installparams = "-toolkitpath=%s -toolkit" % self.installdir cmd = "perl ./%s -verbose -silent %s" % (install_script, installparams) # prepare for running install script autonomously qanda = {} stdqa = { # this question is only asked if CUDA tools are already available system-wide r"Would you like to remove all CUDA files under .*? (yes/no/abort): ": "no", } noqanda = [r"Installation Complete"] # patch install script to handle Q&A autonomously patch_perl_script_autoflush(os.path.join(self.builddir, install_script)) # make sure $DISPLAY is not defined, which may lead to (weird) problems # this is workaround for not being able to specify --nox11 to the Perl install scripts if 'DISPLAY' in os.environ: os.environ.pop('DISPLAY') run_cmd_qa(cmd, qanda, std_qa=stdqa, no_qa=noqanda, log_all=True, simple=True)
def install_step(self): """Install CUDA using Perl install script.""" # define how to run the installer # script has /usr/bin/perl hardcoded, but we want to have control over which perl is being used if LooseVersion(self.version) <= LooseVersion("5"): install_interpreter = "perl" install_script = "install-linux.pl" self.cfg.update('installopts', '--prefix=%s' % self.installdir) elif LooseVersion(self.version) > LooseVersion("5") and LooseVersion(self.version) < LooseVersion("10.1"): install_interpreter = "perl" install_script = "cuda-installer.pl" # note: also including samples (via "-samplespath=%(installdir)s -samples") would require libglut self.cfg.update('installopts', "-verbose -silent -toolkitpath=%s -toolkit" % self.installdir) else: install_interpreter = "" install_script = "./cuda-installer" # note: also including samples (via "-samplespath=%(installdir)s -samples") would require libglut self.cfg.update('installopts', "--silent --toolkit --toolkitpath=%s --defaultroot=%s" % ( self.installdir, self.installdir)) cmd = "%(preinstallopts)s %(interpreter)s %(script)s %(installopts)s" % { 'preinstallopts': self.cfg['preinstallopts'], 'interpreter': install_interpreter, 'script': install_script, 'installopts': self.cfg['installopts'] } # prepare for running install script autonomously qanda = {} stdqa = { # this question is only asked if CUDA tools are already available system-wide r"Would you like to remove all CUDA files under .*? (yes/no/abort): ": "no", } noqanda = [ r"^Configuring", r"Installation Complete", r"Verifying archive integrity.*", r"^Uncompressing NVIDIA CUDA", r".* -> .*", ] # patch install script to handle Q&A autonomously if install_interpreter == "perl": patch_perl_script_autoflush(os.path.join(self.builddir, install_script)) # make sure $DISPLAY is not defined, which may lead to (weird) problems # this is workaround for not being able to specify --nox11 to the Perl install scripts if 'DISPLAY' in os.environ: os.environ.pop('DISPLAY') # overriding maxhits default value to 300 (300s wait for nothing to change in the output without seeing a known # question) run_cmd_qa(cmd, qanda, std_qa=stdqa, no_qa=noqanda, log_all=True, simple=True, maxhits=300) # check if there are patches to apply if len(self.src) > 1: for patch in self.src[1:]: self.log.debug("Running patch %s", patch['name']) run_cmd("/bin/sh " + patch['path'] + " --accept-eula --silent --installdir=" + self.installdir)
def install_step(self): run_cmd("mkdir -p " + self.installdir) # define how to run the installer if LooseVersion(self.version) <= LooseVersion("5"): install_script = os.path.join(self.builddir, "install-linux.pl") cmd = install_script + " --prefix=" + self.installdir else: # the following would require to include "osdependencies = 'libglut'" because of -samples # installparams = "-samplespath=%s/samples/ -toolkitpath=%s -samples -toolkit" % (self.installdir, self.installdir)) installparams = "-toolkitpath=%s -toolkit" % self.installdir install_script = os.path.join(self.builddir, "cuda-installer.pl") cmd = install_script + " -verbose -silent " + installparams qanda = {} stdqa = { "Would you like to remove all CUDA files under .*? (yes/no/abort): ": "no", } noqanda = [r"Installation Complete"] # patch install script to handle Q&A autonomously patch_perl_script_autoflush(install_script) run_cmd_qa(cmd, qanda, std_qa=stdqa, no_qa=noqanda, log_all=True, simple=True) # FIXME (kehoste): what is this about? why chmod the installdir?!? try: os.chmod(self.installdir, stat.S_IRWXU | stat.S_IXOTH | stat.S_IXGRP | stat.S_IROTH | stat.S_IRGRP) except OSError, err: self.log.exception("Can't set permissions on %s: %s" % (self.installdir, err))
def install_step(self): """Custom install procedure for RepeatMasker.""" super(EB_RepeatMasker, self).install_step() # check for required dependencies perl_root = get_software_root('Perl') if perl_root: perl = os.path.join(perl_root, 'bin', 'perl') else: raise EasyBuildError("Missing required dependency: Perl") trf_root = get_software_root('TRF') if trf_root: trf = os.path.join(trf_root, 'trf') else: raise EasyBuildError("Missing required dependency: TRF") # determine which search engine to use # see also http://www.repeatmasker.org/RMDownload.html cand_search_engines = ['CrossMatch', 'RMBlast', 'WUBlast', 'HMMER'] search_engine = None for dep in cand_search_engines: if get_software_root(dep): if search_engine is None: search_engine = dep else: raise EasyBuildError("Found multiple candidate search engines: %s and %s", search_engine, dep) if search_engine is None: raise EasyBuildError("No search engine found, one of these must be included as dependency: %s", ' '.join(cand_search_engines)) change_dir(self.installdir) patch_perl_script_autoflush('configure') search_engine_map = { 'CrossMatch': '1', 'RMBlast': '2', 'WUBlast': '3', 'HMMER': '4', } search_engine_bindir = os.path.join(get_software_root(search_engine), 'bin') cmd = "perl ./configure" qa = { '<PRESS ENTER TO CONTINUE>': '', # select search engine 'Enter Selection:': search_engine_map[search_engine], } std_qa = { r'\*\*PERL PROGRAM\*\*\n([^*]*\n)+Enter path.*': perl, r'\*\*REPEATMASKER INSTALLATION DIRECTORY\*\*\n([^*]*\n)+Enter path.*': self.installdir, r'\*\*TRF PROGRAM\*\*\n([^*]*\n)+Enter path.*': trf, # search engine installation path (location of /bin subdirectory) # also enter 'Y' to confirm + '5' ("Done") to complete selection process for search engine r'\*\*.* INSTALLATION PATH\*\*\n([^*]*\n)+Enter path.*': search_engine_bindir + '\nY\n5', } run_cmd_qa(cmd, qa, std_qa=std_qa, log_all=True, simple=True, log_ok=True)
def install_step(self): """Install CUDA using Perl install script.""" # define how to run the installer # script has /usr/bin/perl hardcoded, but we want to have control over which perl is being used if LooseVersion(self.version) <= LooseVersion("5"): install_script = "install-linux.pl" install_script_path = os.path.join(self.builddir, install_script) cmd = "perl ./%s --prefix=%s %s" % ( install_script, self.installdir, self.cfg['installopts']) else: # the following would require to include "osdependencies = 'libglut'" because of samples # installparams = "-samplespath=%(x)s/samples/ -toolkitpath=%(x)s -samples -toolkit" % {'x': self.installdir} install_script = "cuda-installer.pl" installparams = "-toolkitpath=%s -toolkit" % self.installdir cmd = "perl ./%s -verbose -silent %s %s" % ( install_script, installparams, self.cfg['installopts']) # prepare for running install script autonomously qanda = {} stdqa = { # this question is only asked if CUDA tools are already available system-wide r"Would you like to remove all CUDA files under .*? (yes/no/abort): ": "no", } noqanda = [ r"^Configuring", r"Installation Complete", r"Verifying archive integrity.*", r"^Uncompressing NVIDIA CUDA", r".* -> .*", ] # patch install script to handle Q&A autonomously patch_perl_script_autoflush(os.path.join(self.builddir, install_script)) # make sure $DISPLAY is not defined, which may lead to (weird) problems # this is workaround for not being able to specify --nox11 to the Perl install scripts if 'DISPLAY' in os.environ: os.environ.pop('DISPLAY') #overriding maxhits default value to 300 (300s wait for nothing to change in the output without seeing a known question) run_cmd_qa(cmd, qanda, std_qa=stdqa, no_qa=noqanda, log_all=True, simple=True, maxhits=300)
def test_patch_perl_script_autoflush(self): """Test patching Perl script for autoflush.""" fh, fp = tempfile.mkstemp() os.close(fh) perl_lines = ["$!/usr/bin/perl", "use strict;", "print hello", "", "print hello again"] perltxt = "\n".join(perl_lines) ft.write_file(fp, perltxt) ft.patch_perl_script_autoflush(fp) txt = ft.read_file(fp) self.assertTrue(len(txt.split("\n")) == len(perl_lines) + 4) self.assertTrue(txt.startswith(perl_lines[0] + "\n\nuse IO::Handle qw();\nSTDOUT->autoflush(1);")) for line in perl_lines[1:]: self.assertTrue(line in txt) os.remove(fp) os.remove("%s.eb.orig" % fp)
def install_step(self): run_cmd("mkdir -p " + self.installdir) # define how to run the installer if LooseVersion(self.version) <= LooseVersion("5"): install_script = os.path.join(self.builddir, "install-linux.pl") cmd = install_script + " --prefix=" + self.installdir else: # the following would require to include "osdependencies = 'libglut'" because of -samples # installparams = "-samplespath=%s/samples/ -toolkitpath=%s -samples -toolkit" % (self.installdir, self.installdir)) installparams = "-toolkitpath=%s -toolkit" % self.installdir install_script = os.path.join(self.builddir, "cuda-installer.pl") cmd = install_script + " -verbose -silent " + installparams qanda = {} stdqa = { "Would you like to remove all CUDA files under .*? (yes/no/abort): ": "no", } noqanda = [r"Installation Complete"] # patch install script to handle Q&A autonomously patch_perl_script_autoflush(install_script) run_cmd_qa(cmd, qanda, std_qa=stdqa, no_qa=noqanda, log_all=True, simple=True) # FIXME (kehoste): what is this about? why chmod the installdir?!? try: os.chmod( self.installdir, stat.S_IRWXU | stat.S_IXOTH | stat.S_IXGRP | stat.S_IROTH | stat.S_IRGRP) except OSError, err: self.log.exception("Can't set permissions on %s: %s" % (self.installdir, err))
def test_patch_perl_script_autoflush(self): """Test patching Perl script for autoflush.""" fh, fp = tempfile.mkstemp() os.close(fh) perl_lines = [ "$!/usr/bin/perl", "use strict;", "print hello", "", "print hello again", ] perltxt = '\n'.join(perl_lines) ft.write_file(fp, perltxt) ft.patch_perl_script_autoflush(fp) txt = ft.read_file(fp) self.assertTrue(len(txt.split('\n')) == len(perl_lines) + 4) self.assertTrue(txt.startswith(perl_lines[0] + "\n\nuse IO::Handle qw();\nSTDOUT->autoflush(1);")) for line in perl_lines[1:]: self.assertTrue(line in txt) os.remove(fp) os.remove("%s.eb.orig" % fp)
else: self.log.error("JasPer module not loaded?") # patch ungrib Makefile so that JasPer is found fn = os.path.join("ungrib", "src", "Makefile") jasperlibs = "%s -ljasper %s -lpng" % (jasperlib, libpnglib) try: for line in fileinput.input(fn, inplace=1, backup='.orig.JasPer'): line = re.sub(r"^(\s*-L\.\s*-l\$\(LIBTARGET\))(\s*;.*)$", r"\1 %s\2" % jasperlibs, line) line = re.sub(r"^(\s*\$\(COMPRESSION_LIBS\))(\s*;.*)$", r"\1 %s\2" % jasperlibs, line) sys.stdout.write(line) except IOError, err: self.log.error("Failed to patch %s: %s" % (fn, err)) # patch arch/Config.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join("arch", "Config.pl")) # configure # determine build type option to look for self.comp_fam = self.toolchain.comp_family() build_type_option = None if LooseVersion(self.version) >= LooseVersion("3.4"): knownbuildtypes = { 'smpar': 'serial', 'dmpar': 'dmpar' } if self.comp_fam == toolchain.INTELCOMP: #@UndefinedVariable
def install_step(self): """Custom install procedure for RepeatModeler.""" super(EB_RepeatModeler, self).install_step() # Required dependencies, and bin path relative to software root required_deps = { 'CD-HIT': 'bin', 'Kent_tools': 'bin', 'Perl': os.path.join('bin', 'perl'), 'RECON': 'bin', 'RepeatMasker': '', 'RepeatScout': '', 'TRF': os.path.join('bin', 'trf'), } # Search engines, and bin path relative to software root search_engines = { 'ABBlast': 'bin', 'RMBlast': 'bin', 'WUBlast': 'bin', } # Optional dependencies for LTR pipeline, and bin path relative to software root optional_LTR_deps = { 'GenomeTools': 'bin', 'LTR_retriever': '', 'MAFFT': 'bin', 'TWL-NINJA': 'bin', } for dep, path in required_deps.items(): required_deps[dep] = get_dep_path(dep, path, log=self.log, optional=False) for dep, path in search_engines.items(): search_engines[dep] = get_dep_path(dep, path, log=self.log, optional=True) for dep, path in optional_LTR_deps.items(): optional_LTR_deps[dep] = get_dep_path(dep, path, log=self.log, optional=True) # Check at least one search engine is present, and not both ABBlast/WUBlast if not any(search_engines.values()): raise EasyBuildError("At least one search engine must be specified: RMBlast, ABBlast, WUBlast") elif search_engines['ABBlast'] and search_engines['WUBlast']: raise EasyBuildError("Cannot specify both ABBlast and WUBlast") # Check if all LTR Pipeline dependencies present if all(optional_LTR_deps.values()): self.log.info("All LTR pipeline dependencies found, enabling LTR support") with_LTR = 'y' else: self.log.info("Not all LTR pipeline dependencies found, disabling LTR support") with_LTR = 'n' # Map search engine to configuration option search_engine_map = { 'ABBlast': '2', 'RMBlast': '1', 'WUBlast': '2', } # List of search engines to use (mapped) mapped_engines = [search_engine_map[k] for k, v in search_engines.items() if v] + ['3'] change_dir(self.installdir) # Fix perl shebang in configure script (#!/usr/local/bin/perl) orig_fix_perl_shebang_for = self.cfg['fix_perl_shebang_for'] self.cfg['fix_perl_shebang_for'] = [os.path.join(self.installdir, 'configure')] self.fix_shebang() self.cfg['fix_perl_shebang_for'] = orig_fix_perl_shebang_for patch_perl_script_autoflush('configure') qa = { '<PRESS ENTER TO CONTINUE>': '', } std_qa = { r'\*\*PERL INSTALLATION PATH\*\*\n\n[^*]*\n+Enter path.*:\s*': required_deps['Perl'], r'UCSCTOOLS_DIR.*:\s*': required_deps['Kent_tools'], r'LTR_RETRIEVER_DIR.*:\s*': optional_LTR_deps['LTR_retriever'], r'RMBLAST_DIR.*:\s*': search_engines['RMBlast'], r'ABBLAST_DIR.*:\s*': search_engines['ABBlast'] or search_engines['WUBlast'], # Configure first engine r'.*(\[ Un\-configured \]\n.*){2}\n.*\n+Enter Selection\:\s*': mapped_engines[0], # Configure second engine if multiple specified, otherwise skip r'.*(\[ Un\-configured \]\n.*\[ Configured \]|\[ Configured \]\n.*\[ Un-configured \])' r'\n\n.*\n+Enter Selection\:\s*': mapped_engines[1], # All engines configured r'.*(\[ Configured \]\n.*){2}\n.*\n+Enter Selection\:\s*': '3', # LTR r'LTR.*\[optional](.*\n)*of analysis \[y] or n\?\:\s*': with_LTR, } cmdopts = ' ' + ' '.join([ '-trf_prgm "%(TRF)s"', '-repeatmasker_dir "%(RepeatMasker)s"', '-rscout_dir "%(RepeatScout)s"', '-recon_dir "%(RECON)s"', '-ucsctools_dir "%(Kent_tools)s"', '-cdhit_dir "%(CD-HIT)s"', ]) % required_deps if with_LTR: cmdopts += ' ' + ' '.join([ '-mafft_dir "%(MAFFT)s"', '-genometools_dir "%(GenomeTools)s"', '-ltr_retriever_dir "%(LTR_retriever)s"', '-ninja_dir "%(TWL-NINJA)s"', ]) % optional_LTR_deps cmd = "perl ./configure" + cmdopts run_cmd_qa(cmd, qa, std_qa=std_qa, log_all=True, simple=True, log_ok=True, maxhits=100)
def configure_step(self): """Configure build: - set some magic environment variables - run configure script - adjust configure.wrf file if needed """ wrfdir = os.path.join(self.builddir, self.wrfsubdir) # define $NETCDF* for netCDF dependency (used when creating WRF module file) set_netcdf_env_vars(self.log) # HDF5 (optional) dependency hdf5 = get_software_root('HDF5') if hdf5: env.setvar('HDF5', hdf5) # check if this is parallel HDF5 phdf5_bins = ['h5pcc', 'ph5diff'] parallel_hdf5 = True for f in phdf5_bins: if not os.path.exists(os.path.join(hdf5, 'bin', f)): parallel_hdf5 = False break if parallel_hdf5: env.setvar('PHDF5', hdf5) else: self.log.info( "Parallel HDF5 module not loaded, assuming that's OK...") else: self.log.info("HDF5 module not loaded, assuming that's OK...") # Parallel netCDF (optional) dependency pnetcdf = get_software_root('PnetCDF') if pnetcdf: env.setvar('PNETCDF', pnetcdf) # JasPer dependency check + setting env vars jasper = get_software_root('JasPer') if jasper: jasperlibdir = os.path.join(jasper, "lib") env.setvar('JASPERINC', os.path.join(jasper, "include")) env.setvar('JASPERLIB', jasperlibdir) else: if os.getenv('JASPERINC') or os.getenv('JASPERLIB'): raise EasyBuildError( "JasPer module not loaded, but JASPERINC and/or JASPERLIB still set?" ) else: self.log.info( "JasPer module not loaded, assuming that's OK...") # enable support for large file support in netCDF env.setvar('WRFIO_NCD_LARGE_FILE_SUPPORT', '1') # patch arch/Config_new.pl script, so that run_cmd_qa receives all output to answer questions if LooseVersion(self.version) < LooseVersion('4.0'): patch_perl_script_autoflush( os.path.join(wrfdir, "arch", "Config_new.pl")) # determine build type option to look for build_type_option = None self.comp_fam = self.toolchain.comp_family() if self.comp_fam == toolchain.INTELCOMP: # @UndefinedVariable if LooseVersion(self.version) >= LooseVersion('3.7'): build_type_option = "INTEL\ \(ifort\/icc\)" else: build_type_option = "Linux x86_64 i486 i586 i686, ifort compiler with icc" elif self.comp_fam == toolchain.GCC: # @UndefinedVariable if LooseVersion(self.version) >= LooseVersion('3.7'): build_type_option = "GNU\ \(gfortran\/gcc\)" else: build_type_option = "x86_64 Linux, gfortran compiler with gcc" else: raise EasyBuildError( "Don't know how to figure out build type to select.") # fetch selected build type (and make sure it makes sense) known_build_types = ['serial', 'smpar', 'dmpar', 'dm+sm'] self.parallel_build_types = ["dmpar", "dm+sm"] bt = self.cfg['buildtype'] if bt not in known_build_types: raise EasyBuildError( "Unknown build type: '%s'. Supported build types: %s", bt, known_build_types) # Escape the "+" in "dm+sm" since it's being used in a regexp below. bt = bt.replace('+', r'\+') # fetch option number based on build type option and selected build type if LooseVersion(self.version) >= LooseVersion('3.7'): # the two relevant lines in the configure output for WRF 3.8 are: # 13. (serial) 14. (smpar) 15. (dmpar) 16. (dm+sm) INTEL (ifort/icc) # 32. (serial) 33. (smpar) 34. (dmpar) 35. (dm+sm) GNU (gfortran/gcc) build_type_question = "\s*(?P<nr>[0-9]+)\.\ \(%s\).*%s" % ( bt, build_type_option) else: # the relevant lines in the configure output for WRF 3.6 are: # 13. Linux x86_64 i486 i586 i686, ifort compiler with icc (serial) # 14. Linux x86_64 i486 i586 i686, ifort compiler with icc (smpar) # 15. Linux x86_64 i486 i586 i686, ifort compiler with icc (dmpar) # 16. Linux x86_64 i486 i586 i686, ifort compiler with icc (dm+sm) # 32. x86_64 Linux, gfortran compiler with gcc (serial) # 33. x86_64 Linux, gfortran compiler with gcc (smpar) # 34. x86_64 Linux, gfortran compiler with gcc (dmpar) # 35. x86_64 Linux, gfortran compiler with gcc (dm+sm) build_type_question = "\s*(?P<nr>[0-9]+).\s*%s\s*\(%s\)" % ( build_type_option, bt) # run configure script cmd = "./configure" qa = { # named group in match will be used to construct answer "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]:": "1", "Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]:": "0" } no_qa = [ "testing for fseeko and fseeko64", r"If you wish to change the default options, edit the file:[\s\n]*arch/configure_new.defaults" ] std_qa = { # named group in match will be used to construct answer r"%s.*\n(.*\n)*Enter selection\s*\[[0-9]+-[0-9]+\]\s*:" % build_type_question: "%(nr)s", } run_cmd_qa(cmd, qa, no_qa=no_qa, std_qa=std_qa, log_all=True, simple=True) cfgfile = 'configure.wrf' # make sure correct compilers are being used comps = { 'SCC': os.getenv('CC'), 'SFC': os.getenv('F90'), 'CCOMP': os.getenv('CC'), 'DM_FC': os.getenv('MPIF90'), 'DM_CC': "%s -DMPI2_SUPPORT" % os.getenv('MPICC'), } regex_subs = [(r"^(%s\s*=\s*).*$" % k, r"\1 %s" % v) for (k, v) in comps.items()] apply_regex_substitutions(cfgfile, regex_subs) # rewrite optimization options if desired if self.cfg['rewriteopts']: # replace default -O3 option in configure.wrf with CFLAGS/FFLAGS from environment self.log.info("Rewriting optimization options in %s" % cfgfile) # set extra flags for Intel compilers # see http://software.intel.com/en-us/forums/showthread.php?t=72109&p=1#146748 if self.comp_fam == toolchain.INTELCOMP: # @UndefinedVariable # -O3 -heap-arrays is required to resolve compilation error for envvar in ['CFLAGS', 'FFLAGS']: val = os.getenv(envvar) if '-O3' in val: env.setvar(envvar, '%s -heap-arrays' % val) self.log.info("Updated %s to '%s'" % (envvar, os.getenv(envvar))) # replace -O3 with desired optimization options regex_subs = [ (r"^(FCOPTIM.*)(\s-O3)(\s.*)$", r"\1 %s \3" % os.getenv('FFLAGS')), (r"^(CFLAGS_LOCAL.*)(\s-O3)(\s.*)$", r"\1 %s \3" % os.getenv('CFLAGS')), ] apply_regex_substitutions(cfgfile, regex_subs)
def configure_step(self): """Configure build: - set some magic environment variables - run configure script - adjust configure.wrf file if needed """ # define $NETCDF* for netCDF dependency (used when creating WRF module file) set_netcdf_env_vars(self.log) # HDF5 (optional) dependency hdf5 = get_software_root('HDF5') if hdf5: # check if this is parallel HDF5 phdf5_bins = ['h5pcc', 'ph5diff'] parallel_hdf5 = True for f in phdf5_bins: if not os.path.exists(os.path.join(hdf5, 'bin', f)): parallel_hdf5 = False break if not (hdf5 or parallel_hdf5): raise EasyBuildError("Parallel HDF5 module not loaded?") else: env.setvar('PHDF5', hdf5) else: self.log.info("HDF5 module not loaded, assuming that's OK...") # JasPer dependency check + setting env vars jasper = get_software_root('JasPer') if jasper: jasperlibdir = os.path.join(jasper, "lib") env.setvar('JASPERINC', os.path.join(jasper, "include")) env.setvar('JASPERLIB', jasperlibdir) else: if os.getenv('JASPERINC') or os.getenv('JASPERLIB'): raise EasyBuildError("JasPer module not loaded, but JASPERINC and/or JASPERLIB still set?") else: self.log.info("JasPer module not loaded, assuming that's OK...") # enable support for large file support in netCDF env.setvar('WRFIO_NCD_LARGE_FILE_SUPPORT', '1') # patch arch/Config_new.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join("arch", "Config_new.pl")) # determine build type option to look for build_type_option = None self.comp_fam = self.toolchain.comp_family() if self.comp_fam == toolchain.INTELCOMP: #@UndefinedVariable if LooseVersion(self.version) >= LooseVersion('3.7'): build_type_option = "INTEL\ \(ifort\/icc\)" else: build_type_option = "Linux x86_64 i486 i586 i686, ifort compiler with icc" elif self.comp_fam == toolchain.GCC: #@UndefinedVariable if LooseVersion(self.version) >= LooseVersion('3.7'): build_type_option = "GNU\ \(gfortran\/gcc\)" else: build_type_option = "x86_64 Linux, gfortran compiler with gcc" else: raise EasyBuildError("Don't know how to figure out build type to select.") # fetch selected build type (and make sure it makes sense) known_build_types = ['serial', 'smpar', 'dmpar', 'dm+sm'] self.parallel_build_types = ["dmpar", "smpar", "dm+sm"] bt = self.cfg['buildtype'] if not bt in known_build_types: raise EasyBuildError("Unknown build type: '%s'. Supported build types: %s", bt, known_build_types) # fetch option number based on build type option and selected build type if LooseVersion(self.version) >= LooseVersion('3.7'): # the two relevant lines in the configure output for WRF 3.8 are: # 13. (serial) 14. (smpar) 15. (dmpar) 16. (dm+sm) INTEL (ifort/icc) # 32. (serial) 33. (smpar) 34. (dmpar) 35. (dm+sm) GNU (gfortran/gcc) build_type_question = "\s*(?P<nr>[0-9]+)\.\ \(%s\).*%s" % (bt, build_type_option) else: # the relevant lines in the configure output for WRF 3.6 are: # 13. Linux x86_64 i486 i586 i686, ifort compiler with icc (serial) # 14. Linux x86_64 i486 i586 i686, ifort compiler with icc (smpar) # 15. Linux x86_64 i486 i586 i686, ifort compiler with icc (dmpar) # 16. Linux x86_64 i486 i586 i686, ifort compiler with icc (dm+sm) # 32. x86_64 Linux, gfortran compiler with gcc (serial) # 33. x86_64 Linux, gfortran compiler with gcc (smpar) # 34. x86_64 Linux, gfortran compiler with gcc (dmpar) # 35. x86_64 Linux, gfortran compiler with gcc (dm+sm) build_type_question = "\s*(?P<nr>[0-9]+).\s*%s\s*\(%s\)" % (build_type_option, bt) # run configure script cmd = "./configure" qa = { # named group in match will be used to construct answer "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]:": "1", "Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]:": "0" } no_qa = [ "testing for fseeko and fseeko64", r"If you wish to change the default options, edit the file:[\s\n]*arch/configure_new.defaults" ] std_qa = { # named group in match will be used to construct answer r"%s.*\n(.*\n)*Enter selection\s*\[[0-9]+-[0-9]+\]\s*:" % build_type_question: "%(nr)s", } run_cmd_qa(cmd, qa, no_qa=no_qa, std_qa=std_qa, log_all=True, simple=True) cfgfile = 'configure.wrf' # make sure correct compilers are being used comps = { 'SCC': os.getenv('CC'), 'SFC': os.getenv('F90'), 'CCOMP': os.getenv('CC'), 'DM_FC': os.getenv('MPIF90'), 'DM_CC': "%s -DMPI2_SUPPORT" % os.getenv('MPICC'), } regex_subs = [(r"^(%s\s*=\s*).*$" % k, r"\1 %s" % v) for (k, v) in comps.items()] apply_regex_substitutions(cfgfile, regex_subs) # rewrite optimization options if desired if self.cfg['rewriteopts']: # replace default -O3 option in configure.wrf with CFLAGS/FFLAGS from environment self.log.info("Rewriting optimization options in %s" % cfgfile) # set extra flags for Intel compilers # see http://software.intel.com/en-us/forums/showthread.php?t=72109&p=1#146748 if self.comp_fam == toolchain.INTELCOMP: #@UndefinedVariable # -O3 -heap-arrays is required to resolve compilation error for envvar in ['CFLAGS', 'FFLAGS']: val = os.getenv(envvar) if '-O3' in val: env.setvar(envvar, '%s -heap-arrays' % val) self.log.info("Updated %s to '%s'" % (envvar, os.getenv(envvar))) # replace -O3 with desired optimization options regex_subs = [ (r"^(FCOPTIM.*)(\s-O3)(\s.*)$", r"\1 %s \3" % os.getenv('FFLAGS')), (r"^(CFLAGS_LOCAL.*)(\s-O3)(\s.*)$", r"\1 %s \3" % os.getenv('CFLAGS')), ] apply_regex_substitutions(cfgfile, regex_subs)
def configure_step(self): """Configure build: - set some magic environment variables - run configure script - adjust configure.wrf file if needed """ # netCDF dependency set_netcdf_env_vars(self.log) self.netcdf_mod_cmds = get_netcdf_module_set_cmds(self.log) # HDF5 (optional) dependency hdf5 = get_software_root('HDF5') if hdf5: # check if this is parallel HDF5 phdf5_bins = ['h5pcc', 'ph5diff'] parallel_hdf5 = True for f in phdf5_bins: if not os.path.exists(os.path.join(hdf5, 'bin', f)): parallel_hdf5 = False break if not (hdf5 or parallel_hdf5): self.log.error("Parallel HDF5 module not loaded?") else: env.setvar('PHDF5', hdf5) else: self.log.info("HDF5 module not loaded, assuming that's OK...") # JasPer dependency check + setting env vars jasper = get_software_root('JasPer') if jasper: jasperlibdir = os.path.join(jasper, "lib") env.setvar('JASPERINC', os.path.join(jasper, "include")) env.setvar('JASPERLIB', jasperlibdir) else: if os.getenv('JASPERINC') or os.getenv('JASPERLIB'): self.log.error( "JasPer module not loaded, but JASPERINC and/or JASPERLIB still set?" ) else: self.log.info( "JasPer module not loaded, assuming that's OK...") # enable support for large file support in netCDF env.setvar('WRFIO_NCD_LARGE_FILE_SUPPORT', '1') # patch arch/Config_new.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join("arch", "Config_new.pl")) # determine build type option to look for build_type_option = None self.comp_fam = self.toolchain.comp_family() if self.comp_fam == toolchain.INTELCOMP: #@UndefinedVariable build_type_option = "Linux x86_64 i486 i586 i686, ifort compiler with icc" elif self.comp_fam == toolchain.GCC: #@UndefinedVariable build_type_option = "x86_64 Linux, gfortran compiler with gcc" else: self.log.error( "Don't know how to figure out build type to select.") # fetch selected build type (and make sure it makes sense) known_build_types = ['serial', 'smpar', 'dmpar', 'dm+sm'] self.parallel_build_types = ["dmpar", "smpar", "dm+sm"] bt = self.cfg['buildtype'] if not bt in known_build_types: self.log.error( "Unknown build type: '%s'. Supported build types: %s" % (bt, known_build_types)) # fetch option number based on build type option and selected build type build_type_question = "\s*(?P<nr>[0-9]+).\s*%s\s*\(%s\)" % ( build_type_option, bt) # run configure script cmd = "./configure" qa = { # named group in match will be used to construct answer "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]:": "1", "Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]:": "0" } no_qa = [ "testing for fseeko and fseeko64", r"If you wish to change the default options, edit the file:[\s\n]*arch/configure_new.defaults" ] std_qa = { # named group in match will be used to construct answer r"%s.*\n(.*\n)*Enter selection\s*\[[0-9]+-[0-9]+\]\s*:" % build_type_question: "%(nr)s", } run_cmd_qa(cmd, qa, no_qa=no_qa, std_qa=std_qa, log_all=True, simple=True) cfgfile = 'configure.wrf' # make sure correct compilers are being used comps = { 'SCC': os.getenv('CC'), 'SFC': os.getenv('F90'), 'CCOMP': os.getenv('CC'), 'DM_FC': os.getenv('MPIF90'), 'DM_CC': "%s -DMPI2_SUPPORT" % os.getenv('MPICC'), } for line in fileinput.input(cfgfile, inplace=1, backup='.orig.comps'): for (k, v) in comps.items(): line = re.sub(r"^(%s\s*=\s*).*$" % k, r"\1 %s" % v, line) sys.stdout.write(line) # rewrite optimization options if desired if self.cfg['rewriteopts']: # replace default -O3 option in configure.wrf with CFLAGS/FFLAGS from environment self.log.info("Rewriting optimization options in %s" % cfgfile) # set extra flags for Intel compilers # see http://software.intel.com/en-us/forums/showthread.php?t=72109&p=1#146748 if self.comp_fam == toolchain.INTELCOMP: #@UndefinedVariable # -O3 -heap-arrays is required to resolve compilation error for envvar in ['CFLAGS', 'FFLAGS']: val = os.getenv(envvar) if '-O3' in val: env.setvar(envvar, '%s -heap-arrays' % val) self.log.info("Updated %s to '%s'" % (envvar, os.getenv(envvar))) # replace -O3 with desired optimization options for line in fileinput.input(cfgfile, inplace=1, backup='.orig.rewriteopts'): line = re.sub(r"^(FCOPTIM.*)(\s-O3)(\s.*)$", r"\1 %s \3" % os.getenv('FFLAGS'), line) line = re.sub(r"^(CFLAGS_LOCAL.*)(\s-O3)(\s.*)$", r"\1 %s \3" % os.getenv('CFLAGS'), line) sys.stdout.write(line)
def install_step(self): """Custom install procedure for RepeatMasker.""" super(EB_RepeatMasker, self).install_step() # check for required dependencies perl_root = get_software_root('Perl') if perl_root: perl = os.path.join(perl_root, 'bin', 'perl') else: raise EasyBuildError("Missing required dependency: Perl") trf_root = get_software_root('TRF') if trf_root: trf = os.path.join(trf_root, 'trf') else: raise EasyBuildError("Missing required dependency: TRF") # determine which search engine to use # see also http://www.repeatmasker.org/RMDownload.html cand_search_engines = ['CrossMatch', 'RMBlast', 'WUBlast', 'HMMER'] search_engine = None for dep in cand_search_engines: if get_software_root(dep): if search_engine is None: search_engine = dep else: raise EasyBuildError( "Found multiple candidate search engines: %s and %s", search_engine, dep) if search_engine is None: raise EasyBuildError( "No search engine found, one of these must be included as dependency: %s", ' '.join(cand_search_engines)) change_dir(self.installdir) patch_perl_script_autoflush('configure') search_engine_map = { 'CrossMatch': '1', 'RMBlast': '2', 'WUBlast': '3', 'HMMER': '4', } search_engine_bindir = os.path.join(get_software_root(search_engine), 'bin') cmd = "perl ./configure" qa = { '<PRESS ENTER TO CONTINUE>': '', # select search engine 'Enter Selection:': search_engine_map[search_engine], } std_qa = { r'\*\*PERL PROGRAM\*\*\n([^*]*\n)+Enter path.*': perl, r'\*\*REPEATMASKER INSTALLATION DIRECTORY\*\*\n([^*]*\n)+Enter path.*': self.installdir, r'\*\*TRF PROGRAM\*\*\n([^*]*\n)+Enter path.*': trf, # search engine installation path (location of /bin subdirectory) # also enter 'Y' to confirm + '5' ("Done") to complete selection process for search engine r'\*\*.* INSTALLATION PATH\*\*\n([^*]*\n)+Enter path.*': search_engine_bindir + '\nY\n5', } run_cmd_qa(cmd, qa, std_qa=std_qa, log_all=True, simple=True, log_ok=True)
def configure(self): """Configure build: - set some magic environment variables - run configure script - adjust configure.wrf file if needed """ # netCDF dependency set_netcdf_env_vars(self.log) # HDF5 (optional) dependency hdf5 = get_software_root('HDF5') if hdf5: # check if this is parallel HDF5 phdf5_bins = ['h5pcc','ph5diff'] parallel_hdf5 = True for f in phdf5_bins: if not os.path.exists(os.path.join(hdf5, 'bin', f)): parallel_hdf5 = False break if not (hdf5 or parallel_hdf5): self.log.error("Parallel HDF5 module not loaded?") else: env.set('PHDF5', hdf5) else: self.log.info("HDF5 module not loaded, assuming that's OK...") # JasPer dependency check + setting env vars jasper = get_software_root('JasPer') jasperlibdir = os.path.join(jasper, "lib") if jasper: env.set('JASPERINC', os.path.join(jasper, "include")) env.set('JASPERLIB', jasperlibdir) else: if os.getenv('JASPERINC') or os.getenv('JASPERLIB'): self.log.error("JasPer module not loaded, but JASPERINC and/or JASPERLIB still set?") else: self.log.info("JasPer module not loaded, assuming that's OK...") # enable support for large file support in netCDF env.set('WRFIO_NCD_LARGE_FILE_SUPPORT', '1') # patch arch/Config_new.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join("arch", "Config_new.pl")) # determine build type option to look for build_type_option = None self.comp_fam = self.toolkit().comp_family() if self.comp_fam == toolkit.INTEL: build_type_option = "Linux x86_64 i486 i586 i686, ifort compiler with icc" elif self.comp_fam == toolkit.GCC: build_type_option = "x86_64 Linux, gfortran compiler with gcc" else: self.log.error("Don't know how to figure out build type to select.") # fetch selected build type (and make sure it makes sense) known_build_types = ['serial', 'smpar', 'dmpar', 'dm+sm'] self.parallel_build_types = ["dmpar","smpar","dm+sm"] bt = self.getcfg('buildtype') if not bt in known_build_types: self.log.error("Unknown build type: '%s'. Supported build types: %s" % (bt, known_build_types)) # fetch option number based on build type option and selected build type build_type_question = "\s*(?P<nr>[0-9]+).\s*%s\s*\(%s\)" % (build_type_option, bt) # run configure script cmd = "./configure" qa = { # named group in match will be used to construct answer "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]:": "1", "Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]:": "0" } no_qa = [] std_qa = { # named group in match will be used to construct answer r"%s.*\n(.*\n)*Enter selection\s*\[[0-9]+-[0-9]+\]\s*:" % build_type_question: "%(nr)s", } run_cmd_qa(cmd, qa, no_qa=no_qa, std_qa=std_qa, log_all=True, simple=True) cfgfile= 'configure.wrf' # make sure correct compilers are being used comps = { 'SCC': os.getenv('CC'), 'SFC': os.getenv('F90'), 'CCOMP': os.getenv('CC'), 'DM_FC': os.getenv('MPIF90'), 'DM_CC': "%s -DMPI2_SUPPORT" % os.getenv('MPICC'), } for line in fileinput.input(cfgfile, inplace=1, backup='.orig.comps'): for (k, v) in comps.items(): line = re.sub(r"^(%s\s*=\s*).*$" % k, r"\1 %s" % v, line) sys.stdout.write(line) # rewrite optimization options if desired if self.getcfg('rewriteopts'): # replace default -O3 option in configure.wrf with CFLAGS/FFLAGS from environment self.log.info("Rewriting optimization options in %s" % cfgfile) # set extra flags for Intel compilers # see http://software.intel.com/en-us/forums/showthread.php?t=72109&p=1#146748 if self.comp_fam == toolkit.INTEL: # -O3 -heap-arrays is required to resolve compilation error for envvar in ['CFLAGS', 'FFLAGS']: val = os.getenv(envvar) if '-O3' in val: env.set(envvar, '%s -heap-arrays' % val) self.log.info("Updated %s to '%s'" % (envvar, os.getenv(envvar))) # replace -O3 with desired optimization options for line in fileinput.input(cfgfile, inplace=1, backup='.orig.rewriteopts'): line = re.sub(r"^(FCOPTIM.*)(\s-O3)(\s.*)$", r"\1 %s \3" % os.getenv('FFLAGS'), line) line = re.sub(r"^(CFLAGS_LOCAL.*)(\s-O3)(\s.*)$", r"\1 %s \3" % os.getenv('CFLAGS'), line) sys.stdout.write(line)
def configure_step(self): """Configure build: - set some magic environment variables - run configure script - adjust configure.wrf file if needed """ # define $NETCDF* for netCDF dependency (used when creating WRF module file) set_netcdf_env_vars(self.log) # HDF5 (optional) dependency hdf5 = get_software_root('HDF5') if hdf5: # check if this is parallel HDF5 phdf5_bins = ['h5pcc', 'ph5diff'] parallel_hdf5 = True for f in phdf5_bins: if not os.path.exists(os.path.join(hdf5, 'bin', f)): parallel_hdf5 = False break if not (hdf5 or parallel_hdf5): raise EasyBuildError("Parallel HDF5 module not loaded?") else: env.setvar('PHDF5', hdf5) else: self.log.info("HDF5 module not loaded, assuming that's OK...") # JasPer dependency check + setting env vars jasper = get_software_root('JasPer') if jasper: jasperlibdir = os.path.join(jasper, "lib") env.setvar('JASPERINC', os.path.join(jasper, "include")) env.setvar('JASPERLIB', jasperlibdir) else: if os.getenv('JASPERINC') or os.getenv('JASPERLIB'): raise EasyBuildError("JasPer module not loaded, but JASPERINC and/or JASPERLIB still set?") else: self.log.info("JasPer module not loaded, assuming that's OK...") # enable support for large file support in netCDF env.setvar('WRFIO_NCD_LARGE_FILE_SUPPORT', '1') # patch arch/Config_new.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join("arch", "Config_new.pl")) # determine build type option to look for build_type_option = None self.comp_fam = self.toolchain.comp_family() if self.comp_fam == toolchain.INTELCOMP: #@UndefinedVariable if LooseVersion(self.version) >= LooseVersion('3.7'): build_type_option = "INTEL\ \(ifort\/icc\)" else: build_type_option = "Linux x86_64 i486 i586 i686, ifort compiler with icc" elif self.comp_fam == toolchain.GCC: #@UndefinedVariable if LooseVersion(self.version) >= LooseVersion('3.7'): build_type_option = "GNU\ \(gfortran\/gcc\)" else: build_type_option = "x86_64 Linux, gfortran compiler with gcc" else: raise EasyBuildError("Don't know how to figure out build type to select.") # fetch selected build type (and make sure it makes sense) known_build_types = ['serial', 'smpar', 'dmpar', 'dm+sm'] self.parallel_build_types = ["dmpar", "smpar", "dm+sm"] bt = self.cfg['buildtype'] if not bt in known_build_types: raise EasyBuildError("Unknown build type: '%s'. Supported build types: %s", bt, known_build_types) # fetch option number based on build type option and selected build type if LooseVersion(self.version) >= LooseVersion('3.7'): # the two relevant lines in the configure output for WRF 3.8 are: # 13. (serial) 14. (smpar) 15. (dmpar) 16. (dm+sm) INTEL (ifort/icc) # 32. (serial) 33. (smpar) 34. (dmpar) 35. (dm+sm) GNU (gfortran/gcc) build_type_question = "\s*(?P<nr>[0-9]+)\.\ \(%s\).*%s" % (bt, build_type_option) else: # the relevant lines in the configure output for WRF 3.6 are: # 13. Linux x86_64 i486 i586 i686, ifort compiler with icc (serial) # 14. Linux x86_64 i486 i586 i686, ifort compiler with icc (smpar) # 15. Linux x86_64 i486 i586 i686, ifort compiler with icc (dmpar) # 16. Linux x86_64 i486 i586 i686, ifort compiler with icc (dm+sm) # 32. x86_64 Linux, gfortran compiler with gcc (serial) # 33. x86_64 Linux, gfortran compiler with gcc (smpar) # 34. x86_64 Linux, gfortran compiler with gcc (dmpar) # 35. x86_64 Linux, gfortran compiler with gcc (dm+sm) build_type_question = "\s*(?P<nr>[0-9]+).\s*%s\s*\(%s\)" % (build_type_option, bt) # run configure script cmd = "./configure" qa = { # named group in match will be used to construct answer "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]:": "1", "Compile for nesting? (0=no nesting, 1=basic, 2=preset moves, 3=vortex following) [default 0]:": "0" } no_qa = [ "testing for fseeko and fseeko64", r"If you wish to change the default options, edit the file:[\s ]*arch/configure_new.defaults" ]
def configure_step(self): """Custom configuration procedure for WRF-Fire.""" comp_fam = self.toolchain.comp_family() # define $NETCDF* for netCDF dependency netcdf_fortran = get_software_root('netCDF-Fortran') if netcdf_fortran: env.setvar('NETCDF', netcdf_fortran) else: raise EasyBuildError("Required dependendy netCDF-Fortran is missing") # define $PHDF5 for parallel HDF5 dependency hdf5 = get_software_root('HDF5') if hdf5 and os.path.exists(os.path.join(hdf5, 'bin', 'h5pcc')): env.setvar('PHDF5', hdf5) # first, configure WRF part change_dir(os.path.join(self.cfg['start_dir'], 'WRFV3')) # instruct WRF-Fire to create netCDF v4 output files env.setvar('WRFIO_NETCDF4_FILE_SUPPORT', '1') # patch arch/Config_new.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join('arch', 'Config_new.pl')) # determine build type option to look for known_build_type_options = { toolchain.INTELCOMP: "Linux x86_64 i486 i586 i686, ifort compiler with icc", toolchain.GCC: "x86_64 Linux, gfortran compiler with gcc", toolchain.PGI: "Linux x86_64, PGI compiler with pgcc", } build_type_option = known_build_type_options.get(comp_fam) if build_type_option is None: raise EasyBuildError("Don't know which WPS configure option to select for compiler family %s", comp_fam) build_type_question = "\s*(?P<nr>[0-9]+).\s*%s\s*\(%s\)" % (build_type_option, self.cfg['buildtype']) qa = { "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]:": '1', } std_qa = { # named group in match will be used to construct answer r"%s.*\n(.*\n)*Enter selection\s*\[[0-9]+-[0-9]+\]\s*:" % build_type_question: '%(nr)s', } run_cmd_qa('./configure', qa, std_qa=std_qa, log_all=True, simple=True) cpp_flag = None if comp_fam == toolchain.INTELCOMP: cpp_flag = '-fpp' elif comp_fam == toolchain.GCC: cpp_flag = '-cpp' else: raise EasyBuildError("Don't know which flag to use to specify that Fortran files were preprocessed") # patch configure.wrf to get things right comps = { 'CFLAGS_LOCAL': os.getenv('CFLAGS'), 'DM_FC': os.getenv('MPIF90'), 'DM_CC': "%s -DMPI2_SUPPORT" % os.getenv('MPICC'), 'FCOPTIM': os.getenv('FFLAGS'), # specify that Fortran files have been preprocessed with cpp, # see http://forum.wrfforum.com/viewtopic.php?f=5&t=6086 'FORMAT_FIXED': "-FI %s" % cpp_flag, 'FORMAT_FREE': "-FR %s" % cpp_flag, } regex_subs = [(r"^(%s\s*=\s*).*$" % k, r"\1 %s" % v) for (k, v) in comps.items()] apply_regex_substitutions('configure.wrf', regex_subs) # also configure WPS part change_dir(os.path.join(self.cfg['start_dir'], 'WPS')) # patch arch/Config_new.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join('arch', 'Config.pl')) # determine build type option to look for known_build_type_options = { toolchain.INTELCOMP: "PC Linux x86_64, Intel compiler", toolchain.GCC: "PC Linux x86_64, g95 compiler", toolchain.PGI: "PC Linux x86_64 (IA64 and Opteron), PGI compiler 5.2 or higher", } build_type_option = known_build_type_options.get(comp_fam) if build_type_option is None: raise EasyBuildError("Don't know which WPS configure option to select for compiler family %s", comp_fam) known_wps_build_types = { 'dmpar': 'DM parallel', 'smpar': 'serial', } wps_build_type = known_wps_build_types.get(self.cfg['buildtype']) if wps_build_type is None: raise EasyBuildError("Don't know which WPS build type to pick for '%s'", self.cfg['builddtype']) build_type_question = "\s*(?P<nr>[0-9]+).\s*%s.*%s(?!NO GRIB2)" % (build_type_option, wps_build_type) std_qa = { # named group in match will be used to construct answer r"%s.*\n(.*\n)*Enter selection\s*\[[0-9]+-[0-9]+\]\s*:" % build_type_question: '%(nr)s', } run_cmd_qa('./configure', {}, std_qa=std_qa, log_all=True, simple=True) # patch configure.wps to get things right comps = { 'CC': '%s %s' % (os.getenv('MPICC'), os.getenv('CFLAGS')), 'FC': '%s %s' % (os.getenv('MPIF90'), os.getenv('F90FLAGS')) } regex_subs = [(r"^(%s\s*=\s*).*$" % k, r"\1 %s" % v) for (k, v) in comps.items()] # specify that Fortran90 files have been preprocessed with cpp regex_subs.extend([ (r"^(F77FLAGS\s*=\s*)", r"\1 %s " % cpp_flag), (r"^(FFLAGS\s*=\s*)", r"\1 %s " % cpp_flag), ]) apply_regex_substitutions('configure.wps', regex_subs)
def configure_step(self): """Configure build: - set required environment variables (for netCDF, JasPer) - patch compile script and ungrib Makefile for non-default install paths of WRF and JasPer - run configure script and figure how to select desired build option - patch configure.wps file afterwards to fix 'serial compiler' setting """ # netCDF dependency check + setting env vars (NETCDF, NETCDFF) set_netcdf_env_vars(self.log) # WRF dependency check wrf = get_software_root('WRF') if wrf: wrfdir = os.path.join(wrf, det_wrf_subdir(get_software_version('WRF'))) else: raise EasyBuildError("WRF module not loaded?") self.compile_script = 'compile' if LooseVersion(self.version) >= LooseVersion('4.0.3'): # specify install location of WRF via $WRF_DIR (supported since WPS 4.0.3) # see https://github.com/wrf-model/WPS/pull/102 env.setvar('WRF_DIR', wrfdir) else: # patch compile script so that WRF is found regex_subs = [(r"^(\s*set\s*WRF_DIR_PRE\s*=\s*)\${DEV_TOP}(.*)$", r"\1%s\2" % wrfdir)] apply_regex_substitutions(self.compile_script, regex_subs) # libpng dependency check libpng = get_software_root('libpng') zlib = get_software_root('zlib') if libpng: paths = [libpng] if zlib: paths.insert(0, zlib) libpnginc = ' '.join( ['-I%s' % os.path.join(path, 'include') for path in paths]) libpnglib = ' '.join( ['-L%s' % os.path.join(path, 'lib') for path in paths]) else: # define these as empty, assume that libpng will be available via OS (e.g. due to --filter-deps=libpng) libpnglib = "" libpnginc = "" # JasPer dependency check + setting env vars jasper = get_software_root('JasPer') if jasper: env.setvar('JASPERINC', os.path.join(jasper, "include")) jasperlibdir = os.path.join(jasper, "lib") env.setvar('JASPERLIB', jasperlibdir) jasperlib = "-L%s" % jasperlibdir else: raise EasyBuildError("JasPer module not loaded?") # patch ungrib Makefile so that JasPer is found jasperlibs = "%s -ljasper %s -lpng" % (jasperlib, libpnglib) regex_subs = [ (r"^(\s*-L\.\s*-l\$\(LIBTARGET\))(\s*;.*)$", r"\1 %s\2" % jasperlibs), (r"^(\s*\$\(COMPRESSION_LIBS\))(\s*;.*)$", r"\1 %s\2" % jasperlibs), ] apply_regex_substitutions(os.path.join('ungrib', 'src', 'Makefile'), regex_subs) # patch arch/Config.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join("arch", "Config.pl")) # configure # determine build type option to look for self.comp_fam = self.toolchain.comp_family() build_type_option = None if LooseVersion(self.version) >= LooseVersion("3.4"): knownbuildtypes = {'smpar': 'serial', 'dmpar': 'dmpar'} if self.comp_fam == toolchain.INTELCOMP: # @UndefinedVariable build_type_option = " Linux x86_64, Intel compiler" elif self.comp_fam == toolchain.GCC: # @UndefinedVariable if LooseVersion(self.version) >= LooseVersion("3.6"): build_type_option = "Linux x86_64, gfortran" else: build_type_option = "Linux x86_64 g95" else: raise EasyBuildError( "Don't know how to figure out build type to select.") else: knownbuildtypes = {'smpar': 'serial', 'dmpar': 'DM parallel'} if self.comp_fam == toolchain.INTELCOMP: # @UndefinedVariable build_type_option = "PC Linux x86_64, Intel compiler" elif self.comp_fam == toolchain.GCC: # @UndefinedVariable build_type_option = "PC Linux x86_64, gfortran compiler," knownbuildtypes['dmpar'] = knownbuildtypes['dmpar'].upper() else: raise EasyBuildError( "Don't know how to figure out build type to select.") # check and fetch selected build type bt = self.cfg['buildtype'] if bt not in knownbuildtypes.keys(): raise EasyBuildError( "Unknown build type: '%s'. Supported build types: %s", bt, knownbuildtypes.keys()) # fetch option number based on build type option and selected build type build_type_question = r"\s*(?P<nr>[0-9]+).\s*%s\s*\(?%s\)?\s*\n" % ( build_type_option, knownbuildtypes[bt]) cmd = ' '.join( [self.cfg['preconfigopts'], './configure', self.cfg['configopts']]) qa = {} no_qa = [".*compiler is.*"] std_qa = { # named group in match will be used to construct answer r"%s(.*\n)*Enter selection\s*\[[0-9]+-[0-9]+\]\s*:" % build_type_question: "%(nr)s", } run_cmd_qa(cmd, qa, no_qa=no_qa, std_qa=std_qa, log_all=True, simple=True) # make sure correct compilers and compiler flags are being used comps = { 'SCC': "%s -I$(JASPERINC) %s" % (os.getenv('CC'), libpnginc), 'SFC': os.getenv('F90'), 'DM_FC': os.getenv('MPIF90'), 'DM_CC': os.getenv('MPICC'), 'FC': os.getenv('MPIF90'), 'CC': os.getenv('MPICC'), } if self.toolchain.options.get('openmp', None): comps.update({ 'LDFLAGS': '%s %s' % (self.toolchain.get_flag('openmp'), os.environ['LDFLAGS']) }) regex_subs = [(r"^(%s\s*=\s*).*$" % key, r"\1 %s" % val) for (key, val) in comps.items()] apply_regex_substitutions('configure.wps', regex_subs)
def install_step(self): """Install CUDA using Perl install script.""" # define how to run the installer # script has /usr/bin/perl hardcoded, but we want to have control over which perl is being used if LooseVersion(self.version) <= LooseVersion("5"): install_interpreter = "perl" install_script = "install-linux.pl" self.cfg.update('installopts', '--prefix=%s' % self.installdir) elif LooseVersion(self.version) > LooseVersion("5") and LooseVersion(self.version) < LooseVersion("10.1"): install_interpreter = "perl" install_script = "cuda-installer.pl" # note: samples are installed by default self.cfg.update('installopts', "-verbose -silent -toolkitpath=%s -toolkit" % self.installdir) else: install_interpreter = "" install_script = "./cuda-installer" # samples are installed in two places with identical copies: # self.installdir/samples and $HOME/NVIDIA_CUDA-11.2_Samples # changing the second location (the one under $HOME) to a scratch location using # --samples --samplespath=self.builddir # avoids the duplicate and pollution of the home directory of the installer. self.cfg.update('installopts', "--silent --samples --samplespath=%s --toolkit --toolkitpath=%s --defaultroot=%s" % ( self.builddir, self.installdir, self.installdir)) # When eb is called via sudo -u someuser -i eb ..., the installer may try to chown samples to the # original user using the SUDO_USER environment variable, which fails if "SUDO_USER" in os.environ: self.log.info("SUDO_USER was defined as '%s', need to unset it to avoid problems..." % os.environ["SUDO_USER"]) del os.environ["SUDO_USER"] if LooseVersion("10.0") < LooseVersion(self.version) < LooseVersion("10.2") and get_cpu_architecture() == POWER: # Workaround for # https://devtalk.nvidia.com/default/topic/1063995/cuda-setup-and-installation/cuda-10-1-243-10-1-update-2-ppc64le-run-file-installation-issue/ install_script = " && ".join([ "mkdir -p %(installdir)s/targets/ppc64le-linux/include", "([ -e %(installdir)s/include ] || ln -s targets/ppc64le-linux/include %(installdir)s/include)", "cp -r %(builddir)s/builds/cublas/src %(installdir)s/.", install_script ]) % { 'installdir': self.installdir, 'builddir': self.builddir } # Use C locale to avoid localized questions and crash on CUDA 10.1 self.cfg.update('preinstallopts', "export LANG=C && ") cmd = "%(preinstallopts)s %(interpreter)s %(script)s %(installopts)s" % { 'preinstallopts': self.cfg['preinstallopts'], 'interpreter': install_interpreter, 'script': install_script, 'installopts': self.cfg['installopts'] } # prepare for running install script autonomously qanda = {} stdqa = { # this question is only asked if CUDA tools are already available system-wide r"Would you like to remove all CUDA files under .*? (yes/no/abort): ": "no", } noqanda = [ r"^Configuring", r"Installation Complete", r"Verifying archive integrity.*", r"^Uncompressing NVIDIA CUDA", r".* -> .*", ] # patch install script to handle Q&A autonomously if install_interpreter == "perl": patch_perl_script_autoflush(os.path.join(self.builddir, install_script)) p5lib = os.getenv('PERL5LIB', '') if p5lib == '': p5lib = self.builddir else: p5lib = os.pathsep.join([self.builddir, p5lib]) env.setvar('PERL5LIB', p5lib) # make sure $DISPLAY is not defined, which may lead to (weird) problems # this is workaround for not being able to specify --nox11 to the Perl install scripts if 'DISPLAY' in os.environ: os.environ.pop('DISPLAY') # cuda-installer creates /tmp/cuda-installer.log (ignoring TMPDIR) # Try to remove it before running the installer. # This will fail with a usable error if it can't be removed # instead of segfaulting in the cuda-installer. remove_file('/tmp/cuda-installer.log') # overriding maxhits default value to 1000 (seconds to wait for nothing to change in the output # without seeing a known question) run_cmd_qa(cmd, qanda, std_qa=stdqa, no_qa=noqanda, log_all=True, simple=True, maxhits=1000) # Remove the cuda-installer log file remove_file('/tmp/cuda-installer.log') # check if there are patches to apply if len(self.src) > 1: for patch in self.src[1:]: self.log.debug("Running patch %s", patch['name']) run_cmd("/bin/sh " + patch['path'] + " --accept-eula --silent --installdir=" + self.installdir)
def configure_step(self): """Configure build: - set required environment variables (for netCDF, JasPer) - patch compile script and ungrib Makefile for non-default install paths of WRF and JasPer - run configure script and figure how to select desired build option - patch configure.wps file afterwards to fix 'serial compiler' setting """ # netCDF dependency check + setting env vars (NETCDF, NETCDFF) set_netcdf_env_vars(self.log) # WRF dependency check wrf = get_software_root('WRF') if wrf: wrfdir = os.path.join(wrf, det_wrf_subdir(get_software_version('WRF'))) else: raise EasyBuildError("WRF module not loaded?") # patch compile script so that WRF is found self.compile_script = "compile" regex_subs = [(r"^(\s*set\s*WRF_DIR_PRE\s*=\s*)\${DEV_TOP}(.*)$", r"\1%s\2" % wrfdir)] apply_regex_substitutions(self.compile_script, regex_subs) # libpng dependency check libpng = get_software_root('libpng') zlib = get_software_root('zlib') if libpng: paths = [libpng] if zlib: paths.insert(0, zlib) libpnginc = ' '.join(['-I%s' % os.path.join(path, 'include') for path in paths]) libpnglib = ' '.join(['-L%s' % os.path.join(path, 'lib') for path in paths]) else: # define these as empty, assume that libpng will be available via OS (e.g. due to --filter-deps=libpng) libpnglib = "" libpnginc = "" # JasPer dependency check + setting env vars jasper = get_software_root('JasPer') if jasper: env.setvar('JASPERINC', os.path.join(jasper, "include")) jasperlibdir = os.path.join(jasper, "lib") env.setvar('JASPERLIB', jasperlibdir) jasperlib = "-L%s" % jasperlibdir else: raise EasyBuildError("JasPer module not loaded?") # patch ungrib Makefile so that JasPer is found jasperlibs = "%s -ljasper %s -lpng" % (jasperlib, libpnglib) regex_subs = [ (r"^(\s*-L\.\s*-l\$\(LIBTARGET\))(\s*;.*)$", r"\1 %s\2" % jasperlibs), (r"^(\s*\$\(COMPRESSION_LIBS\))(\s*;.*)$", r"\1 %s\2" % jasperlibs), ] apply_regex_substitutions(os.path.join('ungrib', 'src', 'Makefile'), regex_subs) # patch arch/Config.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join("arch", "Config.pl")) # configure # determine build type option to look for self.comp_fam = self.toolchain.comp_family() build_type_option = None if LooseVersion(self.version) >= LooseVersion("3.4"): knownbuildtypes = { 'smpar': 'serial', 'dmpar': 'dmpar' } if self.comp_fam == toolchain.INTELCOMP: # @UndefinedVariable build_type_option = " Linux x86_64, Intel compiler" elif self.comp_fam == toolchain.GCC: # @UndefinedVariable build_type_option = "Linux x86_64 g95 compiler" else: raise EasyBuildError("Don't know how to figure out build type to select.") else: knownbuildtypes = { 'smpar': 'serial', 'dmpar': 'DM parallel' } if self.comp_fam == toolchain.INTELCOMP: # @UndefinedVariable build_type_option = "PC Linux x86_64, Intel compiler" elif self.comp_fam == toolchain.GCC: # @UndefinedVariable build_type_option = "PC Linux x86_64, gfortran compiler," knownbuildtypes['dmpar'] = knownbuildtypes['dmpar'].upper() else: raise EasyBuildError("Don't know how to figure out build type to select.") # check and fetch selected build type bt = self.cfg['buildtype'] if bt not in knownbuildtypes.keys(): raise EasyBuildError("Unknown build type: '%s'. Supported build types: %s", bt, knownbuildtypes.keys()) # fetch option number based on build type option and selected build type build_type_question = "\s*(?P<nr>[0-9]+).\s*%s\s*\(?%s\)?\s*\n" % (build_type_option, knownbuildtypes[bt]) cmd = "./configure" qa = {} no_qa = [".*compiler is.*"] std_qa = { # named group in match will be used to construct answer r"%s(.*\n)*Enter selection\s*\[[0-9]+-[0-9]+\]\s*:" % build_type_question: "%(nr)s", } run_cmd_qa(cmd, qa, no_qa=no_qa, std_qa=std_qa, log_all=True, simple=True) # make sure correct compilers and compiler flags are being used comps = { 'SCC': "%s -I$(JASPERINC) %s" % (os.getenv('CC'), libpnginc), 'SFC': os.getenv('F90'), 'DM_FC': os.getenv('MPIF90'), 'DM_CC': os.getenv('MPICC'), 'FC': os.getenv('MPIF90'), 'CC': os.getenv('MPICC'), } regex_subs = [(r"^(%s\s*=\s*).*$" % key, r"\1 %s" % val) for (key, val) in comps.items()] apply_regex_substitutions('configure.wps', regex_subs)
def configure_step(self): """Custom configuration procedure for WRF-Fire.""" comp_fam = self.toolchain.comp_family() # define $NETCDF* for netCDF dependency netcdf_fortran = get_software_root('netCDF-Fortran') if netcdf_fortran: env.setvar('NETCDF', netcdf_fortran) else: raise EasyBuildError( "Required dependendy netCDF-Fortran is missing") # define $PHDF5 for parallel HDF5 dependency hdf5 = get_software_root('HDF5') if hdf5 and os.path.exists(os.path.join(hdf5, 'bin', 'h5pcc')): env.setvar('PHDF5', hdf5) # first, configure WRF part change_dir(os.path.join(self.cfg['start_dir'], 'WRFV3')) # instruct WRF-Fire to create netCDF v4 output files env.setvar('WRFIO_NETCDF4_FILE_SUPPORT', '1') # patch arch/Config_new.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join('arch', 'Config_new.pl')) # determine build type option to look for known_build_type_options = { toolchain.INTELCOMP: "Linux x86_64 i486 i586 i686, ifort compiler with icc", toolchain.GCC: "x86_64 Linux, gfortran compiler with gcc", toolchain.PGI: "Linux x86_64, PGI compiler with pgcc", } build_type_option = known_build_type_options.get(comp_fam) if build_type_option is None: raise EasyBuildError( "Don't know which WPS configure option to select for compiler family %s", comp_fam) build_type_question = "\s*(?P<nr>[0-9]+).\s*%s\s*\(%s\)" % ( build_type_option, self.cfg['buildtype']) qa = { "Compile for nesting? (1=basic, 2=preset moves, 3=vortex following) [default 1]:": '1', } std_qa = { # named group in match will be used to construct answer r"%s.*\n(.*\n)*Enter selection\s*\[[0-9]+-[0-9]+\]\s*:" % build_type_question: '%(nr)s', } run_cmd_qa('./configure', qa, std_qa=std_qa, log_all=True, simple=True) cpp_flag = None if comp_fam == toolchain.INTELCOMP: cpp_flag = '-fpp' elif comp_fam == toolchain.GCC: cpp_flag = '-cpp' else: raise EasyBuildError( "Don't know which flag to use to specify that Fortran files were preprocessed" ) # patch configure.wrf to get things right comps = { 'CFLAGS_LOCAL': os.getenv('CFLAGS'), 'DM_FC': os.getenv('MPIF90'), 'DM_CC': "%s -DMPI2_SUPPORT" % os.getenv('MPICC'), 'FCOPTIM': os.getenv('FFLAGS'), # specify that Fortran files have been preprocessed with cpp, # see http://forum.wrfforum.com/viewtopic.php?f=5&t=6086 'FORMAT_FIXED': "-FI %s" % cpp_flag, 'FORMAT_FREE': "-FR %s" % cpp_flag, } regex_subs = [(r"^(%s\s*=\s*).*$" % k, r"\1 %s" % v) for (k, v) in comps.items()] apply_regex_substitutions('configure.wrf', regex_subs) # also configure WPS part change_dir(os.path.join(self.cfg['start_dir'], 'WPS')) # patch arch/Config_new.pl script, so that run_cmd_qa receives all output to answer questions patch_perl_script_autoflush(os.path.join('arch', 'Config.pl')) # determine build type option to look for known_build_type_options = { toolchain.INTELCOMP: "PC Linux x86_64, Intel compiler", toolchain.GCC: "PC Linux x86_64, g95 compiler", toolchain.PGI: "PC Linux x86_64 (IA64 and Opteron), PGI compiler 5.2 or higher", } build_type_option = known_build_type_options.get(comp_fam) if build_type_option is None: raise EasyBuildError( "Don't know which WPS configure option to select for compiler family %s", comp_fam) known_wps_build_types = { 'dmpar': 'DM parallel', 'smpar': 'serial', } wps_build_type = known_wps_build_types.get(self.cfg['buildtype']) if wps_build_type is None: raise EasyBuildError( "Don't know which WPS build type to pick for '%s'", self.cfg['builddtype']) build_type_question = "\s*(?P<nr>[0-9]+).\s*%s.*%s(?!NO GRIB2)" % ( build_type_option, wps_build_type) std_qa = { # named group in match will be used to construct answer r"%s.*\n(.*\n)*Enter selection\s*\[[0-9]+-[0-9]+\]\s*:" % build_type_question: '%(nr)s', } run_cmd_qa('./configure', {}, std_qa=std_qa, log_all=True, simple=True) # patch configure.wps to get things right comps = { 'CC': '%s %s' % (os.getenv('MPICC'), os.getenv('CFLAGS')), 'FC': '%s %s' % (os.getenv('MPIF90'), os.getenv('F90FLAGS')) } regex_subs = [(r"^(%s\s*=\s*).*$" % k, r"\1 %s" % v) for (k, v) in comps.items()] # specify that Fortran90 files have been preprocessed with cpp regex_subs.extend([ (r"^(F77FLAGS\s*=\s*)", r"\1 %s " % cpp_flag), (r"^(FFLAGS\s*=\s*)", r"\1 %s " % cpp_flag), ]) apply_regex_substitutions('configure.wps', regex_subs)