def install_step(self):
        """Interactive install of Maple."""

        cmd = "%s/Maple%sLinuxX86_64Installer.bin" % (self.builddir, self.cfg["version"])

        qa = {
            "PRESS <ENTER> TO CONTINUE:": "",
            "DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N):": "Y",
            "ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT :": self.installdir,
            "IS THIS CORRECT? (Y/N):": "Y",
            "Do you wish to have a shortcut installed on your desktop? ->1- Yes 2- No ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::": "2",
            "->1- Single User License 2- Network License ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::": "2",
            "PRESS <ENTER> TO EXIT THE INSTALLER:": "",
            "License server (DEFAULT: ):": self.cfg["license_server"],
            "Port number (optional) (DEFAULT: ):": "",
            "->1- Configure toolbox for Matlab 2- Do not configure at this time ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::": "2",
        }

        no_qa = [
            "Graphical installers are not supported by the VM. The console mode will be used instead...",
            "Extracting the JRE from the installer archive...",
            "Launching installer...",
            "Configuring the installer for this system's environment...",
            "Unpacking the JRE...",
            "\[[-|]*",
        ]

        run_cmd_qa(cmd, qa, no_qa=no_qa, log_all=True, simple=True)
Exemplo n.º 2
0
    def build_step(self):
        """Build WIEN2k by running siteconfig_lapw script again."""

        self.log.debug('%s part II (build_step)' % self.cfgscript)

        cmd = "./%s" % self.cfgscript

        qanda = {
            'L Perl path (if not in /usr/bin/perl) Q Quit Selection:': 'R',
            'A Compile all programs S Select program Q Quit Selection:': 'A',
            'Press RETURN to continue':
            '\nQ',  # also answer on first qanda pattern with 'Q' to quit
            ' Please enter the full path of the perl program: ': '',
        }
        no_qa = [
            "%s[ \t]*.*" % os.getenv('MPIF90'),
            "%s[ \t]*.*" % os.getenv('F90'),
            "%s[ \t]*.*" % os.getenv('CC'),
            "mv[ \t]*.*",
            ".*SRC_.*",
            ".*: warning .*",
            ".*Stop.",
            "Compile time errors (if any) were:",
            "Please enter the full path of the perl program:",
        ]

        self.log.debug("no_qa for %s: %s" % (cmd, no_qa))
        run_cmd_qa(cmd, qanda, no_qa=no_qa, log_all=True, simple=True)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    def configure_step(self):
        """Configure Qt using interactive `configure` script."""

        self.cfg.update('configopts', '-release')

        comp_fam = self.toolchain.comp_family()
        if comp_fam in [toolchain.GCC]:  #@UndefinedVariable
            self.cfg.update('configopts', '-platform linux-g++-64')
        elif comp_fam in [toolchain.INTELCOMP]:  #@UndefinedVariable
            self.cfg.update('configopts', '-platform linux-icc-64')
        else:
            self.log.error("Don't know which platform to set based on compiler family.")

        cmd = "%s ./configure --prefix=%s %s" % (self.cfg['preconfigopts'], self.installdir, self.cfg['configopts'])
        qa = {
            "Type 'o' if you want to use the Open Source Edition.": 'o',
            "Do you accept the terms of either license?": 'yes',
        }
        no_qa = [
            "for .*pro",
            r"%s.*" % os.getenv('CXX').replace('+', '\\+'),  # need to escape + in 'g++'
            "Reading .*",
            "WARNING .*",
            "Project MESSAGE:.*",
            "rm -f .*",
        ]
        run_cmd_qa(cmd, qa, no_qa=no_qa, log_all=True, simple=True)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    def install_step(self):
        """Install Mathematica using install script."""
        cmd = "./%s_%s_LINUX.sh" % (self.name, self.version)
        shortver = '.'.join(self.version.split('.')[:2])
        qa_install_path = "/usr/local/Wolfram/%s/%s" % (self.name, shortver)
        qa = {
            "Enter the installation directory, or press ENTER to select %s: >" % qa_install_path:
            self.installdir,
            "Create directory (y/n)? >":
            'y',
            "or press ENTER to select /usr/local/bin: >":
            os.path.join(self.installdir, "bin"),
        }
        no_qa = [
            "Now installing.*\n\n.*\[.*\].*",
        ]
        run_cmd_qa(cmd, qa, no_qa=no_qa, log_all=True, simple=True)

        # add license server configuration file
        # some relevant documentation at http://reference.wolfram.com/mathematica/tutorial/ConfigurationFiles.html
        mathpass_path = os.path.join(self.installdir, 'Configuration',
                                     'Licensing', 'mathpass')
        try:
            # append to file, to avoid overwriting anything that might be there
            f = open(mathpass_path, "a")
            f.write("!%s\n" % self.cfg['license_server'])
            f.close()
            f = open(mathpass_path, "r")
            mathpass_txt = f.read()
            f.close()
            self.log.info("Updated license file %s: %s" %
                          (mathpass_path, mathpass_txt))
        except IOError, err:
            self.log.error("Failed to update %s with license server info: %s" %
                           (mathpass_path, err))
Exemplo n.º 7
0
    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))
Exemplo n.º 8
0
    def make_install(self):
        """Interactive install of Maple."""

        cmd = "%s/Maple%sLinuxX86_64Installer.bin" % (self.builddir, self.getcfg('version'))

        qa = {
              'PRESS <ENTER> TO CONTINUE:': '',
              'DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N):': 'Y',
              'ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT :': self.installdir,
              'IS THIS CORRECT? (Y/N):': 'Y',
              'Do you wish to have a shortcut installed on your desktop? ->1- Yes 2- No ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::': '2',
              '->1- Single User License 2- Network License ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::': '2',
              'PRESS <ENTER> TO EXIT THE INSTALLER:': '',
              'License server (DEFAULT: ):': self.getcfg('licenseServer'),
              'Port number (optional) (DEFAULT: ):': '',
              '->1- Configure toolbox for Matlab 2- Do not configure at this time ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::': '2'
             }

        no_qa = ['Graphical installers are not supported by the VM. The console mode will be used instead...',
                 'Extracting the JRE from the installer archive...',
                 'Launching installer...',
                 "Configuring the installer for this system's environment...",
                 'Unpacking the JRE...',
                 '\[[-|]*']

        run_cmd_qa(cmd, qa, no_qa=no_qa, log_all=True, simple=True)
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
    def build_step(self):
        """Build WIEN2k by running siteconfig_lapw script again."""

        self.log.debug('%s part II (build_step)' % self.cfgscript)

        cmd = "./%s" % self.cfgscript

        qanda = {
                 'L Perl path (if not in /usr/bin/perl) Q Quit Selection:': 'R',
                 'A Compile all programs S Select program Q Quit Selection:': 'A',
                 'Press RETURN to continue': '\nQ',  # also answer on first qanda pattern with 'Q' to quit
                 ' Please enter the full path of the perl program: ':'',
                }
        no_qa = [
                 "%s[ \t]*.*" % os.getenv('MPIF90'),
                 "%s[ \t]*.*" % os.getenv('F90'),
                 "%s[ \t]*.*" % os.getenv('CC'),
                 "mv[ \t]*.*",
                 ".*SRC_.*",
                 ".*: warning .*",
                 ".*Stop.",
                 "Compile time errors (if any) were:",
                 "Please enter the full path of the perl program:",
                ]

        self.log.debug("no_qa for %s: %s" % (cmd, no_qa))
        run_cmd_qa(cmd, qanda, no_qa=no_qa, log_all=True, simple=True)
    def install_step(self):
        """Install Mathematica using install script."""

        # make sure $DISPLAY is not set (to avoid that installer uses GUI)
        orig_display = os.environ.pop('DISPLAY', None)

        cmd = "./%s_%s_LINUX.sh" % (self.name, self.version)
        shortver = '.'.join(self.version.split('.')[:2])
        qa_install_path = "/usr/local/Wolfram/%s/%s" % (self.name, shortver)
        qa = {
            "Enter the installation directory, or press ENTER to select %s: >" % qa_install_path: self.installdir,
            "Create directory (y/n)? >": 'y',
            "or press ENTER to select /usr/local/bin: >": os.path.join(self.installdir, "bin"), 
        }
        no_qa = [
            "Now installing.*\n\n.*\[.*\].*",
        ]
        run_cmd_qa(cmd, qa, no_qa=no_qa, log_all=True, simple=True)

        # add license server configuration file
        # some relevant documentation at http://reference.wolfram.com/mathematica/tutorial/ConfigurationFiles.html
        mathpass_path = os.path.join(self.installdir, 'Configuration', 'Licensing', 'mathpass')
        try:
            # append to file, to avoid overwriting anything that might be there
            f = open(mathpass_path, "a")
            f.write("!%s\n" % self.cfg['license_server'])
            f.close()
            f = open(mathpass_path, "r")
            mathpass_txt = f.read()
            f.close()
            self.log.info("Updated license file %s: %s" % (mathpass_path, mathpass_txt))
        except IOError, err:
            self.log.error("Failed to update %s with license server info: %s" % (mathpass_path, err))
