Пример #1
0
  def t_configure(self):
    '''Runs configure.py if it is present, and either configure.log is missing or -forceConfigure is given'''
    if self.argDB['noConfigure']: return
    import config.framework

    root      = self.project.getRoot()
    framework = config.framework.Framework(sys.argv[1:])
    for arg in ['debugLevel', 'debugSections']:
      framework.argDB[arg] = self.argDB[arg]
    framework.argDB['log'] = os.path.join(root, 'configure.log')
    if not self.configureHeader is None:
      framework.header     = self.configureHeader
    # Load default configure module
    try:
      framework.addChild(self.getMakeModule(root, 'configure').Configure(framework))
    except ImportError:
      return
    # Run configuration only if the log file was absent or it is forced
    if self.argDB['forceConfigure'] or not framework.checkLog(framework.logName):
      try:
        framework.configure()
      except Exception, e:
        import traceback

        msg = 'CONFIGURATION FAILURE:\n'+str(e)+'\n'
        print msg
        framework.log.write(msg)
        traceback.print_tb(sys.exc_info()[2], file = framework.log)
        raise e
      framework.storeSubstitutions(self.argDB)
Пример #2
0
    def configure(self, configure_options):
        print '==============================================================================='
        print '             Configuring ' + self.Project + ' to compile on your system                       '
        print '==============================================================================='

        # Arguments passed in take precedence (but don't destroy argv[0])
        sys.argv = sys.argv[:1] + configure_options + sys.argv[1:]
        self.validateOptions(sys.argv)
        self.normalizeOptions(sys.argv)
        logMessages = self.systemKludges(sys.argv)

        import config.base
        import config.framework
        import cPickle

        framework = None
        arch = self.getArch(framework, sys.argv)

        try:
            framework = config.framework.Framework([
                '--configModules=' + self.Project + '.Configure',
                '--optionsModule=' + self.Project + '.compilerOptions'
            ] + sys.argv[1:],
                                                   loadArgDB=0)
            framework.arch = arch
            framework.setup()
            framework.logPrint('\n'.join(logMessages))
            framework.configure(out=sys.stdout)
            framework.storeSubstitutions(framework.argDB)
            framework.argDB['configureCache'] = cPickle.dumps(framework)
            for i in framework.packages:
                if hasattr(i, 'postProcess'):
                    i.postProcess()
            framework.printSummary()
            framework.logClear()
            framework.closeLog()
            try:
                self.cleanupLog(framework)
            except:
                # perhaps print an error about unable to shuffle logs?
                pass
            return 0
        except (RuntimeError, config.base.ConfigureSetupError), e:
            emsg = str(e)
            if not emsg.endswith('\n'): emsg = emsg + '\n'
            msg ='*******************************************************************************\n'\
                +'         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):\n' \
                +'-------------------------------------------------------------------------------\n'  \
                +emsg+'*******************************************************************************\n'
            se = ''
