Exemple #1
0
def petsc_configure(configure_options):
  try:
    petscdir = os.environ['PETSC_DIR']
    sys.path.append(os.path.join(petscdir,'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), 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)
Exemple #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')
    try:
      sys.path.append(os.path.join(petscdir,'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), 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)
Exemple #3
0
def petsc_configure(configure_options):
    try:
        petscdir = os.environ['PETSC_DIR']
        sys.path.append(os.path.join(petscdir, '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), 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)
Exemple #4
0
def petsc_configure(configure_options):
    try:
        petscdir = os.environ["PETSC_DIR"]
        sys.path.append(os.path.join(petscdir, "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), 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)
Exemple #5
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, '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), 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)
Exemple #6
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()
Exemple #7
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()