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