Пример #3
0
def petsc_configure(configure_options):
    if 'PETSC_DIR' in os.environ:
        petscdir = os.environ['PETSC_DIR']
        if petscdir.find(' ') > -1:
            raise RuntimeError(
                'Your PETSC_DIR ' + petscdir +
                ' has spaces in it; this is not allowed.\n Change the directory with PETSc to not have spaces in it'
            )
        if not os.path.isabs(petscdir):
            raise RuntimeError(
                'PETSC_DIR ("' + petscdir +
                '") is set as a relative path. It must be set as an absolute path.'
            )

        try:
            sys.path.append(os.path.join(petscdir, 'lib', 'petsc', 'bin'))
            import petscnagupgrade
            file = os.path.join(petscdir, '.nagged')
            if not petscnagupgrade.naggedtoday(file):
                petscnagupgrade.currentversion(petscdir)
        except:
            pass
    print(
        '============================================================================================='
    )
    print(
        '                      Configuring PETSc to compile on your system                            '
    )
    print(
        '============================================================================================='
    )

    try:
        # Command line arguments take precedence (but don't destroy argv[0])
        sys.argv = sys.argv[:1] + configure_options + sys.argv[1:]
        check_for_option_mistakes(sys.argv)
        check_for_option_changed(sys.argv)
    except (TypeError, ValueError) as e:
        emsg = str(e)
        if not emsg.endswith('\n'): emsg = emsg + '\n'
        msg ='*******************************************************************************\n'\
        +'                ERROR in COMMAND LINE ARGUMENT to ./configure \n' \
        +'-------------------------------------------------------------------------------\n'  \
        +emsg+'*******************************************************************************\n'
        sys.exit(msg)
    # check PETSC_ARCH
    check_for_unsupported_combinations(sys.argv)
    check_petsc_arch(sys.argv)
    check_broken_configure_log_links()

    #rename '--enable-' to '--with-'
    chkenable()
    # support a few standard configure option types
    chksynonyms()
    # Check for broken cygwin
    chkbrokencygwin()
    # Disable threads on RHL9
    chkrhl9()
    # Make sure cygwin-python is used on windows
    chkusingwindowspython()
    # Threads don't work for cygwin & python...
    chkcygwinpython()
    chkcygwinlink()
    chkdosfiles()
    chkcygwinwindowscompilers()
    chktmpnoexec()

    for l in range(1, len(sys.argv)):
        if sys.argv[l].startswith('--with-fc=') and sys.argv[l].endswith(
                'nagfor'):
            # need a way to save this value and later CC so that petscnagfor may use them
            name = sys.argv[l].split('=')[1]
            sys.argv[l] = '--with-fc=' + os.path.join(
                os.path.abspath('.'), 'lib', 'petsc', 'bin', 'petscnagfor')
            break

    # Should be run from the toplevel
    configDir = os.path.abspath('config')
    bsDir = os.path.join(configDir, 'BuildSystem')
    if not os.path.isdir(configDir):
        raise RuntimeError('Run configure from $PETSC_DIR, not ' +
                           os.path.abspath('.'))
    sys.path.insert(0, bsDir)
    sys.path.insert(0, configDir)
    import config.base
    import config.framework
    import pickle
    import traceback

    # Check Cray without modules
    check_cray_modules()

    tbo = None
    framework = None
    try:
        framework = config.framework.Framework([
            '--configModules=PETSc.Configure',
            '--optionsModule=config.compilerOptions'
        ] + sys.argv[1:],
                                               loadArgDB=0)
        framework.setup()
        framework.logPrint('\n'.join(extraLogs))
        framework.configure(out=sys.stdout)
        framework.storeSubstitutions(framework.argDB)
        framework.argDB['configureCache'] = pickle.dumps(framework)
        framework.printSummary()
        framework.argDB.save(force=True)
        framework.logClear()
        print_final_timestamp(framework)
        framework.closeLog()
        try:
            move_configure_log(framework)
        except:
            # perhaps print an error about unable to shuffle logs?
            pass
        return 0
    except (RuntimeError, config.base.ConfigureSetupError) as e:
        tbo = sys.exc_info()[2]
        emsg = str(e)
        if not emsg.endswith('\n'): emsg = emsg + '\n'
        msg ='*******************************************************************************\n'\
        +'         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):\n' \
        +'-------------------------------------------------------------------------------\n'  \
        +emsg+'*******************************************************************************\n'
        se = ''
    except (TypeError, ValueError) as e:
        # this exception is automatically deleted by Python so we need to save it to print below
        tbo = sys.exc_info()[2]
        emsg = str(e)
        if not emsg.endswith('\n'): emsg = emsg + '\n'
        msg ='*******************************************************************************\n'\
        +'    TypeError or ValueError possibly related to ERROR in COMMAND LINE ARGUMENT while running ./configure \n' \
        +'-------------------------------------------------------------------------------\n'  \
        +emsg+'*******************************************************************************\n'
        se = ''
    except ImportError as e:
        # this exception is automatically deleted by Python so we need to save it to print below
        tbo = sys.exc_info()[2]
        emsg = str(e)
        if not emsg.endswith('\n'): emsg = emsg + '\n'
        msg ='*******************************************************************************\n'\
        +'                     ImportError while runing ./configure \n' \
        +'-------------------------------------------------------------------------------\n'  \
        +emsg+'*******************************************************************************\n'
        se = ''
    except OSError as e:
        tbo = sys.exc_info()[2]
        emsg = str(e)
        if not emsg.endswith('\n'): emsg = emsg + '\n'
        msg ='*******************************************************************************\n'\
        +'                    OSError while running ./configure \n' \
        +'-------------------------------------------------------------------------------\n'  \
        +emsg+'*******************************************************************************\n'
        se = ''
    except SystemExit as e:
        tbo = sys.exc_info()[2]
        if e.code is None or e.code == 0:
            return
        if e.code == 10:
            sys.exit(10)
        msg ='*******************************************************************************\n'\
        +'         CONFIGURATION FAILURE  (Please send configure.log to [email protected])\n' \
        +'*******************************************************************************\n'
        se = str(e)
    except Exception as e:
        tbo = sys.exc_info()[2]
        msg ='*******************************************************************************\n'\
        +'        CONFIGURATION CRASH  (Please send configure.log to [email protected])\n' \
        +'*******************************************************************************\n'
        se = str(e)

    print(msg)
    if not framework is None:
        framework.logClear()
        if hasattr(framework, 'log'):
            try:
                if hasattr(framework, 'compilerDefines'):
                    framework.log.write('**** Configure header ' +
                                        framework.compilerDefines + ' ****\n')
                    framework.outputHeader(framework.log)
                if hasattr(framework, 'compilerFixes'):
                    framework.log.write('**** C specific Configure header ' +
                                        framework.compilerFixes + ' ****\n')
                    framework.outputCHeader(framework.log)
            except Exception as e:
                framework.log.write('Problem writing headers to log: ' +
                                    str(e))
            try:
                framework.log.write(msg + se)
                traceback.print_tb(tbo, file=framework.log)
                print_final_timestamp(framework)
                if hasattr(framework, 'log'): framework.log.close()
                move_configure_log(framework)
            except Exception as e:
                print(
                    'Error printing error message from exception or printing the traceback:'
                    + str(e))
                traceback.print_tb(sys.exc_info()[2])
            sys.exit(1)
        else:
            print(se)
            traceback.print_tb(tbo)
    else:
        print(se)
        traceback.print_tb(tbo)
    if hasattr(framework, 'log'): framework.log.close()