Exemplo n.º 12
0
    def install_step(self):
        """Install by running install script."""

        altver = '-'.join(self.version.split('.'))
        cmd = "./install-%s-%s%s.sh -accept" % (self.name.lower(), altver, self.cfg['versionsuffix'])

        qa = {'The directory will be created if it does not already exist. >': self.installdir}

        run_cmd_qa(cmd, qa, log_all=True, simple=True)
Exemplo n.º 13
0
    def install_step(self):
        """Install by running install script."""

        altver = '-'.join(self.version.split('.'))
        cmd = "./install-%s-%s%s.sh -accept" % (self.name.lower(), altver, self.cfg['versionsuffix'])

        qa = {'The directory will be created if it does not already exist. >': self.installdir}

        run_cmd_qa(cmd, qa, log_all=True, simple=True)
    def build_step(self):
        """Build Geant4."""

        if LooseVersion(self.version) >= LooseVersion("9.5"):
            super(EB_Geant4, self).build_step()

        else:
            pwd = self.cfg['start_dir']
            cmd = "%s/Configure -build" % pwd
            run_cmd_qa(cmd, self.qanda, no_qa=self.noqanda, log_all=True, simple=True)
Exemplo n.º 15
0
    def build_step(self):
        """Build Geant4."""

        if LooseVersion(self.get_installversion()) >= LooseVersion("9.5"):
            super(EB_Geant4, self).build_step()

        else:
            pwd = self.cfg['start_dir']
            cmd = "%s/Configure -build" % pwd
            run_cmd_qa(cmd, self.qanda, no_qa=self.noqanda, log_all=True, simple=True)
    def install_step(self):
        cmd = "./install.sh"

        qanda = {
                 'Please enter the BiSearch root directory: ': self.installdir,
                 'Please enter the path of c++ compiler [/usr/bin/g++]: ': os.getenv('CXX')
                }

        no_qa = [r'Compiling components\s*\.*']

        run_cmd_qa(cmd, qanda, no_qa=no_qa, log_all=True, simple=True)
Exemplo n.º 17
0
    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)
Exemplo n.º 18
0
    def install_step(self):
        cmd = "./install.sh"

        qanda = {
            'Please enter the BiSearch root directory: ':
            self.installdir,
            'Please enter the path of c++ compiler [/usr/bin/g++]: ':
            os.getenv('CXX')
        }

        no_qa = [r'Compiling components\s*\.*']

        run_cmd_qa(cmd, qanda, no_qa=no_qa, log_all=True, simple=True)
Exemplo n.º 19
0
    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)
Exemplo n.º 20
0
    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')

        run_cmd_qa(cmd,
                   qanda,
                   std_qa=stdqa,
                   no_qa=noqanda,
                   log_all=True,
                   simple=True)
Exemplo n.º 21
0
class EB_CUDA(Binary):
    """
    Support for installing CUDA.
    """

    def extract_step(self):
        execpath = self.src[0]['path']
        run_cmd("/bin/sh " + execpath + " --noexec --nox11 --target " + self.builddir)
        self.src[0]['finalpath'] = self.builddir

    def install_step(self):

        run_cmd("mkdir -p "+self.installdir)

        # Define how to run the installer
        if LooseVersion(self.version) <= LooseVersion("5"):
          cmd = os.path.join(self.builddir, "install-linux.pl --prefix=" + self.installdir)
        else:
	      ## The following would require to setup: osdependencies = 'libglut'
	      ## installparams = "-samplespath=%s/samples/ -toolkitpath=%s -samples -toolkit" % (self.installdir, self.installdir))
	      installparams = "-toolkitpath=%s -toolkit" % self.installdir)
          cmd = os.path.join(self.builddir, "cuda-installer.pl -verbose -silent " + installparams)

        qanda = {
                 "".join("A previous version of CUDA was found in /usr/local/cuda\n", 
		 "Would you like to remove all CUDA files under /usr/local/cuda? (yes/no/abort): "): "no",
                 }
        noqanda = [r"Installation Complete"]

        run_cmd_qa(cmd, qanda, no_qa = noqanda, log_all = True, simple = True)

        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))
Exemplo n.º 22
0
 def test_run_cmd_qa(self):
     """Basic test for run_cmd_qa function."""
     (out, ec) = ft.run_cmd_qa("echo question; read x; echo $x",
                               {"question": "answer"})
     self.assertEqual(out, "question\nanswer\n")
     # no reason echo hello could fail
     self.assertEqual(ec, 0)
Exemplo n.º 23
0
 def install_step(self):
     """Install FDTD Solutions using install.sh script."""
     cmd = "./install.sh"
     acceptq = ''.join([
         "If you accept the terms above, type ACCEPT, otherwise press <enter> ",
         "to cancel the install [REJECT]:"
     ])
     qa = {
         acceptq: "ACCEPT",
         "Please select an option from the list [1]:": '1',
         "Please enter the install directory [/opt/lumerical/fdtd]:": self.installdir,
     }
     no_qa = [
     ]
     std_qa = {
         "Press <enter> to continue.*": ''
     }
     run_cmd_qa(cmd, qa, no_qa=no_qa, std_qa=std_qa, log_all=True, simple=True)
Exemplo n.º 24
0
    def install_step(self):
        """Interactive install of Modeller."""

        cmd = "%s/Install" % self.cfg['start_dir']

        # by default modeller tries to install to $HOME/bin/modeller9.13
        # get this path to use it in the question/answer
        default_install_path = "[%s]:" % os.path.join(os.path.expanduser('~'), 'bin', 'modeller%s' % self.cfg['version'])

        qa = {
             # installer will autodetect the right arch. [3] = x86_64
             'Select the type of your computer from the list above [3]:': '',
             default_install_path: self.installdir,
             'http://salilab.org/modeller/registration.html:': self.cfg["key"],
             'Press <Enter> to begin the installation:': '',
             'Press <Enter> to continue:': ''
             }

        run_cmd_qa(cmd, qa, log_all=True, simple=True)
Exemplo n.º 25
0
    def install_step(self):
        """Interactive install of Modeller."""

        cmd = "%s/Install" % self.cfg['start_dir']

        # by default modeller tries to install to $HOME/bin/modeller9.13
        # get this path to use it in the question/answer
        default_install_path = "[%s]:" % os.path.join(
            os.path.expanduser('~'), 'bin', 'modeller%s' % self.cfg['version'])

        qa = {
            # installer will autodetect the right arch. [3] = x86_64
            'Select the type of your computer from the list above [3]:': '',
            default_install_path: self.installdir,
            'http://salilab.org/modeller/registration.html:': self.cfg["key"],
            'Press <Enter> to begin the installation:': '',
            'Press <Enter> to continue:': ''
        }

        run_cmd_qa(cmd, qa, log_all=True, simple=True)
Exemplo n.º 26
0
    def install_step(self):

        run_cmd("mkdir -p "+self.installdir)

        # Define how to run the installer
        if LooseVersion(self.version) <= LooseVersion("5"):
          cmd = os.path.join(self.builddir, "install-linux.pl --prefix=" + self.installdir)
        else:
          cmd = os.path.join(self.builddir, "cuda-installer.pl -verbose -silent -samplespath=%s/samples/ -toolkitpath=%s -samples -toolkit" % (self.installdir, self.installdir))

        qanda = {
                 "A previous version of CUDA was found in /usr/local/cuda\nWould you like to remove all CUDA files under /usr/local/cuda? (yes/no/abort): ": "no",
                 }
        noqanda = [r"Installation Complete"]

        run_cmd_qa(cmd, qanda, no_qa = noqanda, log_all = True, simple = True)

        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))
Exemplo n.º 27
0
    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))
Exemplo n.º 28
0
    def runTest(self):
        """
        verify all the possible extract commands
        also run_cmd should work with some basic echo/exit combos
        """
        cmd = ft.extract_cmd("test.zip")
        self.assertEqual("unzip -qq test.zip", cmd)

        cmd = ft.extract_cmd("/some/path/test.tar")
        self.assertEqual("tar xf /some/path/test.tar", cmd)

        cmd = ft.extract_cmd("test.tar.gz")
        self.assertEqual("tar xzf test.tar.gz", cmd)

        cmd = ft.extract_cmd("test.tgz")
        self.assertEqual("tar xzf test.tgz", cmd)

        cmd = ft.extract_cmd("test.bz2")
        self.assertEqual("bunzip2 test.bz2", cmd)

        cmd = ft.extract_cmd("test.tbz")
        self.assertEqual("tar xjf test.tbz", cmd)

        cmd = ft.extract_cmd("test.tar.bz2")
        self.assertEqual("tar xjf test.tar.bz2", cmd)


        (out, ec) = ft.run_cmd("echo hello")
        self.assertEqual(out, "hello\n")
        # no reason echo hello could fail
        self.assertEqual(ec, 0)

        (out, ec) = ft.run_cmd_qa("echo question", {"question":"answer"})
        self.assertEqual(out, "question\n")
        # no reason echo hello could fail
        self.assertEqual(ec, 0)

        self.assertEqual(True, ft.run_cmd("echo hello", simple=True))
        self.assertEqual(False, ft.run_cmd("exit 1", simple=True, log_all=False, log_ok=False))

        name = ft.convert_name("test+test-test")
        self.assertEqual(name, "testplustestmintest")
        name = ft.convert_name("test+test-test", True)
        self.assertEqual(name, "TESTPLUSTESTMINTEST")


        errors = ft.parse_log_for_error("error failed", True)
        self.assertEqual(len(errors), 1)

        # I expect tests to be run from the base easybuild directory
        self.assertEqual(os.getcwd(), ft.find_base_dir())
