15d5a5a7bSMatthew Knepley#!/usr/bin/env python 25d5a5a7bSMatthew Knepleyimport os 35d5a5a7bSMatthew Knepleyimport sys 44f8a5b45SBarry Smithimport commands 5a1eda5bfSSatish Balay# to load ~/.pythonrc.py before inserting correct BuildSystem to path 6a1eda5bfSSatish Balayimport user 77c9abfe7SSatish BalayextraLogs = [] 8b0b472b0SSatish Balaypetsc_arch = '' 94b8aa89bSBarry Smith 1044b0d7f9SSatish Balay# Use en_US as language so that BuildSystem parses compiler messages in english 119b436e4bSSatish Balayif 'LC_LOCAL' in os.environ and os.environ['LC_LOCAL'] != '' and os.environ['LC_LOCAL'] != 'en_US' and os.environ['LC_LOCAL']!= 'en_US.UTF-8': os.environ['LC_LOCAL'] = 'en_US.UTF-8' 129b436e4bSSatish Balayif 'LANG' in os.environ and os.environ['LANG'] != '' and os.environ['LANG'] != 'en_US' and os.environ['LANG'] != 'en_US.UTF-8': os.environ['LANG'] = 'en_US.UTF-8' 1344b0d7f9SSatish Balay 146b66766aSSatish Balayif not hasattr(sys, 'version_info') or not sys.version_info[0] == 2 or not sys.version_info[1] >= 3: 156b66766aSSatish Balay print '*** You must have Python2 version 2.3 or higher to run ./configure *****' 16495ffa62SBarry Smith print '* Python is easy to install for end users or sys-admin. *' 1732077d6dSBarry Smith print '* http://www.python.org/download/ *' 1832077d6dSBarry Smith print '* *' 19495ffa62SBarry Smith print '* You CANNOT configure PETSc without Python *' 20495ffa62SBarry Smith print '* http://www.mcs.anl.gov/petsc/petsc-as/documentation/installation.html *' 21a0022257SSatish Balay print '*******************************************************************************' 22b26a8723SBarry Smith sys.exit(4) 232fb34ac0SMatthew Knepley 244d18482cSSatish Balayif sys.platform == 'win32': 254d18482cSSatish Balay print '**** Windows python detected. ****' 264d18482cSSatish Balay print sys.version,'on',sys.platform 274d18482cSSatish Balay print '' 284d18482cSSatish Balay print '** You must use cygwin python, but not windows python with PETSc configure. ***' 294d18482cSSatish Balay sys.exit(4) 304d18482cSSatish Balay 31ccb279e1SMatthew Knepleydef check_for_option_mistakes(opts): 3245faeebdSBarry Smith for opt in opts[1:]: 33cda0060aSMatthew Knepley name = opt.split('=')[0] 34ccb279e1SMatthew Knepley if name.find('_') >= 0: 35ccb279e1SMatthew Knepley exception = False 36f3fbd535SBarry Smith for exc in ['superlu_dist', 'PETSC_ARCH', 'PETSC_DIR', 'CXX_CXXFLAGS', 'LD_SHARED', 'CC_LINKER_FLAGS', 'CXX_LINKER_FLAGS', 'FC_LINKER_FLAGS', 'AR_FLAGS', 'C_VERSION', 'CXX_VERSION', 'FC_VERSION', 'size_t', 'MPI_Comm','MPI_Fint']: 37ccb279e1SMatthew Knepley if name.find(exc) >= 0: 38ccb279e1SMatthew Knepley exception = True 39ccb279e1SMatthew Knepley if not exception: 40ccb279e1SMatthew Knepley raise ValueError('The option '+name+' should probably be '+name.replace('_', '-')); 41ab610953SSatish Balay if opt.find('=') >=0: 42ab610953SSatish Balay optval = opt.split('=')[1] 43ab610953SSatish Balay if optval == 'ifneeded': 44ab610953SSatish Balay raise ValueError('The option '+opt+' should probably be '+opt.replace('ifneeded', '1')); 45ccb279e1SMatthew Knepley return 46ccb279e1SMatthew Knepley 4759e9bfd6SSatish Balaydef check_petsc_arch(opts): 48c43ea0feSSatish Balay # If PETSC_ARCH not specified - use script name (if not configure.py) 49b0b472b0SSatish Balay global petsc_arch 50c43ea0feSSatish Balay found = 0 5159e9bfd6SSatish Balay for name in opts: 52c43ea0feSSatish Balay if name.find('PETSC_ARCH=') >= 0: 53b0b472b0SSatish Balay petsc_arch=name.split('=')[1] 54c43ea0feSSatish Balay found = 1 5559e9bfd6SSatish Balay break 5659e9bfd6SSatish Balay # If not yet specified - use the filename of script 57c43ea0feSSatish Balay if not found: 5859e9bfd6SSatish Balay filename = os.path.basename(sys.argv[0]) 59*e68ebbecSBarry Smith if not filename.startswith('configure') and not filename.startswith('reconfigure') and not filename.startswith('setup'): 60b0b472b0SSatish Balay petsc_arch=os.path.splitext(os.path.basename(sys.argv[0]))[0] 61b0b472b0SSatish Balay useName = 'PETSC_ARCH='+petsc_arch 6259e9bfd6SSatish Balay opts.append(useName) 631937db7aSSatish Balay return 0 644b8aa89bSBarry Smith 651921852fSSatish Balaydef chkwinf90(): 666a8f6897SSatish Balay for arg in sys.argv: 671921852fSSatish Balay if (arg.find('win32fe') >= 0 and (arg.find('f90') >=0 or arg.find('ifort') >=0)): 686a8f6897SSatish Balay return 1 696a8f6897SSatish Balay return 0 706a8f6897SSatish Balay 716a8f6897SSatish Balaydef chkcygwinlink(): 721921852fSSatish Balay if os.path.exists('/usr/bin/cygcheck.exe') and os.path.exists('/usr/bin/link.exe') and chkwinf90(): 736a8f6897SSatish Balay if '--ignore-cygwin-link' in sys.argv: return 0 746a8f6897SSatish Balay print '===============================================================================' 751921852fSSatish Balay print ' *** Cygwin /usr/bin/link detected! Compiles with CVF/Intel f90 can break! **' 766a8f6897SSatish Balay print ' *** To workarround do: "mv /usr/bin/link.exe /usr/bin/link-cygwin.exe" **' 776a8f6897SSatish Balay print ' *** Or to ignore this check, use configure option: --ignore-cygwin-link **' 786a8f6897SSatish Balay print '===============================================================================' 796a8f6897SSatish Balay sys.exit(3) 806a8f6897SSatish Balay return 0 816a8f6897SSatish Balay 8285ef4d1eSSatish Balaydef chkbrokencygwin(): 839dabcff0SSatish Balay if os.path.exists('/usr/bin/cygcheck.exe'): 849dabcff0SSatish Balay buf = os.popen('/usr/bin/cygcheck.exe -c cygwin').read() 859dabcff0SSatish Balay if buf.find('1.5.11-1') > -1: 86a0022257SSatish Balay print '===============================================================================' 87e2e64c6bSBarry Smith print ' *** cygwin-1.5.11-1 detected. ./configure fails with this version ***' 881937db7aSSatish Balay print ' *** Please upgrade to cygwin-1.5.12-1 or newer version. This can ***' 891937db7aSSatish Balay print ' *** be done by running cygwin-setup, selecting "next" all the way.***' 90a0022257SSatish Balay print '===============================================================================' 911937db7aSSatish Balay sys.exit(3) 929dabcff0SSatish Balay return 0 939dabcff0SSatish Balay 9485ef4d1eSSatish Balaydef chkusingwindowspython(): 951937db7aSSatish Balay if os.path.exists('/usr/bin/cygcheck.exe') and sys.platform != 'cygwin': 96a0022257SSatish Balay print '===============================================================================' 97e2e64c6bSBarry Smith print ' *** Non-cygwin python detected. Please rerun ./configure **' 98a0022257SSatish Balay print ' *** with cygwin-python. ***' 99a0022257SSatish Balay print '===============================================================================' 1001937db7aSSatish Balay sys.exit(3) 10185ef4d1eSSatish Balay return 0 10285ef4d1eSSatish Balay 10385ef4d1eSSatish Balaydef chkcygwinpythonver(): 10471384062SSatish Balay if os.path.exists('/usr/bin/cygcheck.exe'): 10571384062SSatish Balay buf = os.popen('/usr/bin/cygcheck.exe -c python').read() 106c4b7e894SSatish Balay if (buf.find('2.4') > -1) or (buf.find('2.5') > -1) or (buf.find('2.6') > -1): 1071937db7aSSatish Balay sys.argv.append('--useThreads=0') 1081937db7aSSatish Balay extraLogs.append('''\ 109a0022257SSatish Balay=============================================================================== 110a0022257SSatish Balay** Cygwin-python-2.4/2.5/2.6 detected. Threads do not work correctly with this 111e2e64c6bSBarry Smith** version. Disabling thread usage for this run of ./configure ******* 112a0022257SSatish Balay===============================================================================''') 11371384062SSatish Balay return 0 11471384062SSatish Balay 1151937db7aSSatish Balaydef chkrhl9(): 1161937db7aSSatish Balay if os.path.exists('/etc/redhat-release'): 117836c2c52SSatish Balay try: 118594eb360SSatish Balay file = open('/etc/redhat-release','r') 119836c2c52SSatish Balay buf = file.read() 120836c2c52SSatish Balay file.close() 121836c2c52SSatish Balay except: 122836c2c52SSatish Balay # can't read file - assume dangerous RHL9 1231937db7aSSatish Balay buf = 'Shrike' 124836c2c52SSatish Balay if buf.find('Shrike') > -1: 1251937db7aSSatish Balay sys.argv.append('--useThreads=0') 1261937db7aSSatish Balay extraLogs.append('''\ 127a0022257SSatish Balay============================================================================== 1281937db7aSSatish Balay *** RHL9 detected. Threads do not work correctly with this distribution *** 129e2e64c6bSBarry Smith ****** Disabling thread usage for this run of ./configure ********* 130a0022257SSatish Balay===============================================================================''') 131836c2c52SSatish Balay return 0 132836c2c52SSatish Balay 133da58527dSSatish Balaydef check_broken_configure_log_links(): 134da58527dSSatish Balay '''Sometime symlinks can get broken if the original files are deleted. Delete such broken links''' 135da58527dSSatish Balay import os 136da58527dSSatish Balay for logfile in ['configure.log','configure.log.bkp']: 137da58527dSSatish Balay if os.path.islink(logfile) and not os.path.isfile(logfile): os.remove(logfile) 138da58527dSSatish Balay return 139da58527dSSatish Balay 140da1d79b4SSatish Balaydef move_configure_log(framework): 141da1d79b4SSatish Balay '''Move configure.log to PETSC_ARCH/conf - and update configure.log.bkp in both locations appropriately''' 142b0b472b0SSatish Balay global petsc_arch 143b0b472b0SSatish Balay 144b0b472b0SSatish Balay if hasattr(framework,'arch'): petsc_arch = framework.arch 145b0b472b0SSatish Balay if hasattr(framework,'logName'): curr_file = framework.logName 146b0b472b0SSatish Balay else: curr_file = 'configure.log' 147b0b472b0SSatish Balay 148b0b472b0SSatish Balay if petsc_arch: 149da1d79b4SSatish Balay import shutil 150da1d79b4SSatish Balay import os 151b0b472b0SSatish Balay 152b0b472b0SSatish Balay # Just in case - confdir is not created 153b0b472b0SSatish Balay conf_dir = os.path.join(petsc_arch,'conf') 154b0b472b0SSatish Balay if not os.path.isdir(petsc_arch): os.mkdir(petsc_arch) 155b0b472b0SSatish Balay if not os.path.isdir(conf_dir): os.mkdir(conf_dir) 156b0b472b0SSatish Balay 157da1d79b4SSatish Balay curr_bkp = curr_file + '.bkp' 158b0b472b0SSatish Balay new_file = os.path.join(conf_dir,curr_file) 159da1d79b4SSatish Balay new_bkp = new_file + '.bkp' 160da1d79b4SSatish Balay 161da1d79b4SSatish Balay # Keep backup in $PETSC_ARCH/conf location 162da1d79b4SSatish Balay if os.path.isfile(new_bkp): os.remove(new_bkp) 163da1d79b4SSatish Balay if os.path.isfile(new_file): os.rename(new_file,new_bkp) 1649e50940cSSatish Balay if os.path.isfile(curr_file): 1659e50940cSSatish Balay shutil.copyfile(curr_file,new_file) 1669e50940cSSatish Balay os.remove(curr_file) 167da58527dSSatish Balay if os.path.isfile(new_file): os.symlink(new_file,curr_file) 168da1d79b4SSatish Balay # If the old bkp is using the same PETSC_ARCH/conf - then update bkp link 169da1d79b4SSatish Balay if os.path.realpath(curr_bkp) == os.path.realpath(new_file): 170da58527dSSatish Balay if os.path.isfile(curr_bkp): os.remove(curr_bkp) 171da58527dSSatish Balay if os.path.isfile(new_bkp): os.symlink(new_bkp,curr_bkp) 172da1d79b4SSatish Balay return 173da1d79b4SSatish Balay 1745d5a5a7bSMatthew Knepleydef petsc_configure(configure_options): 175a0022257SSatish Balay print '===============================================================================' 17659e9bfd6SSatish Balay print ' Configuring PETSc to compile on your system ' 177a0022257SSatish Balay print '===============================================================================' 17859e9bfd6SSatish Balay 179a258c2c4SMatthew G Knepley try: 180c43ea0feSSatish Balay # Command line arguments take precedence (but don't destroy argv[0]) 181c43ea0feSSatish Balay sys.argv = sys.argv[:1] + configure_options + sys.argv[1:] 182ccb279e1SMatthew Knepley check_for_option_mistakes(sys.argv) 183a258c2c4SMatthew G Knepley except (TypeError, ValueError), e: 184a258c2c4SMatthew G Knepley emsg = str(e) 185a258c2c4SMatthew G Knepley if not emsg.endswith('\n'): emsg = emsg+'\n' 186a258c2c4SMatthew G Knepley msg ='*******************************************************************************\n'\ 187a258c2c4SMatthew G Knepley +' ERROR in COMMAND LINE ARGUMENT to ./configure \n' \ 188a258c2c4SMatthew G Knepley +'-------------------------------------------------------------------------------\n' \ 189a258c2c4SMatthew G Knepley +emsg+'*******************************************************************************\n' 190a258c2c4SMatthew G Knepley sys.exit(msg) 19159e9bfd6SSatish Balay # check PETSC_ARCH 19259e9bfd6SSatish Balay check_petsc_arch(sys.argv) 193da58527dSSatish Balay check_broken_configure_log_links() 1945fb2c094SBarry Smith 195c22cdea9SBarry Smith # support a few standard configure option types 196ed6a7445SBarry Smith for l in range(0,len(sys.argv)): 197c22cdea9SBarry Smith name = sys.argv[l] 198637cc2ebSSatish Balay if name.find('enable-') >= 0: 199193cd51eSMatthew Knepley if name.find('=') == -1: 200193cd51eSMatthew Knepley sys.argv[l] = name.replace('enable-','with-')+'=1' 201193cd51eSMatthew Knepley else: 202193cd51eSMatthew Knepley head, tail = name.split('=', 1) 203193cd51eSMatthew Knepley sys.argv[l] = head.replace('enable-','with-')+'='+tail 204637cc2ebSSatish Balay if name.find('disable-') >= 0: 205193cd51eSMatthew Knepley if name.find('=') == -1: 206193cd51eSMatthew Knepley sys.argv[l] = name.replace('disable-','with-')+'=0' 207193cd51eSMatthew Knepley else: 208193cd51eSMatthew Knepley head, tail = name.split('=', 1) 209193cd51eSMatthew Knepley if tail == '1': tail = '0' 210193cd51eSMatthew Knepley sys.argv[l] = head.replace('disable-','with-')+'='+tail 211637cc2ebSSatish Balay if name.find('without-') >= 0: 212193cd51eSMatthew Knepley if name.find('=') == -1: 213193cd51eSMatthew Knepley sys.argv[l] = name.replace('without-','with-')+'=0' 214193cd51eSMatthew Knepley else: 215193cd51eSMatthew Knepley head, tail = name.split('=', 1) 216193cd51eSMatthew Knepley if tail == '1': tail = '0' 217193cd51eSMatthew Knepley sys.argv[l] = head.replace('without-','with-')+'='+tail 218adc3e427SMatthew Knepley 2199dabcff0SSatish Balay # Check for broken cygwin 2201937db7aSSatish Balay chkbrokencygwin() 221d65f3bddSMatthew Knepley # Disable threads on RHL9 2221937db7aSSatish Balay chkrhl9() 22385ef4d1eSSatish Balay # Make sure cygwin-python is used on windows 2241937db7aSSatish Balay chkusingwindowspython() 22585ef4d1eSSatish Balay # Threads don't work for cygwin & python-2.4, 2.5 etc.. 2261937db7aSSatish Balay chkcygwinpythonver() 2276a8f6897SSatish Balay chkcygwinlink() 2289dabcff0SSatish Balay 22987282423SMatthew Knepley # Should be run from the toplevel 230dbca6d9dSSatish Balay configDir = os.path.abspath('config') 231f8833479SBarry Smith bsDir = os.path.join(configDir, 'BuildSystem') 232f8833479SBarry Smith if not os.path.isdir(configDir): 2335d5a5a7bSMatthew Knepley raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.')) 23487282423SMatthew Knepley if not os.path.isdir(bsDir): 235a0022257SSatish Balay print '===============================================================================' 236dbca6d9dSSatish Balay print '''++ Could not locate BuildSystem in %s.''' % configDir 2374564aff7SMatthew Knepley print '''++ Downloading it using "hg clone http://hg.mcs.anl.gov/petsc/BuildSystem %s"''' % bsDir 238a0022257SSatish Balay print '===============================================================================' 2394564aff7SMatthew Knepley (status,output) = commands.getstatusoutput('hg clone http://petsc.cs.iit.edu/petsc/BuildSystem '+ bsDir) 2407d7624c9SBarry Smith if status: 2417d7624c9SBarry Smith if output.find('ommand not found') >= 0: 242a0022257SSatish Balay print '===============================================================================' 243a0022257SSatish Balay print '''** Unable to locate hg (Mercurial) to download BuildSystem; make sure hg is''' 244a0022257SSatish Balay print '''** in your path or manually copy BuildSystem to $PETSC_DIR/config/BuildSystem''' 245a0022257SSatish Balay print '''** from a machine where you do have hg installed and can clone BuildSystem. ''' 246a0022257SSatish Balay print '===============================================================================' 2477d7624c9SBarry Smith elif output.find('Cannot resolve host') >= 0: 248a0022257SSatish Balay print '===============================================================================' 249d688700cSSatish Balay print '''** Unable to download BuildSystem. You must be off the network.''' 250e2e64c6bSBarry Smith print '''** Connect to the internet and run ./configure again.''' 251a0022257SSatish Balay print '===============================================================================' 2527d7624c9SBarry Smith else: 253a0022257SSatish Balay print '===============================================================================' 254d688700cSSatish Balay print '''** Unable to download BuildSystem. Please send this message to petsc-maint@mcs.anl.gov''' 255a0022257SSatish Balay print '===============================================================================' 2567d7624c9SBarry Smith print output 25787282423SMatthew Knepley sys.exit(3) 2584f8a5b45SBarry Smith 25987282423SMatthew Knepley sys.path.insert(0, bsDir) 260f8833479SBarry Smith sys.path.insert(0, configDir) 261e69ef9dfSMatthew Knepley import config.base 2625d5a5a7bSMatthew Knepley import config.framework 263f56be888SMatthew Knepley import cPickle 2644f8a5b45SBarry Smith 2659dd2fdb1SMatthew Knepley framework = None 2669dd2fdb1SMatthew Knepley try: 2671a784507SMatthew Knepley framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=PETSc.compilerOptions']+sys.argv[1:], loadArgDB = 0) 268d65f3bddSMatthew Knepley framework.setup() 269d65f3bddSMatthew Knepley framework.logPrint('\n'.join(extraLogs)) 270f24f64feSBarry Smith framework.configure(out = sys.stdout) 271358ebc22SMatthew Knepley framework.storeSubstitutions(framework.argDB) 272f56be888SMatthew Knepley framework.argDB['configureCache'] = cPickle.dumps(framework) 2737cfd0b05SBarry Smith import PETSc.packages 2747cfd0b05SBarry Smith for i in framework.packages: 2757cfd0b05SBarry Smith if hasattr(i,'postProcess'): 2767cfd0b05SBarry Smith i.postProcess() 2777c939e48SSatish Balay framework.printSummary() 2787cfd0b05SBarry Smith framework.logClear() 279eefa2c0fSBarry Smith framework.closeLog() 2809e50940cSSatish Balay try: 281da1d79b4SSatish Balay move_configure_log(framework) 2829e50940cSSatish Balay except: 2839e50940cSSatish Balay # perhaps print an error about unable to shuffle logs? 2849e50940cSSatish Balay pass 285dd50d019SBarry Smith return 0 286e69ef9dfSMatthew Knepley except (RuntimeError, config.base.ConfigureSetupError), e: 2877d670a3cSBarry Smith emsg = str(e) 28842351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 289a0022257SSatish Balay msg ='*******************************************************************************\n'\ 290fe09c992SBarry Smith +' UNABLE to CONFIGURE with GIVEN OPTIONS (see configure.log for details):\n' \ 291a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 292a0022257SSatish Balay +emsg+'*******************************************************************************\n' 293e9f3bb17SBarry Smith se = '' 2949dd2fdb1SMatthew Knepley except (TypeError, ValueError), e: 2957d670a3cSBarry Smith emsg = str(e) 29642351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 297a0022257SSatish Balay msg ='*******************************************************************************\n'\ 298e2e64c6bSBarry Smith +' ERROR in COMMAND LINE ARGUMENT to ./configure \n' \ 299a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 300a0022257SSatish Balay +emsg+'*******************************************************************************\n' 3011a02243aSBarry Smith se = '' 30296dc2fe8SMatthew Knepley except ImportError, e : 3037d670a3cSBarry Smith emsg = str(e) 30442351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 305a0022257SSatish Balay msg ='*******************************************************************************\n'\ 306e2e64c6bSBarry Smith +' UNABLE to FIND MODULE for ./configure \n' \ 307a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 308a0022257SSatish Balay +emsg+'*******************************************************************************\n' 30996dc2fe8SMatthew Knepley se = '' 31001def6f0SMatthew Knepley except OSError, e : 31101def6f0SMatthew Knepley emsg = str(e) 31201def6f0SMatthew Knepley if not emsg.endswith('\n'): emsg = emsg+'\n' 313a0022257SSatish Balay msg ='*******************************************************************************\n'\ 314e2e64c6bSBarry Smith +' UNABLE to EXECUTE BINARIES for ./configure \n' \ 315a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 316a0022257SSatish Balay +emsg+'*******************************************************************************\n' 31701def6f0SMatthew Knepley se = '' 318d7d3c4beSMatthew Knepley except SystemExit, e: 319d7d3c4beSMatthew Knepley if e.code is None or e.code == 0: 320d7d3c4beSMatthew Knepley return 321a0022257SSatish Balay msg ='*******************************************************************************\n'\ 322b1dada7fSMatthew Knepley +' CONFIGURATION FAILURE (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \ 323a0022257SSatish Balay +'*******************************************************************************\n' 324d7d3c4beSMatthew Knepley se = str(e) 325e9f3bb17SBarry Smith except Exception, e: 326a0022257SSatish Balay msg ='*******************************************************************************\n'\ 327fe09c992SBarry Smith +' CONFIGURATION CRASH (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \ 328a0022257SSatish Balay +'*******************************************************************************\n' 329e9f3bb17SBarry Smith se = str(e) 330e9f3bb17SBarry Smith 331e9f3bb17SBarry Smith print msg 3329dd2fdb1SMatthew Knepley if not framework is None: 3339dd2fdb1SMatthew Knepley framework.logClear() 334e9f3bb17SBarry Smith if hasattr(framework, 'log'): 335f6614063SBarry Smith import traceback 336b1dada7fSMatthew Knepley try: 337f24f64feSBarry Smith framework.log.write(msg+se) 338f24f64feSBarry Smith traceback.print_tb(sys.exc_info()[2], file = framework.log) 339fd753abcSMatthew G Knepley framework.log.close() 340da1d79b4SSatish Balay move_configure_log(framework) 341b1dada7fSMatthew Knepley except: 342b1dada7fSMatthew Knepley pass 343e9f3bb17SBarry Smith sys.exit(1) 3445a74f024SMatthew Knepley else: 3455a74f024SMatthew Knepley print se 3465a74f024SMatthew Knepley import traceback 3475a74f024SMatthew Knepley traceback.print_tb(sys.exc_info()[2]) 3485d5a5a7bSMatthew Knepley 3495d5a5a7bSMatthew Knepleyif __name__ == '__main__': 350a030c540SBarry Smith petsc_configure([]) 351759acf64SBarry Smith 352