Пример #4
0
        self.executeTest(self.configureConversion)
        self.executeTest(self.configureMPI2)
        self.executeTest(self.configureTypes)
        self.executeTest(self.configureMPITypes)
        self.executeTest(self.configureMissingPrototypes)
        self.executeTest(self.SGIMPICheck)
        self.executeTest(self.CxxMPICheck)
        self.executeTest(self.FortranMPICheck)
        self.executeTest(self.configureIO)
        if self.libraries.check(
                self.dlib, "MPI_Alltoallw") and self.libraries.check(
                    self.dlib, "MPI_Type_create_indexed_block"):
            self.addDefine('HAVE_MPI_ALLTOALLW', 1)
        if self.libraries.check(self.dlib, "MPI_Comm_spawn"):
            self.addDefine('HAVE_MPI_COMM_SPAWN', 1)
        if self.libraries.check(self.dlib, "MPI_Win_create"):
            self.addDefine('HAVE_MPI_WIN_CREATE', 1)
        if self.libraries.check(self.dlib, "MPI_Finalized"):
            self.addDefine('HAVE_MPI_FINALIZED', 1)


if __name__ == '__main__':
    import config.framework
    import sys
    framework = config.framework.Framework(sys.argv[1:])
    framework.setupLogging(framework.clArgs)
    framework.children.append(Configure(framework))
    framework.configure()
    framework.dumpSubstitutions()
Пример #5
0
      self.addDefine('HAVE_MPI_ALLTOALLW',1)
    if self.libraries.check(self.dlib, "MPI_Win_create"):
      self.addDefine('HAVE_MPI_WIN_CREATE',1)
      self.addDefine('HAVE_MPI_REPLACE',1) # MPI_REPLACE is strictly for use with the one-sided function MPI_Accumulate
    funcs = '''MPI_Comm_spawn MPI_Type_get_envelope MPI_Type_get_extent MPI_Type_dup MPI_Init_thread
      MPIX_Iallreduce MPI_Iallreduce MPI_Ibarrier MPI_Finalized MPI_Exscan'''.split()
    for f in funcs:
      if self.libraries.check(self.dlib, f):
        self.addDefine('HAVE_' + f.upper(),1)

    oldFlags = self.compilers.CPPFLAGS # Disgusting save and restore
    self.compilers.CPPFLAGS += ' '+self.headers.toString(self.include)
    if self.checkCompile('#include <mpi.h>', 'int combiner = MPI_COMBINER_DUP;'):
      self.addDefine('HAVE_MPI_COMBINER_DUP',1)
    self.compilers.CPPFLAGS = oldFlags

    if self.libraries.check(self.dlib, "MPIDI_CH3I_sock_set"):
      self.addDefine('HAVE_MPICH_CH3_SOCK', 1)
    if self.libraries.check(self.dlib, "MPIDI_CH3I_sock_fixed_nbc_progress"):
      # Indicates that this bug was fixed: http://trac.mpich.org/projects/mpich/ticket/1785
      self.addDefine('HAVE_MPICH_CH3_SOCK_FIXED_NBC_PROGRESS', 1)