Exemplo n.º 29
0
class EB_CPLEX(Binary):
    """
    Support for installing CPLEX.
    Version 12.2 has a self-extracting binary with a Java installer
    """
    def __init__(self, *args, **kwargs):
        """Initialize CPLEX-specific variables."""

        super(EB_CPLEX, self).__init__(*args, **kwargs)
        self.bindir = None

    def install_step(self):
        """CPLEX has an interactive installer, so use Q&A"""

        tmpdir = os.path.join(self.builddir, 'tmp')
        try:
            os.chdir(self.builddir)
            os.makedirs(tmpdir)

        except OSError, err:
            self.log.exception("Failed to prepare for installation: %s" % err)

        env.setvar('IATEMPDIR', tmpdir)
        dst = os.path.join(self.builddir, self.src[0]['name'])

        # Run the source
        cmd = "%s -i console" % dst

        qanda = {
                 "PRESS <ENTER> TO CONTINUE:":"",
                 'Press Enter to continue viewing the license agreement, or enter' \
                 ' "1" to accept the agreement, "2" to decline it, "3" to print it,' \
                 ' or "99" to go back to the previous screen.:':'1',
                 'ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT :':self.installdir,
                 'IS THIS CORRECT? (Y/N):':'y',
                 'PRESS <ENTER> TO INSTALL:':"",
                 "PRESS <ENTER> TO EXIT THE INSTALLER:":"",
                 "CHOOSE LOCALE BY NUMBER:":"",
                 "Choose Instance Management Option:":""
                 }
        noqanda = [r'Installing\.\.\..*\n.*------.*\n\n.*============.*\n.*$']

        run_cmd_qa(cmd, qanda, no_qa=noqanda, log_all=True, simple=True)

        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))
Exemplo n.º 30
0
    def install_step(self):
        """Interactive install of Maple."""

        cmd = "%s/Maple%sLinuxX86_64Installer.bin" % (self.builddir,
                                                      self.cfg['version'])

        qa = {
            'PRESS <ENTER> TO CONTINUE:':
            '',
            'DO YOU ACCEPT THE TERMS OF THIS LICENSE AGREEMENT? (Y/N):':
            'Y',
            'ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT :':
            self.installdir,
            'IS THIS CORRECT? (Y/N):':
            'Y',
            'Do you wish to have a shortcut installed on your desktop? ->1- Yes 2- No ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::':
            '2',
            '->1- Single User License 2- Network License ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::':
            '2',
            'PRESS <ENTER> TO EXIT THE INSTALLER:':
            '',
            'License server (DEFAULT: ):':
            self.cfg['license_server'],
            'Port number (optional) (DEFAULT: ):':
            '',
            '->1- Configure toolbox for Matlab 2- Do not configure at this time ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT::':
            '2'
        }

        no_qa = [
            'Graphical installers are not supported by the VM. The console mode will be used instead...',
            'Extracting the JRE from the installer archive...',
            'Launching installer...',
            "Configuring the installer for this system's environment...",
            'Unpacking the JRE...', '\[[-|]*'
        ]

        run_cmd_qa(cmd, qa, no_qa=no_qa, log_all=True, simple=True)
Exemplo n.º 31
0
 def install_step(self):
     """Install FDTD Solutions using install.sh script."""
     cmd = "./install.sh"
     acceptq = ''.join([
         "If you accept the terms above, type ACCEPT, otherwise press <enter> ",
         "to cancel the install [REJECT]:"
     ])
     qa = {
         acceptq:
         "ACCEPT",
         "Please select an option from the list [1]:":
         '1',
         "Please enter the install directory [/opt/lumerical/fdtd]:":
         self.installdir,
     }
     no_qa = []
     std_qa = {"Press <enter> to continue.*": ''}
     run_cmd_qa(cmd,
                qa,
                no_qa=no_qa,
                std_qa=std_qa,
                log_all=True,
                simple=True)
Exemplo n.º 32
0
    def build_step(self):
        """Build WIEN2k by running siteconfig_lapw script again."""

        self.log.debug("%s part II (build_step)" % self.cfgscript)

        cmd = "./%s" % self.cfgscript

        qanda = {
            "L Perl path (if not in /usr/bin/perl) Q Quit Selection:": "R",
            "A Compile all programs S Select program Q Quit Selection:": "A",
            "Press RETURN to continue": "\nQ",  # also answer on first qanda pattern with 'Q' to quit
            " Please enter the full path of the perl program: ": "",
        }
        no_qa = [
            "%s[ \t]*.*" % os.getenv("MPIF90"),
            "%s[ \t]*.*" % os.getenv("F90"),
            "%s[ \t]*.*" % os.getenv("CC"),
            ".*SRC_.*",
            ".*: warning .*",
            ".*Stop.",
        ]

        self.log.debug("no_qa for %s: %s" % (cmd, no_qa))
        run_cmd_qa(cmd, qanda, no_qa=no_qa, log_all=True, simple=True)
Exemplo n.º 33
0
class EB_CPLEX(Binary):
    """
    Support for installing CPLEX.
    Version 12.2 has a self-extracting binary with a Java installer
    """
    def __init__(self, *args, **kwargs):
        """Initialize CPLEX-specific variables."""
        super(EB_CPLEX, self).__init__(*args, **kwargs)
        self.bindir = None

    @staticmethod
    def extra_options():
        extra_vars = [
            # staged install via a tmp dir can help with the hard (potentially faulty) check on available disk space
            ('staged_install', [
                False,
                "Should the installation should be staged via a temporary dir?",
                CUSTOM
            ]),
        ]
        return Binary.extra_options(extra_vars)

    def install_step(self):
        """CPLEX has an interactive installer, so use Q&A"""

        tmpdir = os.path.join(self.builddir, 'tmp')
        stagedir = os.path.join(self.builddir, 'staged')
        try:
            os.chdir(self.builddir)
            os.makedirs(tmpdir)
            os.makedirs(stagedir)
        except OSError, err:
            self.log.exception("Failed to prepare for installation: %s" % err)

        env.setvar('IATEMPDIR', tmpdir)
        dst = os.path.join(self.builddir, self.src[0]['name'])

        cmd = "%s -i console" % dst

        install_target = self.installdir
        if self.cfg['staged_install']:
            install_target = stagedir

        qanda = {
            "PRESS <ENTER> TO CONTINUE:": '',
            'Press Enter to continue viewing the license agreement, or enter' \
            ' "1" to accept the agreement, "2" to decline it, "3" to print it,' \
            ' or "99" to go back to the previous screen.:': '1',
            'ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT :': install_target,
            'IS THIS CORRECT? (Y/N):': 'y',
            'PRESS <ENTER> TO INSTALL:': '',
            "PRESS <ENTER> TO EXIT THE INSTALLER:": '',
            "CHOOSE LOCALE BY NUMBER:": '',
            "Choose Instance Management Option:": '',
        }
        noqanda = [r'Installing\.\.\..*\n.*------.*\n\n.*============.*\n.*$']

        run_cmd_qa(cmd, qanda, no_qa=noqanda, log_all=True, simple=True)

        if self.cfg['staged_install']:
            # move staged installation to actual install dir
            try:
                # copytree expects target directory to not exist yet
                shutil.rmtree(self.installdir)
                shutil.copytree(stagedir, self.installdir)
            except OSError, err:
                self.log.error(
                    "Failed to move staged install from %s to %s: %s" %
                    (stagedir, self.installdir, err))
Exemplo n.º 34
0
    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)
Exemplo n.º 35
0
        if not bt in knownbuildtypes.keys():
            self.log.error("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'),
                }
        fn = 'configure.wps'
        for line in fileinput.input(fn, 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)
