def install_step(self): """Custom install procedure for FLUENT.""" cmd = "./INSTALL -noroot -silent -install_dir %s" % self.installdir run_cmd(cmd, log_all=True, simple=True) adjust_permissions(self.installdir, stat.S_IWOTH, add=False)
def _os_dependency_check(self, dep): """ Check if dependency is available from OS. """ # - uses rpm -q and dpkg -s --> can be run as non-root!! # - fallback on which # - should be extended to files later? cmd = "exit 1" if get_os_name() in ['debian', 'ubuntu']: if run_cmd('which dpkg', simple=True, log_ok=False): cmd = "dpkg -s %s" % dep else: # OK for get_os_name() == redhat, fedora, RHEL, SL, centos if run_cmd('which rpm', simple=True, log_ok=False): cmd = "rpm -q %s" % dep found = run_cmd(cmd, simple=True, log_all=False, log_ok=False) if not found: # fallback for when os-dependency is a binary/library cmd = 'which %(dep)s || locate --regexp "/%(dep)s$"' % {'dep': dep} found = run_cmd(cmd, simple=True, log_all=False, log_ok=False) return found
def configure_step(self): """Configure ParMETIS build. For versions of ParMETIS < 4 , METIS is a seperate build New versions of ParMETIS include METIS Run 'cmake' in the build dir to get rid of a 'user friendly' help message that is displayed without this step. """ if LooseVersion(self.version) >= LooseVersion("4"): # tested with 4.0.2, now actually requires cmake to be run first # for both parmetis and metis self.cfg.update('configopts', '-DMETIS_PATH=../metis -DGKLIB_PATH=../metis/GKlib') self.cfg.update('configopts', '-DOPENMP="%s"' % self.toolchain.get_flag('openmp')) if self.toolchain.options.get('usempi', None): self.cfg.update('configopts', '-DCMAKE_C_COMPILER="$MPICC"') if self.toolchain.options['pic']: self.cfg.update('configopts', '-DCMAKE_C_FLAGS="-fPIC"') self.parmetis_builddir = 'build' try: os.chdir(self.parmetis_builddir) cmd = 'cmake .. %s -DCMAKE_INSTALL_PREFIX="%s"' % (self.cfg['configopts'], self.installdir) run_cmd(cmd, log_all=True, simple=True) os.chdir(self.cfg['start_dir']) except OSError, err: self.log.error("Running cmake in %s failed: %s" % (self.parmetis_builddir, err))
def install_step(self): """Custom install procedure for VSC-tools.""" args = "install --prefix=%(path)s --install-lib=%(path)s/lib" % {'path': self.installdir} pylibdir = os.path.join(self.installdir, 'lib') env.setvar('PYTHONPATH', '%s:%s' % (pylibdir, os.getenv('PYTHONPATH'))) try: os.mkdir(pylibdir) pwd = os.getcwd() pkg_list = ['-'.join(src['name'].split('-')[0:-1]) for src in self.src if src['name'].startswith('vsc')] for pkg in pkg_list: os.chdir(self.builddir) sel_dirs = [d for d in glob.glob("%s-[0-9][0-9.]*" % pkg)] if not len(sel_dirs) == 1: self.log.error("Found none or more than one %s dir in %s: %s" % (pkg, self.builddir, sel_dirs)) os.chdir(os.path.join(self.builddir, sel_dirs[0])) cmd = "python setup.py %s" % args run_cmd(cmd, log_all=True, simple=True, log_output=True) os.chdir(pwd) except OSError, err: self.log.error("Failed to install: %s" % err)
def install_R_package(self, cmd, inp=None): """Install R package as specified, and check for errors.""" cmdttdouterr, _ = run_cmd(cmd, log_all=True, simple=False, inp=inp, regexp=False) cmderrors = parse_log_for_error(cmdttdouterr, regExp="^ERROR:") if cmderrors: cmd = "R -q --no-save" stdin = """ remove.library(%s) """ % self.name # remove package if errors were detected # it's possible that some of the dependencies failed, but the package itself was installed run_cmd(cmd, log_all=False, log_ok=False, simple=False, inp=stdin, regexp=False) self.log.error( "Errors detected during installation of R package %s!" % self.name) else: self.log.debug("R package %s installed succesfully" % self.name)
def install_step(self): """ Actual installation - create silent cfg file - execute command """ silent = \ """ [itac] INSTALLDIR=%(ins)s LICENSEPATH=%(lic)s INSTALLMODE=NONRPM INSTALLUSER=NONROOT INSTALL_ITA=YES INSTALL_ITC=YES DEFAULT_MPI=%(mpi)s EULA=accept """ % {'lic': self.license_file, 'ins': self.installdir, 'mpi': self.cfg['preferredmpi']} # already in correct directory silentcfg = os.path.join(os.getcwd(), "silent.cfg") f = open(silentcfg, 'w') f.write(silent) f.close() tmpdir = os.path.join(os.getcwd(), self.version, 'mytmpdir') try: os.makedirs(tmpdir) except: self.log.exception("Directory %s can't be created" % (tmpdir)) cmd = "./install.sh --tmp-dir=%s --silent=%s" % (tmpdir, silentcfg) run_cmd(cmd, log_all=True, simple=True)
def get_cpu_vendor(): """Try to detect the cpu identifier will return INTEL or AMD constant """ regexp = re.compile(r"^vendor_id\s+:\s*(?P<vendorid>\S+)\s*$", re.M) VENDORS = {"GenuineIntel": INTEL, "AuthenticAMD": AMD} # Linux txt = read_file("/proc/cpuinfo", log_error=False) if txt is not None: arch = regexp.search(txt).groupdict()["vendorid"] if arch in VENDORS: return VENDORS[arch] # Darwin (OS X) out, exitcode = run_cmd("sysctl -n machdep.cpu.vendor") out = out.strip() if not exitcode and out and out in VENDORS: return VENDORS[out] # BSD out, exitcode = run_cmd("sysctl -n hw.model") out = out.strip() if not exitcode and out: return out.split(" ")[0] raise SystemToolsException("Could not detect cpu vendor")
def configure_step(self): """Configure build: <single-line description how this deviates from standard configure>""" # set generic make options self.cfg.update('makeopts', 'CC="%s" OPTFLAGS="%s"' % (os.getenv('MPICC'), os.getenv('CFLAGS'))) if LooseVersion(self.version) >= LooseVersion("3.2"): # set correct start_dir dir, and change into it self.cfg['start_dir'] = os.path.join(self.cfg['start_dir'],'src') try: os.chdir(self.cfg['start_dir']) except OSError, err: self.log.error("Failed to change to correct source dir %s: %s" % (self.cfg['start_dir'], err)) # run autoconf to generate configure script cmd = "autoconf" run_cmd(cmd) # set config opts beagle = get_software_root('BEAGLE') if beagle: self.cfg.update('configopts', '--with-beagle=%s' % beagle) else: self.log.error("BEAGLE module not loaded?") if self.toolchain.options['usempi']: self.cfg.update('configopts', '--enable-mpi') # configure super(EB_MrBayes, self).configure_step()
def configure_step(self, *args, **kwargs): """Configure build using 'make config' (only for recent versions (>= v5)).""" if LooseVersion(self.version) >= LooseVersion("5"): cmd = "make config prefix=%s" % self.installdir run_cmd(cmd, log_all=True, simple=True)
def test_step(self): """Test the compilation - default: None """ extrapath = "" testinstalldir = os.path.join(self.builddir, "mytemporarytestinstalldir") if self.testinstall: # Install in test directory and export PYTHONPATH try: os.makedirs(testinstalldir) except OSError: self.log.exception("Creating testinstalldir %s failed" % testinstalldir) ppath = "%s/reallib" % testinstalldir cmd = "python setup.py install --install-scripts=%s --install-purelib=%s %s" % \ (testinstalldir, ppath, self.installopts) run_cmd(cmd, log_all=True, simple=True) if os.environ.has_key('PYTHONPATH'): extrapath = "export PYTHONPATH=%s:%s && " % (ppath, os.environ['PYTHONPATH']) else: extrapath = "export PYTHONPATH=%s && " % ppath if self.runtest: cmd = "%s%s" % (extrapath, self.runtest) run_cmd(cmd, log_all=True, simple=True) if self.testinstall: try: rmtree2(testinstalldir) except OSError, err: self.log.exception("Removing testinstalldir %s failed: %s" % (testinstalldir, err))
def chrysalis(self, run=True): """Install procedure for Chrysalis.""" make_flags = "COMPILER='%s' CPLUSPLUS='%s' CC='%s' " % ( os.getenv('CXX'), os.getenv('CXX'), os.getenv('CC')) make_flags += "OMP_FLAGS='%s' OMP_LINK='%s' " % ( self.toolchain.get_flag('openmp'), os.getenv('LIBS')) make_flags += "OPTIM='-O1' SYS_OPT='-O2 %s' " % self.toolchain.get_flag( 'optarch') make_flags += "OPEN_MP=yes UNSUPPORTED=yes DEBUG=no QUIET=yes" if run: self.log.info("Begin Chrysalis") dst = os.path.join(self.cfg['start_dir'], 'Chrysalis') try: os.chdir(dst) except OSError, err: self.log.error( "Chrysalis: failed to change to dst dir %s: %s" % (dst, err)) run_cmd("make clean") run_cmd("make %s" % make_flags) self.log.info("End Chrysalis")
def get_cpu_vendor(): """Try to detect the cpu identifier will return INTEL or AMD """ regexp = re.compile(r"^vendor_id\s+:\s*(?P<vendorid>\S+)\s*$", re.M) # Linux try: arch = regexp.search(open("/proc/cpuinfo").read()).groupdict()['vendorid'] if arch in VENDORS: return VENDORS[arch] except IOError: pass # Darwin (OS X) out, exitcode = run_cmd("sysctl -n machdep.cpu.vendor") out = out.strip() if not exitcode and out and out in VENDORS: return VENDORS[out] # BSD out, exitcode = run_cmd("sysctl -n hw.model") out = out.strip() if not exitcode and out: return out.split(' ')[0] raise SystemToolsException("Could not detect cpu vendor")
def configure_step(self): """Configure MUMmer build by running make check and setting make options.""" cmd = "%s make check %s" % (self.cfg['preconfigopts'], self.cfg['configopts']) run_cmd(cmd, log_all=True, simple=True, log_output=True) self.cfg.update('makeopts', 'all')
def build_step(self): """Build OpenFOAM using make after sourcing script to set environment.""" precmd = "source %s" % os.path.join(self.builddir, self.openfoamdir, "etc", "bashrc") # make directly in install directory cmd_tmpl = "%(precmd)s && %(premakeopts)s %(makecmd)s" % { 'precmd': precmd, 'premakeopts': self.cfg['premakeopts'], 'makecmd': os.path.join(self.builddir, self.openfoamdir, '%s'), } if 'extend' in self.name.lower() and LooseVersion( self.version) >= LooseVersion('3.0'): qa = { "Proceed without compiling ParaView [Y/n]": 'Y', "Proceed without compiling cudaSolvers? [Y/n]": 'Y', } noqa = [ ".* -o .*\.o", "checking .*", "warning.*", "configure: creating.*", "%s .*" % os.environ['CC'], ] run_cmd_qa(cmd_tmpl % 'Allwmake.firstInstall', qa, no_qa=noqa, log_all=True, simple=True) else: run_cmd(cmd_tmpl % 'Allwmake', log_all=True, simple=True, log_output=True)
def build_step(self): """Build OpenFOAM using make after sourcing script to set environment.""" precmd = "source %s" % os.path.join(self.builddir, self.openfoamdir, "etc", "bashrc") # make directly in install directory cmd_tmpl = "%(precmd)s && %(premakeopts)s %(makecmd)s" % { 'precmd': precmd, 'premakeopts': self.cfg['premakeopts'], 'makecmd': os.path.join(self.builddir, self.openfoamdir, '%s'), } if 'extend' in self.name.lower() and LooseVersion(self.version) >= LooseVersion('3.0'): qa = { "Proceed without compiling ParaView [Y/n]": 'Y', "Proceed without compiling cudaSolvers? [Y/n]": 'Y', } noqa = [ ".* -o .*\.o", "checking .*", "warning.*", "configure: creating.*", "%s .*" % os.environ['CC'], "wmake .*", ] run_cmd_qa(cmd_tmpl % 'Allwmake.firstInstall', qa, no_qa=noqa, log_all=True, simple=True) else: run_cmd(cmd_tmpl % 'Allwmake', log_all=True, simple=True, log_output=True)
def get_cpu_vendor(): """Try to detect the cpu identifier will return INTEL or AMD constant """ regexp = re.compile(r"^vendor_id\s+:\s*(?P<vendorid>\S+)\s*$", re.M) VENDORS = { 'GenuineIntel': INTEL, 'AuthenticAMD': AMD, } # Linux txt = read_file("/proc/cpuinfo", log_error=False) if txt is not None: arch = regexp.search(txt).groupdict()['vendorid'] if arch in VENDORS: return VENDORS[arch] # Darwin (OS X) out, exitcode = run_cmd("sysctl -n machdep.cpu.vendor") out = out.strip() if not exitcode and out and out in VENDORS: return VENDORS[out] # BSD out, exitcode = run_cmd("sysctl -n hw.model") out = out.strip() if not exitcode and out: return out.split(' ')[0] raise SystemToolsException("Could not detect cpu vendor")
def install_step(self): """ Install by copying files over to the right places. Also create symlinks where expected by other software (Lib directory). """ includedir = os.path.join(self.installdir, 'include') libdir = os.path.join(self.installdir, 'lib') if LooseVersion(self.version) >= LooseVersion("4"): # includedir etc changed in v4, use a normal make install cmd = "make install %s" % self.cfg['installopts'] try: os.chdir(self.parmetis_builddir) run_cmd(cmd, log_all=True, simple=True) os.chdir(self.cfg['start_dir']) except OSError, err: self.log.error("Running '%s' in %s failed: %s" % (cmd, self.parmetis_builddir, err)) # libraries try: src = os.path.join(self.cfg['start_dir'], 'build', 'libmetis', 'libmetis.a') dst = os.path.join(libdir, 'libmetis.a') shutil.copy2(src, dst) except OSError, err: self.log.error("Copying files to installation dir failed: %s" % err)
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 build_step(self): """Build by running build_step, but with some special options for SCOTCH depending on the compiler.""" ccs = os.environ['CC'] ccp = os.environ['MPICC'] ccd = os.environ['MPICC'] cflags = "-fPIC -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME" if self.toolchain.comp_family() == toolchain.GCC: #@UndefinedVariable cflags += " -Drestrict=__restrict" else: cflags += " -restrict -DIDXSIZE64" if not self.toolchain.mpi_family() in [ toolchain.INTELMPI, toolchain.QLOGICMPI ]: #@UndefinedVariable cflags += " -DSCOTCH_PTHREAD" # actually build apps = ['scotch', 'ptscotch'] if LooseVersion(self.version) >= LooseVersion('6.0'): # separate target for esmumps in recent versions apps.extend(['esmumps', 'ptesmumps']) for app in apps: cmd = 'make CCS="%s" CCP="%s" CCD="%s" CFLAGS="%s" %s' % ( ccs, ccp, ccd, cflags, app) run_cmd(cmd, log_all=True, simple=True)
def make_install(self): """ Actual installation - create silent cfg file - execute command """ silent = \ """ [itac] INSTALLDIR=%(ins)s LICENSEPATH=%(lic)s INSTALLMODE=NONRPM INSTALLUSER=NONROOT INSTALL_ITA=YES INSTALL_ITC=YES DEFAULT_MPI=%(mpi)s EULA=accept """ % {'lic': self.license, 'ins': self.installdir, 'mpi': self.getcfg('preferredmpi')} # already in correct directory silentcfg = os.path.join(os.getcwd(), "silent.cfg") f = open(silentcfg, 'w') f.write(silent) f.close() tmpdir = os.path.join(os.getcwd(), self.version(), 'mytmpdir') try: os.makedirs(tmpdir) except: self.log.exception("Directory %s can't be created" % (tmpdir)) cmd = "./install.sh --tmp-dir=%s --silent=%s" % (tmpdir, silentcfg) run_cmd(cmd, log_all=True, simple=True)
def build_step(self): """Customize the build step by adding compiler-specific flags to the build command.""" comp_fam = self.toolchain.comp_family() if comp_fam == toolchain.INTELCOMP: # @UndefinedVariable cmd = "python setup.py build --compiler=intel --fcompiler=intelem" elif comp_fam in [toolchain.GCC, toolchain.CLANGGCC]: # @UndefinedVariable cmdprefix = "" ldflags = os.getenv('LDFLAGS') if ldflags: # LDFLAGS should not be set when building numpy/scipy, because it overwrites whatever numpy/scipy sets # see http://projects.scipy.org/numpy/ticket/182 # don't unset it with os.environ.pop('LDFLAGS'), doesn't work in Python 2.4, # see http://bugs.python.org/issue1287 cmdprefix = "unset LDFLAGS && " self.log.debug("LDFLAGS was %s, will be cleared before %s build with '%s'" % (self.name, ldflags, cmdprefix)) cmd = "%s python setup.py build --fcompiler=gnu95" % cmdprefix else: self.log.error("Unknown family of compilers being used: %s" % comp_fam) run_cmd(cmd, log_all=True, simple=True)
def check_os_dependency(dep): """ Check if dependency is available from OS. """ # - uses rpm -q and dpkg -s --> can be run as non-root!! # - fallback on which # - should be extended to files later? cmd = None if get_os_name() in ['debian', 'ubuntu']: if which('dpkg'): cmd = "dpkg -s %s" % dep else: # OK for get_os_name() == redhat, fedora, RHEL, SL, centos if which('rpm'): cmd = "rpm -q %s" % dep found = None if cmd is not None: found = run_cmd(cmd, simple=True, log_all=False, log_ok=False) if found is None: # fallback for when os-dependency is a binary/library found = which(dep) # try locate if it's available if found is None and which('locate'): cmd = 'locate --regexp "/%s$"' % dep found = run_cmd(cmd, simple=True, log_all=False, log_ok=False) return found
def build_step(self, verbose=False): """Build ParMETIS (and METIS) using build_step.""" paracmd = '' if self.cfg['parallel']: paracmd = "-j %s" % self.cfg['parallel'] self.cfg.update('makeopts', 'LIBDIR=""') if self.toolchain.options['usempi']: if self.toolchain.options['pic']: self.cfg.update('makeopts', 'CC="$MPICC -fPIC"') else: self.cfg.update('makeopts', 'CC="$MPICC"') cmd = "%s make %s %s" % (self.cfg['premakeopts'], paracmd, self.cfg['makeopts']) # run make in build dir as well for recent version if LooseVersion(self.version) >= LooseVersion("4"): try: os.chdir(self.parmetis_builddir) run_cmd(cmd, log_all=True, simple=True, log_output=verbose) os.chdir(self.cfg['start_dir']) except OSError, err: self.log.error("Running cmd '%s' in %s failed: %s" % (cmd, self.parmetis_builddir, err))
def install_step(self): """Install ABAQUS using 'setup'.""" os.chdir(self.builddir) cmd = "%s/%s-%s/setup" % (self.builddir, self.name, self.version.split('-')[0]) cmd += " -nosystemcheck -replay %s" % self.replayfile run_cmd(cmd, log_all=True, simple=True)
def install_step(self): """ Install by copying files over to the right places. Also create symlinks where expected by other software (Lib directory). """ includedir = os.path.join(self.installdir, 'include') libdir = os.path.join(self.installdir, 'lib') if LooseVersion(self.version) >= LooseVersion("4"): # includedir etc changed in v4, use a normal make install cmd = "make install %s" % self.cfg['installopts'] try: os.chdir(self.parmetis_builddir) run_cmd(cmd, log_all=True, simple=True) os.chdir(self.cfg['start_dir']) except OSError, err: self.log.error("Running '%s' in %s failed: %s" % (cmd, self.parmetis_builddir, err)) # libraries try: src = os.path.join(self.cfg['start_dir'], 'build' ,'libmetis' ,'libmetis.a') dst = os.path.join(libdir, 'libmetis.a') shutil.copy2(src, dst) except OSError, err: self.log.error("Copying files to installation dir failed: %s" % err)
def install_step(self): """Custom installation procedure for RPMs into a custom prefix.""" try: os.chdir(self.installdir) os.mkdir('rpm') except: self.log.error("Can't create rpm dir in install dir %s" % self.installdir) cmd = "rpm --initdb --dbpath /rpm --root %s" % self.installdir run_cmd(cmd, log_all=True, simple=True) force = '' if self.cfg['force']: force = '--force' postinstall = '--nopost' if self.cfg['postinstall']: postinstall = '' preinstall = '--nopre' if self.cfg['preinstall']: preinstall = '' if self.rebuildRPM: cmd_tpl = "rpm -i --dbpath %(inst)s/rpm %(force)s --relocate /=%(inst)s " \ "%(pre)s %(post)s --nodeps --ignorearch %(rpm)s" else: cmd_tpl = "rpm -i --dbpath /rpm %(force)s --root %(inst)s --relocate /=%(inst)s " \ "%(pre)s %(post)s --nodeps %(rpm)s" # exception for user root: # --relocate is not necesarry -> --root will relocate more than enough # cmd_tpl = "rpm -i --dbpath /rpm %(force)s --root %(inst)s %(pre)s %(post)s --nodeps %(rpm)s" for rpm in self.src: cmd = cmd_tpl % { 'inst': self.installdir, 'rpm': rpm['path'], 'force': force, 'pre': preinstall, 'post': postinstall, } run_cmd(cmd, log_all=True, simple=True) for path in self.cfg['makesymlinks']: # allow globs, always use first hit. # also verify links existince realdirs = glob.glob(path) if realdirs: if len(realdirs) > 1: self.log.debug( "More then one match found for symlink glob %s, using first (all: %s)" % (path, realdirs)) os.symlink( realdirs[0], os.path.join(self.installdir, os.path.basename(path))) else: self.log.debug("No match found for symlink glob %s." % path)
def install_step(self): """Install CP2K: clean, and copy lib directory to install dir""" run_cmd("./do_clean") try: shutil.copytree('lib', os.path.join(self.installdir, 'lib')) except Exception, err: self.log.error("Something went wrong during dir lib copying to installdir: %s" % err)
def build_step(self, name=None): """Build toy.""" if name is None: name = self.name run_cmd('%(premakeopts)s gcc %(name)s.c -o %(name)s' % { 'name': name, 'premakeopts': self.cfg['premakeopts'], })
def install_step(self): """Install CP2K: clean, and copy lib directory to install dir""" run_cmd("./do_clean") try: shutil.copytree("lib", os.path.join(self.installdir, "lib")) except Exception, err: self.log.error("Something went wrong during dir lib copying to installdir: %s" % err)
def prepmodinc(self): """Prepare list of module files""" self.log.debug("Preparing module files") imkl = get_software_root('IMKL') if imkl: # prepare modinc target path modincpath = os.path.join( os.path.dirname(os.path.normpath(self.cfg['start_dir'])), 'modinc') self.log.debug("Preparing module files in %s" % modincpath) try: os.mkdir(modincpath) except OSError, err: self.log.error( "Failed to create directory for module include files: %s" % err) # get list of modinc source files modincdir = os.path.join(imkl, self.cfg["modincprefix"], 'include') if type(self.cfg["modinc"]) == list: modfiles = [ os.path.join(modincdir, x) for x in self.cfg["modinc"] ] elif type(self.cfg["modinc"]) == bool and type(self.cfg["modinc"]): modfiles = glob.glob(os.path.join(modincdir, '*.f90')) else: self.log.error( "prepmodinc: Please specify either a boolean value " "or a list of files in modinc (found: %s)." % self.cfg["modinc"]) f77 = os.getenv('F77') if not f77: self.log.error( "F77 environment variable not set, can't continue.") # create modinc files for f in modfiles: if f77.endswith('ifort'): cmd = "%s -module %s -c %s" % (f77, modincpath, f) elif f77 in ['gfortran', 'mpif77']: cmd = "%s -J%s -c %s" % (f77, modincpath, f) else: self.log.error( "prepmodinc: Unknown value specified for F77 (%s)" % f77) run_cmd(cmd, log_all=True, simple=True) return modincpath
def configure_step(self): """Custom configuration procedure for ESMF through environment variables.""" env.setvar('ESMF_DIR', self.cfg['start_dir']) env.setvar('ESMF_INSTALL_PREFIX', self.installdir) env.setvar('ESMF_INSTALL_BINDIR', 'bin') env.setvar('ESMF_INSTALL_LIBDIR', 'lib') env.setvar('ESMF_INSTALL_MODDIR', 'mod') # specify compiler comp_family = self.toolchain.comp_family() if comp_family in [toolchain.GCC]: compiler = 'gfortran' else: compiler = comp_family.lower() env.setvar('ESMF_COMPILER', compiler) # specify MPI communications library comm = None mpi_family = self.toolchain.mpi_family() if mpi_family in [toolchain.QLOGICMPI]: comm = 'mpich2' else: comm = mpi_family.lower() env.setvar('ESMF_COMM', comm) # specify decent LAPACK lib env.setvar('ESMF_LAPACK', 'user') env.setvar('ESMF_LAPACK_LIBS', '%s %s' % (os.getenv('LDFLAGS'), os.getenv('LIBLAPACK_MT'))) # specify netCDF netcdf = get_software_root('netCDF') if netcdf: env.setvar('ESMF_NETCDF', 'user') netcdf_libs = ['-L%s/lib' % netcdf, '-lnetcdf'] # Fortran netcdff = get_software_root('netCDF-Fortran') if netcdff: netcdf_libs = ["-L%s/lib" % netcdff ] + netcdf_libs + ["-lnetcdff"] else: netcdf_libs.append('-lnetcdff') # C++ netcdfcxx = get_software_root('netCDF-C++') if netcdfcxx: netcdf_libs = ["-L%s/lib" % netcdfcxx ] + netcdf_libs + ["-lnetcdf_c++"] else: netcdf_libs.append('-lnetcdf_c++') env.setvar('ESMF_NETCDF_LIBS', ' '.join(netcdf_libs)) # 'make info' provides useful debug info cmd = "make info" run_cmd(cmd, log_all=True, simple=True, log_ok=True)
def configure_step(self): """Custom configuration procedure for ALADIN.""" # build auxiliary libraries auxlibs_dir = None my_gnu = None if self.toolchain.comp_family() == toolchain.GCC: my_gnu = 'y' # gfortran for var in ['CFLAGS', 'CXXFLAGS', 'F90FLAGS', 'FFLAGS']: flags = os.getenv(var) env.setvar(var, "%s -fdefault-real-8 -fdefault-double-8" % flags) self.log.info("Updated %s to '%s'" % (var, os.getenv(var))) elif self.toolchain.comp_family() == toolchain.INTELCOMP: my_gnu = 'i' # icc/ifort else: self.log.error( "Don't know how to set 'my_gnu' variable in auxlibs build script." ) self.log.info("my_gnu set to '%s'" % my_gnu) tmp_installroot = tempfile.mkdtemp(prefix='aladin_auxlibs_') try: cwd = os.getcwd() os.chdir(self.builddir) builddirs = os.listdir(self.builddir) auxlibs_dir = [ x for x in builddirs if x.startswith('auxlibs_installer') ][0] os.chdir(auxlibs_dir) auto_driver = 'driver_automatic' for line in fileinput.input(auto_driver, inplace=1, backup='.orig.eb'): line = re.sub(r"^(my_gnu\s*=\s*).*$", r"\1%s" % my_gnu, line) line = re.sub(r"^(my_r32\s*=\s*).*$", r"\1n", line) # always 64-bit real precision line = re.sub(r"^(my_readonly\s*=\s*).*$", r"\1y", line) # make libs read-only after build line = re.sub(r"^(my_installroot\s*=\s*).*$", r"\1%s" % tmp_installroot, line) sys.stdout.write(line) run_cmd("./%s" % auto_driver) os.chdir(cwd) except OSError, err: self.log.error("Failed to build ALADIN: %s" % err)
def configure_step(self): """Custom configuration for ROOT, add configure options.""" self.cfg.update('configopts', "--etcdir=%s/etc/root " % self.installdir) cmd = "./configure %s --prefix=%s %s" % (self.cfg['arch'], self.installdir, self.cfg['configopts']) run_cmd(cmd, log_all=True, log_ok=True, simple=True)
def configure_step(self): """Custom configuration procedure for ESMF through environment variables.""" env.setvar('ESMF_DIR', self.cfg['start_dir']) env.setvar('ESMF_INSTALL_PREFIX', self.installdir) env.setvar('ESMF_INSTALL_BINDIR', 'bin') env.setvar('ESMF_INSTALL_LIBDIR', 'lib') env.setvar('ESMF_INSTALL_MODDIR', 'mod') # specify compiler comp_family = self.toolchain.comp_family() if comp_family in [toolchain.GCC]: compiler = 'gfortran' else: compiler = comp_family.lower() env.setvar('ESMF_COMPILER', compiler) # specify MPI communications library comm = None mpi_family = self.toolchain.mpi_family() if mpi_family in [toolchain.QLOGICMPI]: comm = 'mpich2' else: comm = mpi_family.lower() env.setvar('ESMF_COMM', comm) # specify decent LAPACK lib env.setvar('ESMF_LAPACK', 'user') env.setvar('ESMF_LAPACK_LIBS', '%s %s' % (os.getenv('LDFLAGS'), os.getenv('LIBLAPACK'))) # specify netCDF netcdf = get_software_root('netCDF') if netcdf: env.setvar('ESMF_NETCDF', 'user') netcdf_libs = ['-L%s/lib' % netcdf, '-lnetcdf'] # Fortran netcdff = get_software_root('netCDF-Fortran') if netcdff: netcdf_libs = ["-L%s/lib" % netcdff] + netcdf_libs + ["-lnetcdff"] else: netcdf_libs.append('-lnetcdff') # C++ netcdfcxx = get_software_root('netCDF-C++') if netcdfcxx: netcdf_libs = ["-L%s/lib" % netcdfcxx] + netcdf_libs + ["-lnetcdf_c++"] else: netcdf_libs.append('-lnetcdf_c++') env.setvar('ESMF_NETCDF_LIBS', ' '.join(netcdf_libs)) # 'make info' provides useful debug info cmd = "make info" run_cmd(cmd, log_all=True, simple=True, log_ok=True)
def build_step(self): """ First we need to rename a few things, s.a. http://wiki.ci.uchicago.edu/Beagle/BuildingSoftware -> "Cufflinks" """ cmd = "for x in src/*.cpp src/*.h; do sed \'s/foreach/for_each/\' $x > src/x; mv src/x $x; done" run_cmd(cmd, log_all=True, simple=True) cmd = "sed \'s/#include <boost\/for_each.hpp>/#include <boost\/foreach.hpp>/\' src/common.h > src/x && mv src/x src/common.h" run_cmd(cmd, log_all=True, simple=True) Application.make(self)
def configure_step(self, cmd_prefix=''): """ need to run autogen.sh first """ os.chdir(os.path.join(self.cfg['start_dir'],"warg")) cmd = "./autogen.sh" try: run_cmd(cmd, log_all=True, simple=True) except OSError, err: self.log.error("Error running %s." % cmd)
def install_step(self): """Custom installation procedure for RPMs into a custom prefix.""" try: os.chdir(self.installdir) os.mkdir('rpm') except: self.log.error("Can't create rpm dir in install dir %s" % self.installdir) cmd = "rpm --initdb --dbpath /rpm --root %s" % self.installdir run_cmd(cmd, log_all=True, simple=True) force='' if self.cfg['force']: force = '--force' postinstall = '--nopost' if self.cfg['postinstall']: postinstall = '' preinstall = '--nopre' if self.cfg['preinstall']: preinstall = '' if self.rebuildRPM: cmd_tpl = "rpm -i --dbpath %(inst)s/rpm %(force)s --relocate /=%(inst)s " \ "%(pre)s %(post)s --nodeps %(rpm)s" else: cmd_tpl = "rpm -i --dbpath /rpm %(force)s --root %(inst)s --relocate /=%(inst)s " \ "%(pre)s %(post)s --nodeps %(rpm)s" # exception for user root: # --relocate is not necesarry -> --root will relocate more than enough # cmd_tpl = "rpm -i --dbpath /rpm %(force)s --root %(inst)s %(pre)s %(post)s --nodeps %(rpm)s" for rpm in self.src: cmd = cmd_tpl % { 'inst': self.installdir, 'rpm': rpm['path'], 'force': force, 'pre': preinstall, 'post': postinstall } run_cmd(cmd, log_all=True, simple=True) for path in self.cfg['makesymlinks']: # allow globs, always use first hit. # also verify links existince realdirs = glob.glob(path) if realdirs: if len(realdirs) > 1: self.log.debug("More then one match found for symlink glob %s, using first (all: %s)" % (path, realdirs)) os.symlink(realdirs[0], os.path.join(self.installdir, os.path.basename(path))) else: self.log.debug("No match found for symlink glob %s." % path)
def build_step(self): """Build OpenFOAM using make after sourcing script to set environment.""" nameversion = "%s-%s"%(self.name, self.version) precmd = "source %s" % os.path.join(self.builddir, nameversion, "etc", "bashrc") # make directly in install directory cmd="%(precmd)s && %(premakeopts)s %(makecmd)s"%{'precmd':precmd, 'premakeopts':self.cfg['premakeopts'], 'makecmd':os.path.join(self.builddir, nameversion, "Allwmake")} run_cmd(cmd,log_all=True,simple=True,log_output=True)
def extract_step(self): """Unpack WIEN2k sources using gunzip and provided expand_lapw script.""" super(EB_WIEN2k, self).extract_step() cmd = "gunzip *gz" run_cmd(cmd, log_all=True, simple=True) cmd = "./expand_lapw" qanda = {"continue (y/n)": "y"} no_qa = ["tar -xf.*", ".*copied and linked.*"] run_cmd_qa(cmd, qanda, no_qa=no_qa, log_all=True, simple=True)
def build_step(self): """Build and install Chapel""" # enable parallel build p = self.cfg['parallel'] self.par = "" if p: self.par = "-j %s" % p # build chapel cmd = "make %s" % self.par run_cmd(cmd, log_all=True, simple=True, log_output=True)
def install_step(self): """ Actual installation - create silent cfg file - execute command """ if LooseVersion(self.version) >= LooseVersion('4.0.1'): # impi starting from version 4.0.1.x uses standard installation procedure. super(EB_impi, self).install_step() return None else: # impi up until version 4.0.0.x uses custom installation procedure. silent = \ """ [mpi] INSTALLDIR=%(ins)s LICENSEPATH=%(lic)s INSTALLMODE=NONRPM INSTALLUSER=NONROOT UPDATE_LD_SO_CONF=NO PROCEED_WITHOUT_PYTHON=yes AUTOMOUNTED_CLUSTER=yes EULA=accept [mpi-rt] INSTALLDIR=%(ins)s LICENSEPATH=%(lic)s INSTALLMODE=NONRPM INSTALLUSER=NONROOT UPDATE_LD_SO_CONF=NO PROCEED_WITHOUT_PYTHON=yes AUTOMOUNTED_CLUSTER=yes EULA=accept """ % {'lic':self.license_file, 'ins':self.installdir} # already in correct directory silentcfg = os.path.join(os.getcwd(), "silent.cfg") try: f = open(silentcfg, 'w') f.write(silent) f.close() except: self.log.exception("Writing silent cfg file %s failed." % silent) tmpdir = os.path.join(os.getcwd(), self.version, 'mytmpdir') try: os.makedirs(tmpdir) except: self.log.exception("Directory %s can't be created" % (tmpdir)) cmd = "./install.sh --tmp-dir=%s --silent=%s" % (tmpdir, silentcfg) run_cmd(cmd, log_all=True, simple=True)
def configure_step(self): """Custom configuration procedure for ALADIN.""" # unset $LIBRARY_PATH set by modules of dependencies, because it may screw up linking if 'LIBRARY_PATH' in os.environ: self.log.debug("Unsetting $LIBRARY_PATH (was: %s)" % os.environ['LIBRARY_PATH']) self.orig_library_path = os.environ.pop('LIBRARY_PATH') # build auxiliary libraries auxlibs_dir = None my_gnu = None if self.toolchain.comp_family() == toolchain.GCC: my_gnu = 'y' # gfortran for var in ['CFLAGS', 'CXXFLAGS', 'F90FLAGS', 'FFLAGS']: flags = os.getenv(var) env.setvar(var, "%s -fdefault-real-8 -fdefault-double-8" % flags) self.log.info("Updated %s to '%s'" % (var, os.getenv(var))) elif self.toolchain.comp_family() == toolchain.INTELCOMP: my_gnu = 'i' # icc/ifort else: self.log.error("Don't know how to set 'my_gnu' variable in auxlibs build script.") self.log.info("my_gnu set to '%s'" % my_gnu) tmp_installroot = tempfile.mkdtemp(prefix='aladin_auxlibs_') try: cwd = os.getcwd() os.chdir(self.builddir) builddirs = os.listdir(self.builddir) auxlibs_dir = [x for x in builddirs if x.startswith('auxlibs_installer')][0] os.chdir(auxlibs_dir) auto_driver = 'driver_automatic' for line in fileinput.input(auto_driver, inplace=1, backup='.orig.eb'): line = re.sub(r"^(my_gnu\s*=\s*).*$", r"\1%s" % my_gnu, line) line = re.sub(r"^(my_r32\s*=\s*).*$", r"\1n", line) # always 64-bit real precision line = re.sub(r"^(my_readonly\s*=\s*).*$", r"\1y", line) # make libs read-only after build line = re.sub(r"^(my_installroot\s*=\s*).*$", r"\1%s" % tmp_installroot, line) sys.stdout.write(line) run_cmd("./%s" % auto_driver) os.chdir(cwd) except OSError, err: self.log.error("Failed to build ALADIN: %s" % err)
def make_install(self): """ Actual installation - create silent cfg file - execute command """ if LooseVersion(self.version()) >= LooseVersion('4.0.1'): #impi starting from version 4.0.1.x uses standard installation procedure. IntelBase.make_install(self) return None else: #impi up until version 4.0.0.x uses custom installation procedure. silent = \ """ [mpi] INSTALLDIR=%(ins)s LICENSEPATH=%(lic)s INSTALLMODE=NONRPM INSTALLUSER=NONROOT UPDATE_LD_SO_CONF=NO PROCEED_WITHOUT_PYTHON=yes AUTOMOUNTED_CLUSTER=yes EULA=accept [mpi-rt] INSTALLDIR=%(ins)s LICENSEPATH=%(lic)s INSTALLMODE=NONRPM INSTALLUSER=NONROOT UPDATE_LD_SO_CONF=NO PROCEED_WITHOUT_PYTHON=yes AUTOMOUNTED_CLUSTER=yes EULA=accept """ % {'lic':self.license, 'ins':self.installdir} # already in correct directory silentcfg = os.path.join(os.getcwd(), "silent.cfg") try: f = open(silentcfg, 'w') f.write(silent) f.close() except: self.log.exception("Writing silent cfg file %s failed." % silent) tmpdir = os.path.join(os.getcwd(), self.version(), 'mytmpdir') try: os.makedirs(tmpdir) except: self.log.exception("Directory %s can't be created" % (tmpdir)) cmd = "./install.sh --tmp-dir=%s --silent=%s" % (tmpdir, silentcfg) run_cmd(cmd, log_all=True, simple=True)
def configure_step(self): """ Configure Perl build: run ./Configure instead of ./configure with some different options """ configopts = ' '.join([ self.cfg['configopts'], "-Dusethreads", '-Dcc="%s"' % os.getenv('CC'), '-Dccflags="%s"' % os.getenv('CFLAGS'), '-Dinc_version_list=none', ]) cmd = './Configure -de %s -Dprefix="%s" ' % (configopts, self.installdir) run_cmd(cmd, log_all=True, simple=True)
def test_step(self): """Test Perl build via 'make test'.""" # allow escaping with runtest = False if self.cfg['runtest'] is None or self.cfg['runtest']: if isinstance(self.cfg['runtest'], basestring): cmd = "make %s" % self.cfg['runtest'] else: cmd = "make test" # specify locale to be used, to avoid that a handful of tests fail cmd = "export LC_ALL=C && %s" % cmd run_cmd(cmd, log_all=False, log_ok=False, simple=False)
def install_perl_module(self): """Install procedure for Perl modules: using either Makefile.Pl or Build.PL.""" # Perl modules have two possible installation procedures: using Makefile.PL and Build.PL # configure, build, test, install if os.path.exists('Makefile.PL'): run_cmd('%s perl Makefile.PL PREFIX=%s %s' % (self.cfg['preconfigopts'], self.installdir, self.cfg['configopts'])) ConfigureMake.build_step(self) ConfigureMake.test_step(self) ConfigureMake.install_step(self) elif os.path.exists('Build.PL'): run_cmd('%s perl Build.PL --prefix %s %s' % (self.cfg['preconfigopts'], self.installdir, self.cfg['configopts'])) run_cmd('%s perl Build build %s' % (self.cfg['prebuildopts'], self.cfg['buildopts'])) run_cmd('perl Build test') run_cmd('%s perl Build install %s' % (self.cfg['preinstallopts'], self.cfg['installopts']))
def build_step(self): """Custom build procedure for NWChem.""" # set FC self.setvar_env_makeopt('FC', os.getenv('F77')) # check whether 64-bit integers should be used, and act on it if not self.toolchain.options['i8']: if self.cfg['parallel']: self.cfg.update('makeopts', '-j %s' % self.cfg['parallel']) run_cmd("make %s 64_to_32" % self.cfg['makeopts'], simple=True, log_all=True, log_ok=True, log_output=True) self.setvar_env_makeopt('USE_64TO32', "y") # unset env vars that cause trouble during NWChem build or cause build to generate incorrect stuff for var in ['CFLAGS', 'FFLAGS', 'LIBS']: val = os.getenv(var) if val: self.log.info( "%s was defined as '%s', need to unset it to avoid problems..." % (var, val)) os.unsetenv(var) os.environ.pop(var) super(EB_NWChem, self).build_step(verbose=True) # build version info try: self.log.info("Building version info...") cwd = os.getcwd() os.chdir(os.path.join(self.cfg['start_dir'], 'src', 'util')) run_cmd("make version", simple=True, log_all=True, log_ok=True, log_output=True) run_cmd("make", simple=True, log_all=True, log_ok=True, log_output=True) os.chdir(os.path.join(self.cfg['start_dir'], 'src')) run_cmd("make link", simple=True, log_all=True, log_ok=True, log_output=True) os.chdir(cwd) except OSError, err: self.log.error("Failed to build version info: %s" % err)
def test_step(self): """Run available numpy unit tests, and more.""" super(EB_numpy, self).test_step() # temporarily install numpy, it doesn't alow to be used straight from the source dir tmpdir = tempfile.mkdtemp() cmd = "python setup.py install --prefix=%s %s" % (tmpdir, self.installopts) run_cmd(cmd, log_all=True, simple=True) try: pwd = os.getcwd() os.chdir(tmpdir) except OSError, err: self.log.error("Faild to change to %s: %s" % (tmpdir, err))
def extract_step(self): """Unpack WIEN2k sources using gunzip and provided expand_lapw script.""" super(EB_WIEN2k, self).extract_step() cmd = "gunzip *gz" run_cmd(cmd, log_all=True, simple=True) cmd = "./expand_lapw" qanda = {'continue (y/n)': 'y'} no_qa = [ 'tar -xf.*', '.*copied and linked.*', ] run_cmd_qa(cmd, qanda, no_qa=no_qa, log_all=True, simple=True)