if __name__ == '__main__':
  import config.framework
  import sys
  framework = config.framework.Framework(sys.argv[1:])
  framework.setupLogging(framework.clArgs)
  framework.children.append(Configure(framework))
  framework.configure()
  framework.dumpSubstitutions()
Пример #6
0
  configDir = os.path.abspath('config')
  bsDir     = os.path.join(configDir, 'BuildSystem')
  if not os.path.isdir(configDir):
    raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.'))
  sys.path.insert(0, bsDir)
  sys.path.insert(0, configDir)
  import config.base
  import config.framework
  import cPickle

  framework = None
  try:
    framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=config.compilerOptions']+sys.argv[1:], loadArgDB = 0)
    framework.setup()
    framework.logPrint('\n'.join(extraLogs))
    framework.configure(out = sys.stdout)
    framework.storeSubstitutions(framework.argDB)
    framework.argDB['configureCache'] = cPickle.dumps(framework)
    framework.printSummary()
    framework.argDB.save(force = True)
    framework.logClear()
    print_final_timestamp(framework)
    framework.closeLog()
    try:
      move_configure_log(framework)
    except:
      # perhaps print an error about unable to shuffle logs?
      pass
    return 0
  except (RuntimeError, config.base.ConfigureSetupError), e:
    emsg = str(e)
Пример #7
0
    sys.path.insert(0, bsDir)
    sys.path.insert(0, configDir)
    import config.base
    import config.framework
    import cPickle

    framework = None
    try:
        framework = config.framework.Framework([
            '--configModules=PETSc.Configure',
            '--optionsModule=config.compilerOptions'
        ] + sys.argv[1:],
                                               loadArgDB=0)
        framework.setup()
        framework.logPrint('\n'.join(extraLogs))
        framework.configure(out=sys.stdout)
        framework.storeSubstitutions(framework.argDB)
        framework.argDB['configureCache'] = cPickle.dumps(framework)
        framework.printSummary()
        framework.argDB.save(force=True)
        framework.logClear()
        print_final_timestamp(framework)
        framework.closeLog()
        try:
            move_configure_log(framework)
        except:
            # perhaps print an error about unable to shuffle logs?
            pass
        return 0
    except (RuntimeError, config.base.ConfigureSetupError), e:
        emsg = str(e)