Exemplo n.º 36
0
    def configure_step(self):
        """Configure WIEN2k build by patching siteconfig_lapw script and running it."""

        self.cfgscript = "siteconfig_lapw"

        # patch config file first

        # toolchain-dependent values
        comp_answer = None
        if self.toolchain.comp_family(
        ) == toolchain.INTELCOMP:  #@UndefinedVariable
            if LooseVersion(
                    get_software_version("icc")) >= LooseVersion("2011"):
                comp_answer = 'I'  # Linux (Intel ifort 12.0 compiler + mkl )
            else:
                comp_answer = "K1"  # Linux (Intel ifort 11.1 compiler + mkl )

        elif self.toolchain.comp_family(
        ) == toolchain.GCC:  #@UndefinedVariable
            comp_answer = 'V'  # Linux (gfortran compiler + gotolib)

        else:
            self.log.error("Failed to determine toolchain-dependent answers.")

        # libraries
        rlibs = "%s %s" % (os.getenv('LIBLAPACK_MT'),
                           self.toolchain.get_flag('openmp'))
        rplibs = [os.getenv('LIBSCALAPACK_MT'), os.getenv('LIBLAPACK_MT')]
        fftwver = get_software_version('FFTW')
        if fftwver:
            suff = ''
            if LooseVersion(fftwver) >= LooseVersion("3"):
                suff = '3'
            rplibs.insert(0,
                          "-lfftw%(suff)s_mpi -lfftw%(suff)s" % {'suff': suff})
        else:
            rplibs.append(os.getenv('LIBFFT'))

        rplibs = ' '.join(rplibs)

        d = {
            'FC': '%s %s' % (os.getenv('F90'), os.getenv('FFLAGS')),
            'MPF': "%s %s" % (os.getenv('MPIF90'), os.getenv('FFLAGS')),
            'CC': os.getenv('CC'),
            'LDFLAGS': '$(FOPT) %s ' % os.getenv('LDFLAGS'),
            'R_LIBS': rlibs,  # libraries for 'real' (not 'complex') binary
            'RP_LIBS': rplibs,  # libraries for 'real' parallel binary
            'MPIRUN': '',
        }

        for line in fileinput.input(self.cfgscript, inplace=1, backup='.orig'):
            # set config parameters
            for (k, v) in d.items():
                regexp = re.compile('^([a-z0-9]+):%s:.*' % k)
                res = regexp.search(line)
                if res:
                    # we need to exclude the lines with 'current', otherwise we break the script
                    if not res.group(1) == "current":
                        line = regexp.sub('\\1:%s:%s' % (k, v), line)
            # avoid exit code > 0 at end of configuration
            line = re.sub('(\s+)exit 1', '\\1exit 0', line)
            sys.stdout.write(line)

        # set correct compilers
        env.setvar('bin', os.getcwd())

        dc = {
            'COMPILERC': os.getenv('CC'),
            'COMPILER': os.getenv('F90'),
            'COMPILERP': os.getenv('MPIF90'),
        }

        for (k, v) in dc.items():
            f = open(k, "w")
            f.write(v)
            f.close()

        # configure with patched configure script
        self.log.debug('%s part I (configure)' % self.cfgscript)

        cmd = "./%s" % self.cfgscript
        qanda = {
                 'Press RETURN to continue': '',
                 'compiler) Selection:': comp_answer,
                 'Your compiler:': '',
                 'Hit Enter to continue': '',
                 'Shared Memory Architecture? (y/n):': 'n',
                 'Remote shell (default is ssh) =': '',
                 'and you need to know details about your installed  mpi ..) (y/n)': 'y',
                 'Recommended setting for parallel f90 compiler: mpiifort ' \
                        'Current selection: Your compiler:': os.getenv('MPIF90'),
                 'Q to quit Selection:': 'Q',
                 'A Compile all programs (suggested) Q Quit Selection:': 'Q',
                 ' Please enter the full path of the perl program: ': '',
                 'continue or stop (c/s)': 'c',
                 '(like taskset -c). Enter N / your_specific_command:': 'N',
                 'If you are using mpi2 set MPI_REMOTE to 0  Set MPI_REMOTE to 0 / 1:': '0',
                 'Do you have MPI and Scalapack installed and intend to run ' \
                    'finegrained parallel? (This is usefull only for BIG cases ' \
                    '(50 atoms and more / unit cell) and you need to know details ' \
                    'about your installed  mpi and fftw ) (y/n)': 'y',
                }

        no_qa = [
            'You have the following mkl libraries in %s :' %
            os.getenv('MKLROOT'),
            "%s[ \t]*.*" % os.getenv('MPIF90'),
            "%s[ \t]*.*" % os.getenv('F90'),
            "%s[ \t]*.*" % os.getenv('CC'),
            ".*SRC_.*",
            "Please enter the full path of the perl program:",
        ]

        std_qa = {
            r'S\s+Save and Quit[\s\n]+To change an item select option.[\s\n]+Selection:':
            'S',
        }

        run_cmd_qa(cmd,
                   qanda,
                   no_qa=no_qa,
                   std_qa=std_qa,
                   log_all=True,
                   simple=True)

        # post-configure patches
        fn = os.path.join(self.cfg['start_dir'], 'parallel_options')
        remote = self.cfg['remote']
        try:
            for line in fileinput.input(fn, inplace=1, backup='.orig.eb'):
                if self.cfg['wien_mpirun']:
                    line = re.sub("(setenv WIEN_MPIRUN\s*).*",
                                  r'\1 "%s"' % self.cfg['wien_mpirun'], line)
                sys.stdout.write(line)

            if remote:
                f = open(fn, "a")

                if remote == 'pbsssh':
                    extra = "set remote = pbsssh\n"
                    extra += "setenv PBSSSHENV 'LD_LIBRARY_PATH PATH'\n"
                else:
                    self.log.error("Don't know how to patch %s for remote %s" %
                                   (fn, remote))

                f.write(extra)
                f.close()

            self.log.debug("Patched file %s: %s" % (fn, open(fn, 'r').read()))

        except IOError, err:
            self.log.error("Failed to patch %s: %s" % (fn, err))
