示例#1
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 = ''
示例#2
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()
示例#3
0
                           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:
示例#4
0
  # 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 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:
示例#5
0
    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=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)
        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:
示例#6
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 = ''
示例#7
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
示例#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 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()