1#!/usr/bin/env python 2from __future__ import print_function 3import os, sys 4 5extraLogs = [] 6petsc_arch = '' 7banner_length = 93 8 9# Use en_US as language so that BuildSystem parses compiler messages in english 10def fixLang(lang): 11 if lang in os.environ and os.environ[lang] != '': 12 lv = os.environ[lang] 13 enc = '' 14 try: lv,enc = lv.split('.') 15 except: pass 16 if lv not in ['en_US','C']: lv = 'en_US' 17 if enc: lv = lv+'.'+enc 18 os.environ[lang] = lv 19 20fixLang('LC_LOCAL') 21fixLang('LANG') 22 23 24def check_for_option_mistakes(opts): 25 for opt in opts[1:]: 26 name = opt.split('=')[0] 27 if name.find(' ') >= 0: 28 raise ValueError('The option "'+name+'" has a space character in the name - this is likely incorrect usage.'); 29 if name.find('_') >= 0: 30 exception = False 31 for exc in ['mkl_sparse', 'mkl_sparse_optimize', 'mkl_cpardiso', 'mkl_pardiso', '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','int64_t']: 32 if name.find(exc) >= 0: 33 exception = True 34 if not exception: 35 raise ValueError('The option '+name+' should probably be '+name.replace('_', '-')); 36 if opt.find('=') >=0: 37 optval = opt.split('=')[1] 38 if optval == 'ifneeded': 39 raise ValueError('The option '+opt+' should probably be '+opt.replace('ifneeded', '1')); 40 for exc in ['mkl_sparse', 'mkl_sparse_optimize', 'mkl_cpardiso', 'mkl_pardiso', 'superlu_dist']: 41 if name.find(exc.replace('_','-')) > -1: 42 raise ValueError('The option '+opt+' should be '+opt.replace(exc.replace('_','-'),exc)); 43 return 44 45def check_for_unsupported_combinations(opts): 46 if '--with-precision=single' in opts and '--with-clanguage=cxx' in opts and '--with-scalar-type=complex' in opts: 47 sys.exit(ValueError('PETSc does not support single precision complex with C++ clanguage, run with --with-clanguage=c')) 48 49def check_for_option_changed(opts): 50# Document changes in command line options here. 51 optMap = [('with-64bit-indices','with-64-bit-indices'), 52 ('with-mpi-exec','with-mpiexec'), 53 ('c-blas-lapack','f2cblaslapack'), 54 ('cholmod','suitesparse'), 55 ('umfpack','suitesparse'), 56 ('matlabengine','matlab-engine'), 57 ('sundials','sundials2'), 58 ('f-blas-lapack','fblaslapack'), 59 ('with-packages-dir','with-packages-download-dir'), 60 ('with-external-packages-dir','with-packages-build-dir'), 61 ('package-dirs','with-packages-search-path'), 62 ('download-petsc4py-python','with-python-exec'), 63 ('search-dirs','with-executables-search-path')] 64 for opt in opts[1:]: 65 optname = opt.split('=')[0].strip('-') 66 for oldname,newname in optMap: 67 if optname.find(oldname) >=0 and not optname.find(newname) >=0: 68 raise ValueError('The option '+opt+' should probably be '+opt.replace(oldname,newname)) 69 return 70 71def check_petsc_arch(opts): 72 # If PETSC_ARCH not specified - use script name (if not configure.py) 73 global petsc_arch 74 found = 0 75 for name in opts: 76 if name.find('PETSC_ARCH=') >= 0: 77 petsc_arch=name.split('=')[1] 78 found = 1 79 break 80 # If not yet specified - use the filename of script 81 if not found: 82 filename = os.path.basename(sys.argv[0]) 83 if not filename.startswith('configure') and not filename.startswith('reconfigure') and not filename.startswith('setup'): 84 petsc_arch=os.path.splitext(os.path.basename(sys.argv[0]))[0] 85 useName = 'PETSC_ARCH='+petsc_arch 86 opts.append(useName) 87 return 0 88 89def chkenable(): 90 #Replace all 'enable-'/'disable-' with 'with-'=0/1/tail 91 #enable-fortran is a special case, the resulting --with-fortran is ambiguous. 92 #Would it mean --with-fc= 93 en_dash = u'\N{EN DASH}' 94 no_break_space = u'\N{NO-BREAK SPACE}' 95 if sys.version_info < (3, 0): 96 en_dash = en_dash.encode('utf-8') 97 no_break_space = no_break_space.encode('utf-8') 98 99 for l in range(0,len(sys.argv)): 100 name = sys.argv[l] 101 if name.find(no_break_space) >= 0: 102 sys.exit(ValueError('Unicode NO-BREAK SPACE char found in arguments! Please rerun configure using regular space chars: %s' % [name])) 103 name = name.replace(en_dash,'-') 104 if name.lstrip('-').startswith('enable-cxx'): 105 if name.find('=') == -1: 106 name = name.replace('enable-cxx','with-clanguage=C++',1) 107 else: 108 head, tail = name.split('=', 1) 109 if tail=='0': 110 name = head.replace('enable-cxx','with-clanguage=C',1) 111 else: 112 name = head.replace('enable-cxx','with-clanguage=C++',1) 113 sys.argv[l] = name 114 continue 115 if name.lstrip('-').startswith('disable-cxx'): 116 if name.find('=') == -1: 117 name = name.replace('disable-cxx','with-clanguage=C',1) 118 else: 119 head, tail = name.split('=', 1) 120 if tail == '0': 121 name = head.replace('disable-cxx','with-clanguage=C++',1) 122 else: 123 name = head.replace('disable-cxx','with-clanguage=C',1) 124 sys.argv[l] = name 125 continue 126 127 if name.lstrip('-').startswith('enable-'): 128 if name.find('=') == -1: 129 name = name.replace('enable-','with-',1)+'=1' 130 else: 131 head, tail = name.split('=', 1) 132 name = head.replace('enable-','with-',1)+'='+tail 133 if name.lstrip('-').startswith('disable-'): 134 if name.find('=') == -1: 135 name = name.replace('disable-','with-',1)+'=0' 136 else: 137 head, tail = name.split('=', 1) 138 if tail == '1': tail = '0' 139 name = head.replace('disable-','with-',1)+'='+tail 140 if name.lstrip('-').startswith('without-'): 141 if name.find('=') == -1: 142 name = name.replace('without-','with-',1)+'=0' 143 else: 144 head, tail = name.split('=', 1) 145 if tail == '1': tail = '0' 146 name = head.replace('without-','with-',1)+'='+tail 147 sys.argv[l] = name 148 149def chksynonyms(): 150 #replace common configure options with ones that PETSc BuildSystem recognizes 151 simplereplacements = {'F77' : 'FC', 'F90' : 'FC'} 152 for l in range(0,len(sys.argv)): 153 name = sys.argv[l] 154 155 name = name.replace('download-petsc4py','with-petsc4py') 156 name = name.replace('with-openmpi','with-mpi') 157 name = name.replace('with-mpich','with-mpi') 158 name = name.replace('with-blas-lapack','with-blaslapack') 159 name = name.replace('with-cuda-gencodearch','with-cuda-arch') 160 name = name.replace('download-hdf5-fortran-bindings','with-hdf5-fortran-bindings') 161 162 if name.find('with-debug=') >= 0 or name.endswith('with-debug'): 163 if name.find('=') == -1: 164 name = name.replace('with-debug','with-debugging')+'=1' 165 else: 166 head, tail = name.split('=', 1) 167 name = head.replace('with-debug','with-debugging')+'='+tail 168 169 if name.find('with-shared=') >= 0 or name.endswith('with-shared'): 170 if name.find('=') == -1: 171 name = name.replace('with-shared','with-shared-libraries')+'=1' 172 else: 173 head, tail = name.split('=', 1) 174 name = head.replace('with-shared','with-shared-libraries')+'='+tail 175 176 if name.find('with-index-size=') >=0: 177 head,tail = name.split('=',1) 178 if int(tail)==32: 179 name = '--with-64-bit-indices=0' 180 elif int(tail)==64: 181 name = '--with-64-bit-indices=1' 182 else: 183 raise RuntimeError('--with-index-size= must be 32 or 64') 184 185 if name.find('with-precision=') >=0: 186 head,tail = name.split('=',1) 187 if tail.find('quad')>=0: 188 name='--with-precision=__float128' 189 190 for i,j in simplereplacements.items(): 191 if name.find(i+'=') >= 0: 192 name = name.replace(i+'=',j+'=') 193 elif name.find('with-'+i.lower()+'=') >= 0: 194 name = name.replace(i.lower()+'=',j.lower()+'=') 195 196 # restore 'sys.argv[l]' from the intermediate var 'name' 197 sys.argv[l] = name 198 199def chkwincompilerusinglink(): 200 for arg in sys.argv: 201 if (arg.find('win32fe') >= 0 and (arg.find('f90') >=0 or arg.find('ifort') >=0 or arg.find('icl') >=0)): 202 return 1 203 return 0 204 205def chkdosfiles(): 206 # cygwin - but not a hg clone - so check one of files in bin dir 207 if b"\r\n" in open(os.path.join('lib','petsc','bin','petscmpiexec'),"rb").read(): 208 print('===============================================================================') 209 print(' *** Scripts are in DOS mode. Was winzip used to extract petsc sources? ****') 210 print(' *** Please restart with a fresh tarball and use "tar -xzf petsc.tar.gz" ****') 211 print('===============================================================================') 212 sys.exit(3) 213 return 214 215def chkcygwinlink(): 216 if os.path.exists('/usr/bin/cygcheck.exe') and os.path.exists('/usr/bin/link.exe') and chkwincompilerusinglink(): 217 if '--ignore-cygwin-link' in sys.argv: return 0 218 print('===============================================================================') 219 print(' *** Cygwin /usr/bin/link detected! Compiles with Intel icl/ifort can break! **') 220 print(' *** To workaround do: "mv /usr/bin/link.exe /usr/bin/link-cygwin.exe" **') 221 print(' *** Or to ignore this check, use configure option: --ignore-cygwin-link. But compiles can fail. **') 222 print('===============================================================================') 223 sys.exit(3) 224 return 0 225 226def chkbrokencygwin(): 227 if os.path.exists('/usr/bin/cygcheck.exe'): 228 buf = os.popen('/usr/bin/cygcheck.exe -c cygwin').read() 229 if buf.find('1.5.11-1') > -1: 230 print('===============================================================================') 231 print(' *** cygwin-1.5.11-1 detected. ./configure fails with this version ***') 232 print(' *** Please upgrade to cygwin-1.5.12-1 or newer version. This can ***') 233 print(' *** be done by running cygwin-setup, selecting "next" all the way.***') 234 print('===============================================================================') 235 sys.exit(3) 236 return 0 237 238def chkusingwindowspython(): 239 if sys.platform == 'win32': 240 print('===============================================================================') 241 print(' *** Windows python detected. Please rerun ./configure with cygwin-python. ***') 242 print('===============================================================================') 243 sys.exit(3) 244 return 0 245 246def chkcygwinpython(): 247 if sys.platform == 'cygwin' : 248 import platform 249 import re 250 r=re.compile("([0-9]+).([0-9]+).([0-9]+)") 251 m=r.match(platform.release()) 252 major=int(m.group(1)) 253 minor=int(m.group(2)) 254 subminor=int(m.group(3)) 255 if ((major < 1) or (major == 1 and minor < 7) or (major == 1 and minor == 7 and subminor < 34)): 256 sys.argv.append('--useThreads=0') 257 extraLogs.append('''\ 258=============================================================================== 259** Cygwin version is older than 1.7.34. Python threads do not work correctly. *** 260** Disabling thread usage for this run of ./configure ******* 261===============================================================================''') 262 return 0 263 264def chkcygwinwindowscompilers(): 265 '''Adds win32fe for Microsoft/Intel compilers''' 266 if os.path.exists('/usr/bin/cygcheck.exe'): 267 for l in range(1,len(sys.argv)): 268 option = sys.argv[l] 269 for i in ['cl','icl','ifort']: 270 if option.startswith(i): 271 sys.argv[l] = 'win32fe '+option 272 break 273 return 0 274 275def chkrhl9(): 276 if os.path.exists('/etc/redhat-release'): 277 try: 278 file = open('/etc/redhat-release','r') 279 buf = file.read() 280 file.close() 281 except: 282 # can't read file - assume dangerous RHL9 283 buf = 'Shrike' 284 if buf.find('Shrike') > -1: 285 sys.argv.append('--useThreads=0') 286 extraLogs.append('''\ 287============================================================================== 288 *** RHL9 detected. Threads do not work correctly with this distribution *** 289 ****** Disabling thread usage for this run of ./configure ********* 290===============================================================================''') 291 return 0 292 293def chktmpnoexec(): 294 if not hasattr(os,'ST_NOEXEC'): return # novermin 295 if 'TMPDIR' in os.environ: tmpDir = os.environ['TMPDIR'] 296 else: tmpDir = '/tmp' 297 if os.statvfs(tmpDir).f_flag & os.ST_NOEXEC: # novermin 298 if os.statvfs(os.path.abspath('.')).f_flag & os.ST_NOEXEC: # novermin 299 print('************************************************************************') 300 print('* TMPDIR '+tmpDir+' has noexec attribute. Same with '+os.path.abspath('.')+' where petsc is built.') 301 print('* Suggest building PETSc in a location without this restriction!') 302 print('* Alternatively, set env variable TMPDIR to a location that is not restricted to run binaries.') 303 print('************************************************************************') 304 sys.exit(4) 305 else: 306 newTmp = os.path.abspath('tmp-petsc') 307 print('************************************************************************') 308 print('* TMPDIR '+tmpDir+' has noexec attribute. Using '+newTmp+' instead.') 309 print('************************************************************************') 310 if not os.path.isdir(newTmp): os.mkdir(os.path.abspath(newTmp)) 311 os.environ['TMPDIR'] = newTmp 312 return 313 314def check_cray_modules(): 315 import script 316 '''For Cray systems check if the cc, CC, ftn compiler suite modules have been set''' 317 cray = os.getenv('CRAY_SITE_LIST_DIR') 318 if not cray: return 319 cray = os.getenv('CRAYPE_DIR') 320 if not cray: 321 print('************************************************************************') 322 print('* You are on a Cray system but no programming environments have been loaded') 323 print('* Perhaps you need:') 324 print('* module load intel ; module load PrgEnv-intel') 325 print('* or module load PrgEnv-cray') 326 print('* or module load PrgEnv-gnu') 327 print('* See https://petsc.org/release/install/install/#installing-on-large-scale-doe-systems') 328 print('************************************************************************') 329 sys.exit(4) 330 331def check_broken_configure_log_links(): 332 '''Sometime symlinks can get broken if the original files are deleted. Delete such broken links''' 333 import os 334 for logfile in ['configure.log','configure.log.bkp']: 335 if os.path.islink(logfile) and not os.path.isfile(logfile): os.remove(logfile) 336 return 337 338def move_configure_log(framework): 339 '''Move configure.log to PETSC_ARCH/lib/petsc/conf - and update configure.log.bkp in both locations appropriately''' 340 global petsc_arch 341 342 if hasattr(framework,'arch'): petsc_arch = framework.arch 343 if hasattr(framework,'logName'): curr_file = framework.logName 344 else: curr_file = 'configure.log' 345 346 if petsc_arch: 347 import shutil 348 import os 349 350 # Just in case - confdir is not created 351 lib_dir = os.path.join(petsc_arch,'lib') 352 petsc_dir = os.path.join(petsc_arch,'lib','petsc') 353 conf_dir = os.path.join(petsc_arch,'lib','petsc','conf') 354 if not os.path.isdir(petsc_arch): os.mkdir(petsc_arch) 355 if not os.path.isdir(lib_dir): os.mkdir(lib_dir) 356 if not os.path.isdir(petsc_dir): os.mkdir(petsc_dir) 357 if not os.path.isdir(conf_dir): os.mkdir(conf_dir) 358 359 curr_bkp = curr_file + '.bkp' 360 new_file = os.path.join(conf_dir,curr_file) 361 new_bkp = new_file + '.bkp' 362 363 # Keep backup in $PETSC_ARCH/lib/petsc/conf location 364 if os.path.isfile(new_bkp): os.remove(new_bkp) 365 if os.path.isfile(new_file): os.rename(new_file,new_bkp) 366 if os.path.isfile(curr_file): 367 shutil.copyfile(curr_file,new_file) 368 os.remove(curr_file) 369 if os.path.isfile(new_file): os.symlink(new_file,curr_file) 370 # If the old bkp is using the same PETSC_ARCH/lib/petsc/conf - then update bkp link 371 if os.path.realpath(curr_bkp) == os.path.realpath(new_file): 372 if os.path.isfile(curr_bkp): os.remove(curr_bkp) 373 if os.path.isfile(new_bkp): os.symlink(new_bkp,curr_bkp) 374 return 375 376def print_final_timestamp(framework): 377 import time 378 framework.log.write(('='*80)+'\n') 379 framework.log.write('Finishing configure run at '+time.strftime('%a, %d %b %Y %H:%M:%S %z')+'\n') 380 framework.log.write(('='*80)+'\n') 381 return 382 383def petsc_configure(configure_options): 384 if 'PETSC_DIR' in os.environ: 385 petscdir = os.environ['PETSC_DIR'] 386 if petscdir.find(' ') > -1: 387 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') 388 if not os.path.isabs(petscdir): 389 raise RuntimeError('PETSC_DIR ("'+petscdir+'") is set as a relative path. It must be set as an absolute path.') 390 391 try: 392 sys.path.append(os.path.join(petscdir,'lib','petsc','bin')) 393 import petscnagupgrade 394 file = os.path.join(petscdir,'.nagged') 395 if not petscnagupgrade.naggedtoday(file): 396 petscnagupgrade.currentversion(petscdir) 397 except: 398 pass 399 banner_line = banner_length*'=' 400 print(banner_line) 401 print('Configuring PETSc to compile on your system'.center(banner_length)) 402 print(banner_line) 403 404 try: 405 # Command line arguments take precedence (but don't destroy argv[0]) 406 sys.argv = sys.argv[:1] + configure_options + sys.argv[1:] 407 check_for_option_mistakes(sys.argv) 408 check_for_option_changed(sys.argv) 409 except (TypeError, ValueError) as e: 410 emsg = str(e) 411 if not emsg.endswith('\n'): emsg = emsg+'\n' 412 banner_line = banner_length*'*' 413 msg = '\n'.join([ 414 banner_line, 415 'ERROR in COMMAND LINE ARGUMENT to ./configure'.center(banner_length), 416 banner_length*'-', 417 emsg, 418 banner_line, 419 '' # to add an additional newline at the end 420 ]) 421 sys.exit(msg) 422 # check PETSC_ARCH 423 check_for_unsupported_combinations(sys.argv) 424 check_petsc_arch(sys.argv) 425 check_broken_configure_log_links() 426 427 #rename '--enable-' to '--with-' 428 chkenable() 429 # support a few standard configure option types 430 chksynonyms() 431 # Check for broken cygwin 432 chkbrokencygwin() 433 # Disable threads on RHL9 434 chkrhl9() 435 # Make sure cygwin-python is used on windows 436 chkusingwindowspython() 437 # Threads don't work for cygwin & python... 438 chkcygwinpython() 439 chkcygwinlink() 440 chkdosfiles() 441 chkcygwinwindowscompilers() 442 chktmpnoexec() 443 444 for l in range(1,len(sys.argv)): 445 if sys.argv[l].startswith('--with-fc=') and sys.argv[l].endswith('nagfor'): 446 # need a way to save this value and later CC so that petscnagfor may use them 447 name = sys.argv[l].split('=')[1] 448 sys.argv[l] = '--with-fc='+os.path.join(os.path.abspath('.'),'lib','petsc','bin','petscnagfor') 449 break 450 451 452 # Should be run from the toplevel 453 configDir = os.path.abspath('config') 454 bsDir = os.path.join(configDir, 'BuildSystem') 455 if not os.path.isdir(configDir): 456 raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.')) 457 sys.path.insert(0, bsDir) 458 sys.path.insert(0, configDir) 459 import config.base 460 import config.framework 461 import pickle 462 import traceback 463 464 # Check Cray without modules 465 check_cray_modules() 466 467 tbo = None 468 framework = None 469 try: 470 framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=config.compilerOptions']+sys.argv[1:], loadArgDB = 0) 471 framework.setup() 472 framework.logPrint('\n'.join(extraLogs)) 473 framework.configure(out = sys.stdout) 474 framework.storeSubstitutions(framework.argDB) 475 framework.argDB['configureCache'] = pickle.dumps(framework) 476 framework.printSummary() 477 framework.argDB.save(force = True) 478 framework.logClear() 479 print_final_timestamp(framework) 480 framework.closeLog() 481 try: 482 move_configure_log(framework) 483 except: 484 # perhaps print an error about unable to shuffle logs? 485 pass 486 return 0 487 except (RuntimeError, config.base.ConfigureSetupError) as e: 488 tbo = sys.exc_info()[2] 489 emsg = str(e) 490 if not emsg.endswith('\n'): emsg = emsg+'\n' 491 msg ='*******************************************************************************\n'\ 492 +' UNABLE to CONFIGURE with GIVEN OPTIONS (see configure.log for details):\n' \ 493 +'-------------------------------------------------------------------------------\n' \ 494 +emsg+'*******************************************************************************\n' 495 se = '' 496 except (TypeError, ValueError) as e: 497 # this exception is automatically deleted by Python so we need to save it to print below 498 tbo = sys.exc_info()[2] 499 emsg = str(e) 500 if not emsg.endswith('\n'): emsg = emsg+'\n' 501 msg ='*******************************************************************************\n'\ 502 +' TypeError or ValueError possibly related to ERROR in COMMAND LINE ARGUMENT while running ./configure \n' \ 503 +'-------------------------------------------------------------------------------\n' \ 504 +emsg+'*******************************************************************************\n' 505 se = '' 506 except ImportError as e : 507 # this exception is automatically deleted by Python so we need to save it to print below 508 tbo = sys.exc_info()[2] 509 emsg = str(e) 510 if not emsg.endswith('\n'): emsg = emsg+'\n' 511 msg ='*******************************************************************************\n'\ 512 +' ImportError while runing ./configure \n' \ 513 +'-------------------------------------------------------------------------------\n' \ 514 +emsg+'*******************************************************************************\n' 515 se = '' 516 except OSError as e : 517 tbo = sys.exc_info()[2] 518 emsg = str(e) 519 if not emsg.endswith('\n'): emsg = emsg+'\n' 520 msg ='*******************************************************************************\n'\ 521 +' OSError while running ./configure \n' \ 522 +'-------------------------------------------------------------------------------\n' \ 523 +emsg+'*******************************************************************************\n' 524 se = '' 525 except SystemExit as e: 526 tbo = sys.exc_info()[2] 527 if e.code is None or e.code == 0: 528 return 529 if e.code == 10: 530 sys.exit(10) 531 msg ='*******************************************************************************\n'\ 532 +' CONFIGURATION FAILURE (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \ 533 +'*******************************************************************************\n' 534 se = str(e) 535 except Exception as e: 536 tbo = sys.exc_info()[2] 537 msg ='*******************************************************************************\n'\ 538 +' CONFIGURATION CRASH (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \ 539 +'*******************************************************************************\n' 540 se = str(e) 541 542 print(msg) 543 if not framework is None: 544 framework.logClear() 545 if hasattr(framework, 'log'): 546 try: 547 if hasattr(framework,'compilerDefines'): 548 framework.log.write('**** Configure header '+framework.compilerDefines+' ****\n') 549 framework.outputHeader(framework.log) 550 if hasattr(framework,'compilerFixes'): 551 framework.log.write('**** C specific Configure header '+framework.compilerFixes+' ****\n') 552 framework.outputCHeader(framework.log) 553 except Exception as e: 554 framework.log.write('Problem writing headers to log: '+str(e)) 555 try: 556 framework.log.write(msg+se) 557 traceback.print_tb(tbo, file = framework.log) 558 print_final_timestamp(framework) 559 if hasattr(framework,'log'): framework.log.close() 560 move_configure_log(framework) 561 except Exception as e: 562 print('Error printing error message from exception or printing the traceback:'+str(e)) 563 traceback.print_tb(sys.exc_info()[2]) 564 sys.exit(1) 565 else: 566 print(se) 567 traceback.print_tb(tbo) 568 else: 569 print(se) 570 traceback.print_tb(tbo) 571 if hasattr(framework,'log'): framework.log.close() 572 573if __name__ == '__main__': 574 petsc_configure([]) 575