Exemplo n.º 37
0
    def configure_step(self):
        """
        Configure Geant4 build, either via CMake for versions more recent than 9.5,
        or using an interactive configuration procedure otherwise.
        """

        # Geant4 switched to a cmake build system in 9.5
        if LooseVersion(self.version) >= LooseVersion("9.5"):
            mkdir('configdir')
            os.chdir('configdir')
            super(EB_Geant4, self).configure_step(srcdir="..")

        else:
            pwd = self.cfg['start_dir']
            dst = self.installdir
            clhepdir = get_software_root('CLHEP')
            cmd = "%s/Configure -E -build" % pwd

            self.qanda = {# questions and answers for version 9.1.p03
                          "There exists a config.sh file. Shall I use it to set the defaults? [y]": "n",
                          "Would you like to see the instructions? [n]": "",
                          "[Type carriage return to continue]": "",
                          "Definition of G4SYSTEM variable is Linux-g++. That stands for: 1) OS : Linux" \
                            "2) Compiler : g++ To modify default settings, select number above (e.g. 2) " \
                            "[Press [Enter] for default settings]": "2",
                          "Which C++ compiler? [g++]": "$(GPP)",
                          "Confirm your selection or set recommended 'g++'! [*]": "",
                          "Definition of G4SYSTEM variable is Linux-icc. That stands for: 1) OS : Linux 2)" \
                            "Compiler : icc To modify default settings, select number above (e.g. 2) " \
                            "[Press [Enter] for default settings]": "",
                          "Do you expect to run these scripts and binaries on multiple machines? [n]": "y",
                          "Where is Geant4 source installed? [%s]" % pwd: "",
                          "Specify the path where Geant4 libraries and source files should be installed." \
                            " [%s]" % pwd: dst,
                          "Do you want to copy all Geant4 headers in one directory? [n]": "y",
                          "Please, specify default directory where ALL the Geant4 data is installed:" \
                            "G4LEVELGAMMADATA: %(pwd)s/data/PhotonEvaporation2.0 G4RADIOACTIVEDATA: " \
                            "%(pwd)s/data/RadioactiveDecay3.2 G4LEDATA: %(pwd)s/data/G4EMLOW5.1 G4NEUTRONHPDATA:    " \
                            "%(pwd)s/data/G4NDL3.12 G4ABLADATA: %(pwd)s/data/G4ABLA3.0 You will be asked about " \
                            "customizing these next. [%(pwd)s/data]" % {'pwd': pwd}: "%s/data" % dst,
                          "Directory %s/data doesn't exist. Use that name anyway? [n]" % dst: "y",
                          "Please, specify default directory where the Geant4 data is installed: " \
                            "1) G4LEVELGAMMADATA: %(dst)s/data/PhotonEvaporation2.0 2) G4RADIOACTIVEDATA: " \
                            "%(dst)s/data/RadioactiveDecay3.2 3) G4LEDATA: %(dst)s/data/G4EMLOW5.1 4) G4NEUTRONHPDATA: " \
                            "%(dst)s/data/G4NDL3.12 5) G4ABLADATA: %(dst)s/data/G4ABLA3.0 To modify default settings, " \
                            "select number above (e.g. 2) [Press [Enter] for default settings]" % {'dst': dst}: "",
                          "Please, specify where CLHEP is installed: CLHEP_BASE_DIR: ": clhepdir,
                          "Please, specify where CLHEP is installed: CLHEP_BASE_DIR: [%s]" % clhepdir: "",
                          "You can customize paths and library name of you CLHEP installation: 1) CLHEP_INCLUDE_DIR: " \
                            "%(clhepdir)s/include 2) CLHEP_LIB_DIR: %(clhepdir)s/lib 3) CLHEP_LIB: CLHEP To modify " \
                            "default settings, select number above (e.g. 2) [Press [Enter] for default settings]" %
                            {'clhepdir': clhepdir}: "",
                          "By default 'static' (.a) libraries are built. Do you want to build 'shared' (.so) " \
                            "libraries? [n]": "y",
                          "You selected to build 'shared' (.so) libraries. Do you want to build 'static' (.a) " \
                            "libraries too? [n]": "y",
                          "Do you want to build 'global' compound libraries? [n]": "",
                          "Do you want to compile libraries in DEBUG mode (-g)? [n]": "",
                          "G4UI_NONE If this variable is set, no UI sessions nor any UI libraries are built. " \
                            "This can be useful when running a pure batch job or in a user framework having its own " \
                            "UI system. Do you want to set this variable ? [n]": "",
                          "G4UI_BUILD_XAW_SESSION G4UI_USE_XAW Specifies to include and use the XAW interfaces in " \
                            "the application to be built. The XAW (X11 Athena Widget set) extensions are required to " \
                            "activate and build this driver. [n]": "",
                          "G4UI_BUILD_XM_SESSION G4UI_USE_XM Specifies to include and use the XM Motif based user " \
                            "interfaces. The XM Motif extensions are required to activate and build this driver. [n]": "",
                          "G4VIS_NONE If this variable is set, no visualization drivers will be built or used. Do " \
                            "you want to set this variable ? [n]": "n",
                          "G4VIS_BUILD_OPENGLX_DRIVER G4VIS_USE_OPENGLX It is an interface to the de facto standard " \
                            "3D graphics library, OpenGL. It is well suited for real-time fast visualization and " \
                            "prototyping. The X11 version of the OpenGL libraries is required. [n]": "",
                          "G4VIS_BUILD_OPENGLXM_DRIVER G4VIS_USE_OPENGLXM It is an interface to the de facto " \
                            "standard 3D graphics library, OpenGL. It is well suited for real-time fast visualization " \
                            "and prototyping. The X11 version of the OpenGL libraries and the Motif Xm extension is " \
                            "required. [n]": "",
                          "G4VIS_BUILD_DAWN_DRIVER G4VIS_USE_DAWN DAWN drivers are interfaces to the Fukui Renderer " \
                            "DAWN. DAWN is a vectorized 3D PostScript processor suited to prepare technical high " \
                            "quality outputs for presentation and/or documentation. [n]": "",
                          "G4VIS_BUILD_OIX_DRIVER G4VIS_USE_OIX The OpenInventor driver is based on OpenInventor tech" \
                            "nology for scientific visualization. The X11 version of OpenInventor is required. [n]": "",
                          "G4VIS_BUILD_RAYTRACERX_DRIVER G4VIS_USE_RAYTRACERX Allows for interactive ray-tracing " \
                            "graphics through X11. The X11 package is required. [n]": "",
                          "G4VIS_BUILD_VRML_DRIVER G4VIS_USE_VRML These driver generate VRML files, which describe " \
                            "3D scenes to be visualized with a proper VRML viewer. [n]": "",
                          "G4LIB_BUILD_GDML Setting this variable will enable building of the GDML plugin module " \
                            "embedded in Geant4 for detector description persistency. It requires your system to have " \
                            "the XercesC library and headers installed. Do you want to set this variable? [n]": "",
                          "G4LIB_BUILD_G3TOG4 The utility module 'g3tog4' will be built by setting this variable. " \
                            "NOTE: it requires a valid FORTRAN compiler to be installed on your system and the " \
                            "'cernlib' command in the path, in order to build the ancillary tools! Do you want to " \
                            "build 'g3tog4' ? [n]": "",
                          "G4LIB_BUILD_ZLIB Do you want to activate compression for output files generated by the " \
                            "HepRep visualization driver? [n]": "y",
                          "G4ANALYSIS_USE Activates the configuration setup for allowing plugins to analysis tools " \
                            "based on AIDA (Astract Interfaces for Data Analysis). In order to use AIDA features and " \
                            "compliant analysis tools, the proper environment for these tools will have to be set " \
                            "(see documentation for the specific analysis tools). [n]": "",
                          "Press [Enter] to start installation or use a shell escape to edit config.sh: ": "",
                          # extra questions and answers for version 9.2.p03
                          "Directory %s doesn't exist. Use that name anyway? [n]" % dst: "y",
                          "Specify the path where the Geant4 data libraries PhotonEvaporation%s " \
                            "RadioactiveDecay%s G4EMLOW%s G4NDL%s G4ABLA%s are " \
                            "installed. For now, a flat directory structure is assumed, and this can be customized " \
                            "at the next step if needed. [%s/data]" % (self.cfg['PhotonEvaporationVersion'],
                                                                       self.cfg['G4RadioactiveDecayVersion'],
                                                                       self.cfg['G4EMLOWVersion'],
                                                                       self.cfg['G4NDLVersion'],
                                                                       self.cfg['G4ABLAVersion'],
                                                                       pwd
                                                                      ): "%s/data" % dst,
                          "Please enter 1) Another path to search in 2) 'f' to force the use of the path " \
                            "you entered previously (the data libraries are not needed to build Geant4, but " \
                            "are needed to run applications later). 3) 'c' to customize the data paths, e.g. " \
                            "if you have the data libraries installed in different locations. [f]": "",
                          "G4UI_BUILD_QT_SESSION G4UI_USE_QT Setting these variables will enable the building " \
                            "of the G4 Qt based user interface module and the use of this module in your " \
                            "applications respectively. The Qt3 or Qt4 headers, libraries and moc application are " \
                            "required to enable the building of this module. Do you want to enable build and use of " \
                            "this module? [n]": "",
                          # extra questions and answers for version 9.4.po1
                          "What is the path to the Geant4 source tree? [%s]" % pwd: "",
                          "Where should Geant4 be installed? [%s]" % pwd: dst,
                          "Do you want to install all Geant4 headers in one directory? [n]": "y",
                          "Do you want to build shared libraries? [y]": "",
                          "Do you want to build static libraries too? [n]": "",
                          "Do you want to build global libraries? [y]": "",
                          "Do you want to build granular libraries as well? [n]": "",
                          "Do you want to build libraries with debugging information? [n]": "",
                          "Specify the path where the Geant4 data libraries are installed: [%s/data]" % pwd: "%s/data" % dst,
                          "How many parallel jobs should make launch? [1]": "%s" % self.cfg['parallel'],
                          "Please enter 1) Another path to search in 2) 'f' to force the use of the path you entered " \
                            "previously (the data libraries are NOT needed to build Geant4, but are needed to run " \
                            "applications later). 3) 'c' to customize the data paths, e.g. if you have the data " \
                            "libraries installed in different locations. [f]": "",
                          "Enable building of User Interface (UI) modules? [y]": "",
                          "Enable building of the XAW (X11 Athena Widget set) UI module? [n]": "",
                          "Enable building of the X11-Motif (Xm) UI module? [n]": "",
                          "Enable building of the Qt UI module? [n]": "",
                          "Enable building of visualization drivers? [y]": "n",
                          "Enable the Geometry Description Markup Language (GDML) module? [n]": "",
                          "Enable build of the g3tog4 utility module? [n]": "",
                          "Enable internal zlib compression for HepRep visualization? [n] ": "",
                         }

            self.noqanda = [
                r"Compiling\s+.*?\s+\.\.\.",
                r"Making\s+dependency\s+for\s+file\s+.*?\s+\.\.\.",
                r"Making\s+libname\.map\s+starter\s+file\s+\.\.\.",
                r"Making\s+libname\.map\s+\.\.\.",
                r"Reading\s+library\s+get_name\s+map\s+file\s*\.\.\.",
                r"Reading\s+dependency\s+files\s*\.\.\.",
                r"Creating\s+shared\s+library\s+.*?\s+\.\.\."
            ]

            run_cmd_qa(cmd,
                       self.qanda,
                       self.noqanda,
                       log_all=True,
                       simple=True)

            # determining self.g4system
            try:
                scriptdirbase = os.path.join(pwd, '.config', 'bin')
                filelist = os.listdir(scriptdirbase)
            except OSError, err:
                self.log.error("Failed to determine self.g4system: %s" % err)

            if len(filelist) != 1:
                self.log.error(
                    "Exactly one directory is expected in %s; found back: %s" %
                    (scriptdirbase, filelist))
            else:
                self.g4system = filelist[0]

            self.scriptdir = os.path.join(scriptdirbase, self.g4system)
            if not os.path.isdir(self.scriptdir):
                self.log.error("Something went wrong. Dir: %s doesn't exist." %
                               self.scriptdir)
            self.log.info(
                "The directory containing several important scripts to be copied was found: %s"
                % self.scriptdir)

            # copying config.sh to pwd
            try:
                self.log.info("copying config.sh to %s" % pwd)
                shutil.copy2(os.path.join(self.scriptdir, 'config.sh'), pwd)
            except IOError, err:
                self.log.error("Failed to copy config.sh to %s" % pwd)
Exemplo n.º 38
0
    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)