Пример #8
0
def petsc_configure(configure_options):
    print '==============================================================================='
    print '             Configuring PETSc to compile on your system                       '
    print '==============================================================================='

    # Command line arguments take precedence (but don't destroy argv[0])
    sys.argv = sys.argv[:1] + configure_options + sys.argv[1:]
    check_for_option_mistakes(sys.argv)
    # check PETSC_ARCH
    check_petsc_arch(sys.argv)
    check_broken_configure_log_links()

    # support a few standard configure option types
    for l in range(0, len(sys.argv)):
        name = sys.argv[l]
        if name.find('enable-') >= 0:
            if name.find('=') == -1:
                sys.argv[l] = name.replace('enable-', 'with-') + '=1'
            else:
                head, tail = name.split('=', 1)
                sys.argv[l] = head.replace('enable-', 'with-') + '=' + tail
        if name.find('disable-') >= 0:
            if name.find('=') == -1:
                sys.argv[l] = name.replace('disable-', 'with-') + '=0'
            else:
                head, tail = name.split('=', 1)
                if tail == '1': tail = '0'
                sys.argv[l] = head.replace('disable-', 'with-') + '=' + tail
        if name.find('without-') >= 0:
            if name.find('=') == -1:
                sys.argv[l] = name.replace('without-', 'with-') + '=0'
            else:
                head, tail = name.split('=', 1)
                if tail == '1': tail = '0'
                sys.argv[l] = head.replace('without-', 'with-') + '=' + tail

    # Check for broken cygwin
    chkbrokencygwin()
    # Disable threads on RHL9
    chkrhl9()
    # Make sure cygwin-python is used on windows
    chkusingwindowspython()
    # Threads don't work for cygwin & python-2.4, 2.5 etc..
    chkcygwinpythonver()
    chkcygwinlink()

    # Should be run from the toplevel
    configDir = os.path.abspath('config')
    bsDir = os.path.join(configDir, 'BuildSystem')
    if not os.path.isdir(configDir):
        raise RuntimeError('Run configure from $PETSC_DIR, not ' +
                           os.path.abspath('.'))
    if not os.path.isdir(bsDir):
        print '==============================================================================='
        print '''++ Could not locate BuildSystem in %s.''' % configDir
        print '''++ Downloading it using "hg clone http://hg.mcs.anl.gov/petsc/BuildSystem %s"''' % bsDir
        print '==============================================================================='
        (status, output) = commands.getstatusoutput(
            'hg clone http://petsc.cs.iit.edu/petsc/BuildSystem ' + bsDir)
        if status:
            if output.find('ommand not found') >= 0:
                print '==============================================================================='
                print '''** Unable to locate hg (Mercurial) to download BuildSystem; make sure hg is'''
                print '''** in your path or manually copy BuildSystem to $PETSC_DIR/config/BuildSystem'''
                print '''**  from a machine where you do have hg installed and can clone BuildSystem. '''
                print '==============================================================================='
            elif output.find('Cannot resolve host') >= 0:
                print '==============================================================================='
                print '''** Unable to download BuildSystem. You must be off the network.'''
                print '''** Connect to the internet and run config/configure.py again.'''
                print '==============================================================================='
            else:
                print '==============================================================================='
                print '''** Unable to download BuildSystem. Please send this message to [email protected]'''
                print '==============================================================================='
            print output
            sys.exit(3)

    sys.path.insert(0, bsDir)
    sys.path.insert(0, configDir)
    import config.base
    import config.framework
    import cPickle

    framework = None
    try:
        framework = config.framework.Framework([
            '--configModules=PETSc.Configure',
            '--optionsModule=PETSc.compilerOptions'
        ] + sys.argv[1:],
                                               loadArgDB=0)
        framework.setup()
        framework.logPrint('\n'.join(extraLogs))
        framework.configure(out=sys.stdout)
        framework.storeSubstitutions(framework.argDB)
        framework.argDB['configureCache'] = cPickle.dumps(framework)
        import PETSc.packages
        for i in framework.packages:
            if hasattr(i, 'postProcess'):
                i.postProcess()
        framework.printSummary()
        framework.logClear()
        framework.closeLog()
        try:
            move_configure_log(framework)
        except:
            # perhaps print an error about unable to shuffle logs?
            pass
        return 0
    except (RuntimeError, config.base.ConfigureSetupError), e:
        emsg = str(e)
        if not emsg.endswith('\n'): emsg = emsg + '\n'
        msg ='*******************************************************************************\n'\
        +'         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):\n' \
        +'-------------------------------------------------------------------------------\n'  \
        +emsg+'*******************************************************************************\n'
        se = ''