Exemplo n.º 39
0
    def configure_step(self):
        """Configure WIEN2k build by patching siteconfig_lapw script and running it."""

        self.cfgscript = "siteconfig_lapw"

        # patch config file first

        # toolchain-dependent values
        comp_answer = None
        if self.toolchain.comp_family() == toolchain.INTELCOMP:  #@UndefinedVariable
            if LooseVersion(get_software_version("icc")) >= LooseVersion("2011"):
                comp_answer = 'I'  # Linux (Intel ifort 12.0 compiler + mkl )
            else:
                comp_answer = "K1"  # Linux (Intel ifort 11.1 compiler + mkl )

        elif self.toolchain.comp_family() == toolchain.GCC:  #@UndefinedVariable
            comp_answer = 'V'  # Linux (gfortran compiler + gotolib)

        else:
            self.log.error("Failed to determine toolchain-dependent answers.")

        # libraries
        rlibs = "%s %s" % (os.getenv('LIBLAPACK_MT'), self.toolchain.get_flag('openmp'))
        rplibs = [os.getenv('LIBSCALAPACK_MT'), os.getenv('LIBLAPACK_MT')]
        fftwver = get_software_version('FFTW')
        if fftwver:
            suff = ''
            if LooseVersion(fftwver) >= LooseVersion("3"):
                suff = '3'
            rplibs.insert(0, "-lfftw%(suff)s_mpi -lfftw%(suff)s" % {'suff': suff})
        else:
            rplibs.append(os.getenv('LIBFFT'))

        rplibs = ' '.join(rplibs)

        d = {
             'FC': '%s %s' % (os.getenv('F90'), os.getenv('FFLAGS')),
             'MPF': "%s %s" % (os.getenv('MPIF90'), os.getenv('FFLAGS')),
             'CC': os.getenv('CC'),
             'LDFLAGS': '$(FOPT) %s ' % os.getenv('LDFLAGS'),
             'R_LIBS': rlibs,  # libraries for 'real' (not 'complex') binary
             'RP_LIBS' : rplibs,  # libraries for 'real' parallel binary
             'MPIRUN': '',
            }

        for line in fileinput.input(self.cfgscript, inplace=1, backup='.orig'):
            # set config parameters
            for (k,v) in d.items():
                regexp = re.compile('^([a-z0-9]+):%s:.*' % k)
                res = regexp.search(line)
                if res:
                    # we need to exclude the lines with 'current', otherwise we break the script
                    if not res.group(1) == "current":
                        line = regexp.sub('\\1:%s:%s' % (k, v), line)
            # avoid exit code > 0 at end of configuration
            line = re.sub('(\s+)exit 1', '\\1exit 0', line)
            sys.stdout.write(line)

        # set correct compilers
        env.setvar('bin', os.getcwd())

        dc = {
              'COMPILERC': os.getenv('CC'),
              'COMPILER': os.getenv('F90'),
              'COMPILERP': os.getenv('MPIF90'),
             }

        for (k,v) in dc.items():
            f = open(k,"w")
            f.write(v)
            f.close()

        # configure with patched configure script
        self.log.debug('%s part I (configure)' % self.cfgscript)

        cmd = "./%s" % self.cfgscript
        qanda = {
                 'Press RETURN to continue': '',
                 'compiler) Selection:': comp_answer,
                 'Your compiler:': '',
                 'Hit Enter to continue': '',
                 'Shared Memory Architecture? (y/n):': 'n',
                 'Remote shell (default is ssh) =': '',
                 'and you need to know details about your installed  mpi ..) (y/n)': 'y',
                 'Recommended setting for parallel f90 compiler: mpiifort ' \
                        'Current selection: Your compiler:': os.getenv('MPIF90'),
                 'Q to quit Selection:': 'Q',
                 'A Compile all programs (suggested) Q Quit Selection:': 'Q',
                 ' Please enter the full path of the perl program: ': '',
                 'continue or stop (c/s)': 'c',
                 '(like taskset -c). Enter N / your_specific_command:': 'N',
                 'If you are using mpi2 set MPI_REMOTE to 0  Set MPI_REMOTE to 0 / 1:': '0',
                 'Do you have MPI and Scalapack installed and intend to run ' \
                    'finegrained parallel? (This is usefull only for BIG cases ' \
                    '(50 atoms and more / unit cell) and you need to know details ' \
                    'about your installed  mpi and fftw ) (y/n)': 'y',
                }

        no_qa = [
                 'You have the following mkl libraries in %s :' % os.getenv('MKLROOT'),
                 "%s[ \t]*.*"%os.getenv('MPIF90'),
                 "%s[ \t]*.*"%os.getenv('F90'),
                 "%s[ \t]*.*"%os.getenv('CC'),
                 ".*SRC_.*",
                 "Please enter the full path of the perl program:",
                ]

        std_qa = {
                  r'S\s+Save and Quit[\s\n]+To change an item select option.[\s\n]+Selection:': 'S',
                 }

        run_cmd_qa(cmd, qanda, no_qa=no_qa, std_qa=std_qa, log_all=True, simple=True)

        # post-configure patches
        fn = os.path.join(self.cfg['start_dir'], 'parallel_options')
        remote = self.cfg['remote']
        try:
            for line in fileinput.input(fn, inplace=1, backup='.orig.eb'):
                if self.cfg['wien_mpirun']:
                    line = re.sub("(setenv WIEN_MPIRUN\s*).*", r'\1 "%s"' % self.cfg['wien_mpirun'], line)
                sys.stdout.write(line)

            if remote:
                f = open(fn, "a")

                if remote == 'pbsssh':
                    extra = "set remote = pbsssh\n"
                    extra += "setenv PBSSSHENV 'LD_LIBRARY_PATH PATH'\n"
                else:
                    self.log.error("Don't know how to patch %s for remote %s" % (fn, remote))

                f.write(extra)
                f.close()

            self.log.debug("Patched file %s: %s" % (fn, open(fn, 'r').read()))

        except IOError, err:
            self.log.error("Failed to patch %s: %s" % (fn, err))
Exemplo n.º 40
0
    def configure_step(self):
        """Configure WIEN2k build by patching siteconfig_lapw script and running it."""

        self.cfgscript = "siteconfig_lapw"

        # patch config file first

        # toolchain-dependent values
        comp_answer = None
        if self.toolchain.comp_family() == toolchain.INTELCOMP:  # @UndefinedVariable
            if LooseVersion(get_software_version("icc")) >= LooseVersion("2011"):
                comp_answer = "I"  # Linux (Intel ifort 12.0 compiler + mkl )
            else:
                comp_answer = "K1"  # Linux (Intel ifort 11.1 compiler + mkl )

        elif self.toolchain.comp_family() == toolchain.GCC:  # @UndefinedVariable
            comp_answer = "V"  # Linux (gfortran compiler + gotolib)

        else:
            self.log.error("Failed to determine toolchain-dependent answers.")

        # libraries
        rlibs = "%s %s" % (os.getenv("LIBLAPACK_MT"), self.toolchain.get_flag("openmp"))
        rplibs = [os.getenv("LIBSCALAPACK_MT"), os.getenv("LIBLAPACK_MT")]
        fftwver = get_software_version("FFTW")
        if fftwver:
            suff = ""
            if LooseVersion(fftwver) >= LooseVersion("3"):
                suff = "3"
            rplibs.insert(0, "-lfftw%(suff)s_mpi -lfftw%(suff)s" % {"suff": suff})
        else:
            rplibs.append(os.getenv("LIBFFT"))

        rplibs = " ".join(rplibs)

        d = {
            "FC": "%s %s" % (os.getenv("F90"), os.getenv("FFLAGS")),
            "MPF": "%s %s" % (os.getenv("MPIF90"), os.getenv("FFLAGS")),
            "CC": os.getenv("CC"),
            "LDFLAGS": "$(FOPT) %s " % os.getenv("LDFLAGS"),
            "R_LIBS": rlibs,  # libraries for 'real' (not 'complex') binary
            "RP_LIBS": rplibs,  # libraries for 'real' parallel binary
            "MPIRUN": "",
        }

        for line in fileinput.input(self.cfgscript, inplace=1, backup=".orig"):
            # set config parameters
            for (k, v) in d.items():
                regexp = re.compile("^([a-z0-9]+):%s:.*" % k)
                res = regexp.search(line)
                if res:
                    # we need to exclude the lines with 'current', otherwise we break the script
                    if not res.group(1) == "current":
                        line = regexp.sub("\\1:%s:%s" % (k, v), line)
            # avoid exit code > 0 at end of configuration
            line = re.sub("(\s+)exit 1", "\\1exit 0", line)
            sys.stdout.write(line)

        # set correct compilers
        env.setvar("bin", os.getcwd())

        dc = {"COMPILERC": os.getenv("CC"), "COMPILER": os.getenv("F90"), "COMPILERP": os.getenv("MPIF90")}

        for (k, v) in dc.items():
            f = open(k, "w")
            f.write(v)
            f.close()

        # configure with patched configure script
        self.log.debug("%s part I (configure)" % self.cfgscript)

        cmd = "./%s" % self.cfgscript
        qanda = {
            "Press RETURN to continue": "",
            "compiler) Selection:": comp_answer,
            "Your compiler:": "",
            "Hit Enter to continue": "",
            "Shared Memory Architecture? (y/n):": "n",
            "Remote shell (default is ssh) =": "",
            "and you need to know details about your installed  mpi ..) (y/n)": "y",
            "Recommended setting for parallel f90 compiler: mpiifort "
            "Current selection: Your compiler:": os.getenv("MPIF90"),
            "Q to quit Selection:": "Q",
            "A Compile all programs (suggested) Q Quit Selection:": "Q",
            " Please enter the full path of the perl program: ": "",
            "continue or stop (c/s)": "c",
            "(like taskset -c). Enter N / your_specific_command:": "N",
            "If you are using mpi2 set MPI_REMOTE to 0  Set MPI_REMOTE to 0 / 1:": "0",
            "Do you have MPI and Scalapack installed and intend to run "
            "finegrained parallel? (This is usefull only for BIG cases "
            "(50 atoms and more / unit cell) and you need to know details "
            "about your installed  mpi and fftw ) (y/n)": "y",
        }

        no_qa = [
            "You have the following mkl libraries in %s :" % os.getenv("MKLROOT"),
            "%s[ \t]*.*" % os.getenv("MPIF90"),
            "%s[ \t]*.*" % os.getenv("F90"),
            "%s[ \t]*.*" % os.getenv("CC"),
            ".*SRC_.*",
        ]

        std_qa = {r"S\s+Save and Quit[\s\n]+To change an item select option.[\s\n]+Selection:": "S"}

        run_cmd_qa(cmd, qanda, no_qa=no_qa, std_qa=std_qa, log_all=True, simple=True)