Пример #9
0
    def configure(self, configure_options):
        print(
            '==============================================================================='
        )
        print('             Configuring ' + self.Project +
              ' to compile on your system                       ')
        print(
            '==============================================================================='
        )

        # Arguments passed in take precedence (but don't destroy argv[0])
        sys.argv = sys.argv[:1] + configure_options + sys.argv[1:]
        self.validateOptions(sys.argv)
        self.normalizeOptions(sys.argv)
        logMessages = self.systemKludges(sys.argv)

        import config.base
        import config.framework
        import pickle

        framework = None
        arch = self.getArch(framework, sys.argv)

        try:
            framework = config.framework.Framework([
                '--configModules=' + self.Project + '.Configure',
                '--optionsModule=' + self.Project + '.compilerOptions'
            ] + sys.argv[1:],
                                                   loadArgDB=0)
            framework.arch = arch
            framework.setup()
            framework.logPrint('\n'.join(logMessages))
            framework.configure(out=sys.stdout)
            framework.storeSubstitutions(framework.argDB)
            framework.argDB['configureCache'] = pickle.dumps(framework)
            for i in framework.packages:
                if hasattr(i, 'postProcess'):
                    i.postProcess()
            framework.printSummary()
            framework.logClear()
            framework.closeLog()
            try:
                self.cleanupLog(framework)
            except:
                # perhaps print an error about unable to shuffle logs?
                pass
            return 0
        except (RuntimeError, config.base.ConfigureSetupError) as e:
            emsg = str(e)
            if not emsg.endswith('\n'): emsg = emsg + '\n'
            msg ='*******************************************************************************\n'\
                +'         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):\n' \
                +'-------------------------------------------------------------------------------\n'  \
                +emsg+'*******************************************************************************\n'
            se = ''
        except (TypeError, ValueError) as e:
            emsg = str(e)
            if not emsg.endswith('\n'): emsg = emsg + '\n'
            msg ='*******************************************************************************\n'\
                +'                ERROR in COMMAND LINE ARGUMENT to ./configure \n' \
                +'-------------------------------------------------------------------------------\n'  \
                +emsg+'*******************************************************************************\n'
            se = ''
        except ImportError as e:
            emsg = str(e)
            if not emsg.endswith('\n'): emsg = emsg + '\n'
            msg ='*******************************************************************************\n'\
                +'                     UNABLE to FIND MODULE for ./configure \n' \
                +'-------------------------------------------------------------------------------\n'  \
                +emsg+'*******************************************************************************\n'
            se = ''
        except OSError as e:
            emsg = str(e)
            if not emsg.endswith('\n'): emsg = emsg + '\n'
            msg ='*******************************************************************************\n'\
                +'                    UNABLE to EXECUTE BINARIES for ./configure \n' \
                +'-------------------------------------------------------------------------------\n'  \
                +emsg+'*******************************************************************************\n'
            se = ''
        except SystemExit as e:
            if e.code is None or e.code == 0:
                return
            msg ='*******************************************************************************\n'\
                +'         CONFIGURATION FAILURE  (Please send configure.log to the Amanzi developers)\n' \
                +'*******************************************************************************\n'
            se = str(e)
        except Exception as e:
            msg ='*******************************************************************************\n'\
                +'        CONFIGURATION CRASH  (Please send configure.log to the Amanzi developers)\n' \
                +'*******************************************************************************\n'
            se = str(e)
        print(msg)
        if framework is not None:
            framework.logClear()
            if hasattr(framework, 'log'):
                import traceback
                try:
                    framework.log.write(msg + se)
                    traceback.print_tb(sys.exc_info()[2], file=framework.log)
                    framework.log.close()
                    self.cleanupLog(framework)
                except:
                    pass
                sys.exit(1)
        else:
            print(se)
            import traceback
            traceback.print_tb(sys.exc_info()[2])
        return