Exemplo n.º 41
0
    def configure_step(self):
        """
        Configure Geant4 build, either via CMake for versions more recent than 9.5,
        or using an interactive configuration procedure otherwise.
        """

        # Geant4 switched to a cmake build system in 9.5
        if LooseVersion(self.get_installversion()) >= LooseVersion("9.5"):
            mkdir('configdir')
            os.chdir('configdir')
            super(EB_Geant4, self).configure_step(builddir="..")

        else:
            pwd = self.cfg['start_dir']
            dst = self.installdir
            clhepdir = get_software_root('CLHEP')
            cmd = "%s/Configure -E -build" % pwd

            self.qanda = {# questions and answers for version 9.1.p03
                          "There exists a config.sh file. Shall I use it to set the defaults? [y]": "n",
                          "Would you like to see the instructions? [n]": "",
                          "[Type carriage return to continue]": "",
                          "Definition of G4SYSTEM variable is Linux-g++. That stands for: 1) OS : Linux" \
                            "2) Compiler : g++ To modify default settings, select number above (e.g. 2) " \
                            "[Press [Enter] for default settings]": "2",
                          "Which C++ compiler? [g++]": "$(GPP)",
                          "Confirm your selection or set recommended 'g++'! [*]": "",
                          "Definition of G4SYSTEM variable is Linux-icc. That stands for: 1) OS : Linux 2)" \
                            "Compiler : icc To modify default settings, select number above (e.g. 2) " \
                            "[Press [Enter] for default settings]": "",
                          "Do you expect to run these scripts and binaries on multiple machines? [n]": "y",
                          "Where is Geant4 source installed? [%s]" % pwd: "",
                          "Specify the path where Geant4 libraries and source files should be installed." \
                            " [%s]" % pwd: dst,
                          "Do you want to copy all Geant4 headers in one directory? [n]": "y",
                          "Please, specify default directory where ALL the Geant4 data is installed:" \
                            "G4LEVELGAMMADATA: %(pwd)s/data/PhotonEvaporation2.0 G4RADIOACTIVEDATA: " \
                            "%(pwd)s/data/RadioactiveDecay3.2 G4LEDATA: %(pwd)s/data/G4EMLOW5.1 G4NEUTRONHPDATA:    " \
                            "%(pwd)s/data/G4NDL3.12 G4ABLADATA: %(pwd)s/data/G4ABLA3.0 You will be asked about " \
                            "customizing these next. [%(pwd)s/data]" % {'pwd': pwd}: "%s/data" % dst,
                          "Directory %s/data doesn't exist. Use that name anyway? [n]" % dst: "y",
                          "Please, specify default directory where the Geant4 data is installed: " \
                            "1) G4LEVELGAMMADATA: %(dst)s/data/PhotonEvaporation2.0 2) G4RADIOACTIVEDATA: " \
                            "%(dst)s/data/RadioactiveDecay3.2 3) G4LEDATA: %(dst)s/data/G4EMLOW5.1 4) G4NEUTRONHPDATA: " \
                            "%(dst)s/data/G4NDL3.12 5) G4ABLADATA: %(dst)s/data/G4ABLA3.0 To modify default settings, " \
                            "select number above (e.g. 2) [Press [Enter] for default settings]" % {'dst': dst}: "",
                          "Please, specify where CLHEP is installed: CLHEP_BASE_DIR: ": clhepdir,
                          "Please, specify where CLHEP is installed: CLHEP_BASE_DIR: [%s]" % clhepdir: "",
                          "You can customize paths and library name of you CLHEP installation: 1) CLHEP_INCLUDE_DIR: " \
                            "%(clhepdir)s/include 2) CLHEP_LIB_DIR: %(clhepdir)s/lib 3) CLHEP_LIB: CLHEP To modify " \
                            "default settings, select number above (e.g. 2) [Press [Enter] for default settings]" % 
                            {'clhepdir': clhepdir}: "",
                          "By default 'static' (.a) libraries are built. Do you want to build 'shared' (.so) " \
                            "libraries? [n]": "y",
                          "You selected to build 'shared' (.so) libraries. Do you want to build 'static' (.a) " \
                            "libraries too? [n]": "y",
                          "Do you want to build 'global' compound libraries? [n]": "",
                          "Do you want to compile libraries in DEBUG mode (-g)? [n]": "",
                          "G4UI_NONE If this variable is set, no UI sessions nor any UI libraries are built. " \
                            "This can be useful when running a pure batch job or in a user framework having its own " \
                            "UI system. Do you want to set this variable ? [n]": "",
                          "G4UI_BUILD_XAW_SESSION G4UI_USE_XAW Specifies to include and use the XAW interfaces in " \
                            "the application to be built. The XAW (X11 Athena Widget set) extensions are required to " \
                            "activate and build this driver. [n]": "",
                          "G4UI_BUILD_XM_SESSION G4UI_USE_XM Specifies to include and use the XM Motif based user " \
                            "interfaces. The XM Motif extensions are required to activate and build this driver. [n]": "",
                          "G4VIS_NONE If this variable is set, no visualization drivers will be built or used. Do " \
                            "you want to set this variable ? [n]": "n",
                          "G4VIS_BUILD_OPENGLX_DRIVER G4VIS_USE_OPENGLX It is an interface to the de facto standard " \
                            "3D graphics library, OpenGL. It is well suited for real-time fast visualization and " \
                            "prototyping. The X11 version of the OpenGL libraries is required. [n]": "",
                          "G4VIS_BUILD_OPENGLXM_DRIVER G4VIS_USE_OPENGLXM It is an interface to the de facto " \
                            "standard 3D graphics library, OpenGL. It is well suited for real-time fast visualization " \
                            "and prototyping. The X11 version of the OpenGL libraries and the Motif Xm extension is " \
                            "required. [n]": "",
                          "G4VIS_BUILD_DAWN_DRIVER G4VIS_USE_DAWN DAWN drivers are interfaces to the Fukui Renderer " \
                            "DAWN. DAWN is a vectorized 3D PostScript processor suited to prepare technical high " \
                            "quality outputs for presentation and/or documentation. [n]": "",
                          "G4VIS_BUILD_OIX_DRIVER G4VIS_USE_OIX The OpenInventor driver is based on OpenInventor tech" \
                            "nology for scientific visualization. The X11 version of OpenInventor is required. [n]": "",
                          "G4VIS_BUILD_RAYTRACERX_DRIVER G4VIS_USE_RAYTRACERX Allows for interactive ray-tracing " \
                            "graphics through X11. The X11 package is required. [n]": "",
                          "G4VIS_BUILD_VRML_DRIVER G4VIS_USE_VRML These driver generate VRML files, which describe " \
                            "3D scenes to be visualized with a proper VRML viewer. [n]": "",
                          "G4LIB_BUILD_GDML Setting this variable will enable building of the GDML plugin module " \
                            "embedded in Geant4 for detector description persistency. It requires your system to have " \
                            "the XercesC library and headers installed. Do you want to set this variable? [n]": "",
                          "G4LIB_BUILD_G3TOG4 The utility module 'g3tog4' will be built by setting this variable. " \
                            "NOTE: it requires a valid FORTRAN compiler to be installed on your system and the " \
                            "'cernlib' command in the path, in order to build the ancillary tools! Do you want to " \
                            "build 'g3tog4' ? [n]": "",
                          "G4LIB_BUILD_ZLIB Do you want to activate compression for output files generated by the " \
                            "HepRep visualization driver? [n]": "y",
                          "G4ANALYSIS_USE Activates the configuration setup for allowing plugins to analysis tools " \
                            "based on AIDA (Astract Interfaces for Data Analysis). In order to use AIDA features and " \
                            "compliant analysis tools, the proper environment for these tools will have to be set " \
                            "(see documentation for the specific analysis tools). [n]": "",
                          "Press [Enter] to start installation or use a shell escape to edit config.sh: ": "",
                          # extra questions and answers for version 9.2.p03
                          "Directory %s doesn't exist. Use that name anyway? [n]" % dst: "y",
                          "Specify the path where the Geant4 data libraries PhotonEvaporation%s " \
                            "RadioactiveDecay%s G4EMLOW%s G4NDL%s G4ABLA%s are " \
                            "installed. For now, a flat directory structure is assumed, and this can be customized " \
                            "at the next step if needed. [%s/data]" % (self.cfg['PhotonEvaporationVersion'],
                                                                       self.cfg['G4RadioactiveDecayVersion'],
                                                                       self.cfg['G4EMLOWVersion'],
                                                                       self.cfg['G4NDLVersion'],
                                                                       self.cfg['G4ABLAVersion'],
                                                                       pwd
                                                                      ): "%s/data" % dst,
                          "Please enter 1) Another path to search in 2) 'f' to force the use of the path " \
                            "you entered previously (the data libraries are not needed to build Geant4, but " \
                            "are needed to run applications later). 3) 'c' to customize the data paths, e.g. " \
                            "if you have the data libraries installed in different locations. [f]": "",
                          "G4UI_BUILD_QT_SESSION G4UI_USE_QT Setting these variables will enable the building " \
                            "of the G4 Qt based user interface module and the use of this module in your " \
                            "applications respectively. The Qt3 or Qt4 headers, libraries and moc application are " \
                            "required to enable the building of this module. Do you want to enable build and use of " \
                            "this module? [n]": "",
                          # extra questions and answers for version 9.4.po1
                          "What is the path to the Geant4 source tree? [%s]" % pwd: "",
                          "Where should Geant4 be installed? [%s]" % pwd: dst,
                          "Do you want to install all Geant4 headers in one directory? [n]": "y",
                          "Do you want to build shared libraries? [y]": "",
                          "Do you want to build static libraries too? [n]": "",
                          "Do you want to build global libraries? [y]": "",
                          "Do you want to build granular libraries as well? [n]": "",
                          "Do you want to build libraries with debugging information? [n]": "",
                          "Specify the path where the Geant4 data libraries are installed: [%s/data]" % pwd: "%s/data" % dst,
                          "How many parallel jobs should make launch? [1]": "%s" % self.cfg['parallel'],
                          "Please enter 1) Another path to search in 2) 'f' to force the use of the path you entered " \
                            "previously (the data libraries are NOT needed to build Geant4, but are needed to run " \
                            "applications later). 3) 'c' to customize the data paths, e.g. if you have the data " \
                            "libraries installed in different locations. [f]": "",
                          "Enable building of User Interface (UI) modules? [y]": "",
                          "Enable building of the XAW (X11 Athena Widget set) UI module? [n]": "",
                          "Enable building of the X11-Motif (Xm) UI module? [n]": "",
                          "Enable building of the Qt UI module? [n]": "",
                          "Enable building of visualization drivers? [y]": "n",
                          "Enable the Geometry Description Markup Language (GDML) module? [n]": "",
                          "Enable build of the g3tog4 utility module? [n]": "",
                          "Enable internal zlib compression for HepRep visualization? [n] ": "",
                         }

            self.noqanda = [r"Compiling\s+.*?\s+\.\.\.",
                            r"Making\s+dependency\s+for\s+file\s+.*?\s+\.\.\.",
                            r"Making\s+libname\.map\s+starter\s+file\s+\.\.\.",
                            r"Making\s+libname\.map\s+\.\.\.",
                            r"Reading\s+library\s+get_name\s+map\s+file\s*\.\.\.",
                            r"Reading\s+dependency\s+files\s*\.\.\.",
                            r"Creating\s+shared\s+library\s+.*?\s+\.\.\."
                           ]

            run_cmd_qa(cmd, self.qanda, self.noqanda, log_all=True, simple=True)

            # determining self.g4system
            try:
                scriptdirbase = os.path.join(pwd, '.config', 'bin')
                filelist = os.listdir(scriptdirbase)
            except OSError, err:
                self.log.error("Failed to determine self.g4system: %s" % err)
    
            if len(filelist) != 1:
                self.log.error("Exactly one directory is expected in %s; found back: %s" % (scriptdirbase, filelist))
            else:
                self.g4system = filelist[0]
    
            self.scriptdir = os.path.join(scriptdirbase, self.g4system)
            if not os.path.isdir(self.scriptdir):
                self.log.error("Something went wrong. Dir: %s doesn't exist." % self.scriptdir)
            self.log.info("The directory containing several important scripts to be copied was found: %s" % self.scriptdir)

            # copying config.sh to pwd
            try:
                self.log.info("copying config.sh to %s" % pwd)
                shutil.copy2(os.path.join(self.scriptdir, 'config.sh'), pwd)
            except IOError, err:
                self.log.error("Failed to copy config.sh to %s" % pwd)