Пример #10
0
def petsc_configure(configure_options): 
  print '==============================================================================='
  print '             Configuring PETSc to compile on your system                       '
  print '==============================================================================='  

  # Command line arguments take precedence (but don't destroy argv[0])
  sys.argv = sys.argv[:1] + configure_options + sys.argv[1:]
  check_for_option_mistakes(sys.argv)
  # check PETSC_ARCH
  check_petsc_arch(sys.argv)
  check_broken_configure_log_links()

  # support a few standard configure option types
  for l in range(0,len(sys.argv)):
    name = sys.argv[l]
    if name.find('enable-') >= 0:
      if name.find('=') == -1:
        sys.argv[l] = name.replace('enable-','with-')+'=1'
      else:
        head, tail = name.split('=', 1)
        sys.argv[l] = head.replace('enable-','with-')+'='+tail
    if name.find('disable-') >= 0:
      if name.find('=') == -1:
        sys.argv[l] = name.replace('disable-','with-')+'=0'
      else:
        head, tail = name.split('=', 1)
        if tail == '1': tail = '0'
        sys.argv[l] = head.replace('disable-','with-')+'='+tail
    if name.find('without-') >= 0:
      if name.find('=') == -1:
        sys.argv[l] = name.replace('without-','with-')+'=0'
      else:
        head, tail = name.split('=', 1)
        if tail == '1': tail = '0'
        sys.argv[l] = head.replace('without-','with-')+'='+tail

  # Check for broken cygwin
  chkbrokencygwin()
  # Disable threads on RHL9
  chkrhl9()
  # Make sure cygwin-python is used on windows
  chkusingwindowspython()
  # Threads don't work for cygwin & python-2.4, 2.5 etc..
  chkcygwinpythonver()
  chkcygwinlink()

  # Should be run from the toplevel
  configDir = os.path.abspath('config')
  bsDir     = os.path.join(configDir, 'BuildSystem')
  if not os.path.isdir(configDir):
    raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.'))
  if not os.path.isdir(bsDir):
    print '==============================================================================='
    print '''++ Could not locate BuildSystem in %s.''' % configDir
    print '''++ Downloading it using "hg clone http://hg.mcs.anl.gov/petsc/BuildSystem %s"''' % bsDir
    print '==============================================================================='
    (status,output) = commands.getstatusoutput('hg clone http://petsc.cs.iit.edu/petsc/BuildSystem '+ bsDir)
    if status:
      if output.find('ommand not found') >= 0:
        print '==============================================================================='
        print '''** Unable to locate hg (Mercurial) to download BuildSystem; make sure hg is'''
        print '''** in your path or manually copy BuildSystem to $PETSC_DIR/config/BuildSystem'''
        print '''**  from a machine where you do have hg installed and can clone BuildSystem. '''
        print '==============================================================================='
      elif output.find('Cannot resolve host') >= 0:
        print '==============================================================================='
        print '''** Unable to download BuildSystem. You must be off the network.'''
        print '''** Connect to the internet and run config/configure.py again.'''
        print '==============================================================================='
      else:
        print '==============================================================================='
        print '''** Unable to download BuildSystem. Please send this message to [email protected]'''
        print '==============================================================================='
      print output
      sys.exit(3)
      
  sys.path.insert(0, bsDir)
  sys.path.insert(0, configDir)
  import config.base
  import config.framework
  import cPickle

  framework = None
  try:
    framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=PETSc.compilerOptions']+sys.argv[1:], loadArgDB = 0)
    framework.setup()
    framework.logPrint('\n'.join(extraLogs))
    framework.configure(out = sys.stdout)
    framework.storeSubstitutions(framework.argDB)
    framework.argDB['configureCache'] = cPickle.dumps(framework)
    import PETSc.packages
    for i in framework.packages:
      if hasattr(i,'postProcess'):
        i.postProcess()
    framework.printSummary()
    framework.logClear()
    framework.closeLog()
    try:
      move_configure_log(framework)
    except:
      # perhaps print an error about unable to shuffle logs?
      pass
    return 0
  except (RuntimeError, config.base.ConfigureSetupError), e:
    emsg = str(e)
    if not emsg.endswith('\n'): emsg = emsg+'\n'
    msg ='*******************************************************************************\n'\
    +'         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):\n' \
    +'-------------------------------------------------------------------------------\n'  \
    +emsg+'*******************************************************************************\n'
    se = ''
Пример #11
0
def petsc_configure(configure_options):
  if 'PETSC_DIR' in os.environ:
    petscdir = os.environ['PETSC_DIR']
    if petscdir.find(' ') > -1:
      raise RuntimeError('Your PETSC_DIR '+petscdir+' has spaces in it; this is not allowed.\n Change the directory with PETSc to not have spaces in it')
    try:
      sys.path.append(os.path.join(petscdir,'lib','petsc','bin'))
      import petscnagupgrade
      file     = os.path.join(petscdir,'.nagged')
      if not petscnagupgrade.naggedtoday(file):
        petscnagupgrade.currentversion(petscdir)
    except:
      pass
  print('===============================================================================')
  print('             Configuring PETSc to compile on your system                       ')
  print('===============================================================================')

  try:
    # Command line arguments take precedence (but don't destroy argv[0])
    sys.argv = sys.argv[:1] + configure_options + sys.argv[1:]
    check_for_option_mistakes(sys.argv)
    check_for_option_changed(sys.argv)
  except (TypeError, ValueError) as e:
    emsg = str(e)
    if not emsg.endswith('\n'): emsg = emsg+'\n'
    msg ='*******************************************************************************\n'\
    +'                ERROR in COMMAND LINE ARGUMENT to ./configure \n' \
    +'-------------------------------------------------------------------------------\n'  \
    +emsg+'*******************************************************************************\n'
    sys.exit(msg)
  # check PETSC_ARCH
  check_for_unsupported_combinations(sys.argv)
  check_petsc_arch(sys.argv)
  check_broken_configure_log_links()

  #rename '--enable-' to '--with-'
  chkenable()
  # support a few standard configure option types
  chksynonyms()
  # Check for broken cygwin
  chkbrokencygwin()
  # Disable threads on RHL9
  chkrhl9()
  # Make sure cygwin-python is used on windows
  chkusingwindowspython()
  # Threads don't work for cygwin & python...
  chkcygwinpython()
  chkcygwinlink()
  chkdosfiles()

  # Should be run from the toplevel
  configDir = os.path.abspath('config')
  bsDir     = os.path.join(configDir, 'BuildSystem')
  if not os.path.isdir(configDir):
    raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.'))
  sys.path.insert(0, bsDir)
  sys.path.insert(0, configDir)
  import config.base
  import config.framework
  import pickle

  framework = None
  try:
    framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=config.compilerOptions']+sys.argv[1:], loadArgDB = 0)
    framework.setup()
    framework.logPrint('\n'.join(extraLogs))
    framework.configure(out = sys.stdout)
    framework.storeSubstitutions(framework.argDB)
    framework.argDB['configureCache'] = pickle.dumps(framework)
    framework.printSummary()
    framework.argDB.save(force = True)
    framework.logClear()
    print_final_timestamp(framework)
    framework.closeLog()
    try:
      move_configure_log(framework)
    except:
      # perhaps print an error about unable to shuffle logs?
      pass
    return 0
  except (RuntimeError, config.base.ConfigureSetupError) as e:
    emsg = str(e)
    if not emsg.endswith('\n'): emsg = emsg+'\n'
    msg ='*******************************************************************************\n'\
    +'         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):\n' \
    +'-------------------------------------------------------------------------------\n'  \
    +emsg+'*******************************************************************************\n'
    se = ''
  except (TypeError, ValueError) as e:
    emsg = str(e)
    if not emsg.endswith('\n'): emsg = emsg+'\n'
    msg ='*******************************************************************************\n'\
    +'                ERROR in COMMAND LINE ARGUMENT to ./configure \n' \
    +'-------------------------------------------------------------------------------\n'  \
    +emsg+'*******************************************************************************\n'
    se = ''
  except ImportError as e :
    emsg = str(e)
    if not emsg.endswith('\n'): emsg = emsg+'\n'
    msg ='*******************************************************************************\n'\
    +'                     UNABLE to FIND MODULE for ./configure \n' \
    +'-------------------------------------------------------------------------------\n'  \
    +emsg+'*******************************************************************************\n'
    se = ''
  except OSError as e :
    emsg = str(e)
    if not emsg.endswith('\n'): emsg = emsg+'\n'
    msg ='*******************************************************************************\n'\
    +'                    UNABLE to EXECUTE BINARIES for ./configure \n' \
    +'-------------------------------------------------------------------------------\n'  \
    +emsg+'*******************************************************************************\n'
    se = ''
  except SystemExit as e:
    if e.code is None or e.code == 0:
      return
    if e.code is 10:
      sys.exit(10)
    msg ='*******************************************************************************\n'\
    +'         CONFIGURATION FAILURE  (Please send configure.log to [email protected])\n' \
    +'*******************************************************************************\n'
    se  = str(e)
  except Exception as e:
    msg ='*******************************************************************************\n'\
    +'        CONFIGURATION CRASH  (Please send configure.log to [email protected])\n' \
    +'*******************************************************************************\n'
    se  = str(e)

  print(msg)
  if not framework is None:
    framework.logClear()
    if hasattr(framework, 'log'):
      try:
        if hasattr(framework,'compilerDefines'):
          framework.log.write('**** Configure header '+framework.compilerDefines+' ****\n')
          framework.outputHeader(framework.log)
        if hasattr(framework,'compilerFixes'):
          framework.log.write('**** C specific Configure header '+framework.compilerFixes+' ****\n')
          framework.outputCHeader(framework.log)
      except Exception as e:
        framework.log.write('Problem writing headers to log: '+str(e))
      import traceback
      try:
        framework.log.write(msg+se)
        traceback.print_tb(sys.exc_info()[2], file = framework.log)
        print_final_timestamp(framework)
        if hasattr(framework,'log'): framework.log.close()
        move_configure_log(framework)
      except:
        pass
      sys.exit(1)
  else:
    print(se)
    import traceback
    traceback.print_tb(sys.exc_info()[2])
  if hasattr(framework,'log'): framework.log.close()