Exemplo n.º 42
0
 def test_run_cmd_qa(self):
     """Basic test for run_cmd_qa function."""
     (out, ec) = ft.run_cmd_qa("echo question; read x; echo $x", {"question": "answer"})
     self.assertEqual(out, "question\nanswer\n")
     # no reason echo hello could fail
     self.assertEqual(ec, 0)
            (r'Confirm library .* is .*',
             'y'),  # this one needs to be tried first!
            (r'.*fortran 90 compiler name .*\s*:\n\(suggestions\s*: .*\)',
             os.getenv('F90')),
            (r'.*fortran 90 compiler interfaced with .*\s*:\n\(suggestions\s*: .*\)',
             f90_seq),
            (r'Please type the ABSOLUTE name of .*library.*, or ignore\s*[:]*\s*[\n]*.*',
             ''),
            (r'Please .* to save this draft configuration file :\n.*',
             '%s.x' % self.conf_file),
        ])

        env.setvar('GMKTMP', self.builddir)
        env.setvar('GMKFILE', self.conf_file)

        run_cmd_qa("gmkfilemaker", qa, std_qa=stdqa)

        # set environment variables for installation dirs
        env.setvar('ROOTPACK', os.path.join(self.installdir, 'rootpack'))
        env.setvar('ROOTBIN', os.path.join(self.installdir, 'rootpack'))
        env.setvar('HOMEPACK', os.path.join(self.installdir, 'pack'))
        env.setvar('HOMEBIN', os.path.join(self.installdir, 'pack'))

    def build_step(self):
        """No separate build procedure for ALADIN (see install_step)."""

        pass

    def test_step(self):
        """Custom built-in test procedure for ALADIN."""
class EB_ALADIN(EasyBlock):
    """Support for building/installing ALADIN."""
    def __init__(self, *args, **kwargs):
        """Initialisation of custom class variables for ALADIN."""
        super(EB_ALADIN, self).__init__(*args, **kwargs)

        self.conf_file = None
        self.conf_filepath = None
        self.rootpack_dir = None

        self.orig_library_path = None

    @staticmethod
    def extra_options():
        """Custom easyconfig parameters for ALADIN."""

        extra_vars = {
            'optional_extra_param':
            ['default value', "short description", CUSTOM],
        }
        return EasyBlock.extra_options(extra_vars)

    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)

        # build gmkpack, update PATH and set GMKROOT
        # we build gmkpack here because a config file is generated in the gmkpack isntall path
        try:
            gmkpack_dir = [x for x in builddirs if x.startswith('gmkpack')][0]
            os.chdir(os.path.join(self.builddir, gmkpack_dir))

            qa = {
                'Do you want to run the configuration file maker assistant now (y) or later [n] ?':
                'n',
            }

            run_cmd_qa("./build_gmkpack", qa)

            os.chdir(cwd)

            paths = os.getenv('PATH').split(':')
            paths.append(os.path.join(self.builddir, gmkpack_dir, 'util'))
            env.setvar('PATH', ':'.join(paths))

            env.setvar('GMKROOT', os.path.join(self.builddir, gmkpack_dir))

        except OSError, err:
            self.log.error("Failed to build gmkpack: %s" % err)
Exemplo n.º 45
0
        if not f90_seq:
            # F90_SEQ is only defined when usempi is enabled
            f90_seq = os.getenv('F90')

        stdqa = OrderedDict([
                             (r'Confirm library .* is .*', 'y'),  # this one needs to be tried first!
                             (r'.*fortran 90 compiler name .*\s*:\n\(suggestions\s*: .*\)', os.getenv('F90')),
                             (r'.*fortran 90 compiler interfaced with .*\s*:\n\(suggestions\s*: .*\)', f90_seq),
                             (r'Please type the ABSOLUTE name of .*library.*, or ignore\s*[:]*\s*[\n]*.*', ''),  
                             (r'Please .* to save this draft configuration file :\n.*', '%s.x' % self.conf_file),
                            ])

        env.setvar('GMKTMP', self.builddir)
        env.setvar('GMKFILE', self.conf_file)

        run_cmd_qa("gmkfilemaker", qa, std_qa=stdqa)

        # set environment variables for installation dirs
        env.setvar('ROOTPACK', os.path.join(self.installdir, 'rootpack'))
        env.setvar('ROOTBIN', os.path.join(self.installdir, 'rootpack'))
        env.setvar('HOMEPACK', os.path.join(self.installdir, 'pack'))
        env.setvar('HOMEBIN', os.path.join(self.installdir, 'pack'))

    def build_step(self):
        """No separate build procedure for ALADIN (see install_step)."""

        pass

    def test_step(self):
        """Custom built-in test procedure for ALADIN."""