xref: /petsc/config/configure.py (revision 7d5fd1e4d9337468ad3f05b65b7facdcd2dfd2a4)
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 hasattr(name,'isprintable') and not name.isprintable():
104      sys.exit(ValueError('Non-printable characters or control characters found in arguments! Please rerun configure using only printable character arguments: %s' % [name]))
105    if name.lstrip('-').startswith('enable-cxx'):
106      if name.find('=') == -1:
107        name = name.replace('enable-cxx','with-clanguage=C++',1)
108      else:
109        head, tail = name.split('=', 1)
110        if tail=='0':
111          name = head.replace('enable-cxx','with-clanguage=C',1)
112        else:
113          name = head.replace('enable-cxx','with-clanguage=C++',1)
114      sys.argv[l] = name
115      continue
116    if name.lstrip('-').startswith('disable-cxx'):
117      if name.find('=') == -1:
118        name = name.replace('disable-cxx','with-clanguage=C',1)
119      else:
120        head, tail = name.split('=', 1)
121        if tail == '0':
122          name = head.replace('disable-cxx','with-clanguage=C++',1)
123        else:
124          name = head.replace('disable-cxx','with-clanguage=C',1)
125      sys.argv[l] = name
126      continue
127
128    if name.lstrip('-').startswith('enable-'):
129      if name.find('=') == -1:
130        name = name.replace('enable-','with-',1)+'=1'
131      else:
132        head, tail = name.split('=', 1)
133        name = head.replace('enable-','with-',1)+'='+tail
134    if name.lstrip('-').startswith('disable-'):
135      if name.find('=') == -1:
136        name = name.replace('disable-','with-',1)+'=0'
137      else:
138        head, tail = name.split('=', 1)
139        if tail == '1': tail = '0'
140        name = head.replace('disable-','with-',1)+'='+tail
141    if name.lstrip('-').startswith('without-'):
142      if name.find('=') == -1:
143        name = name.replace('without-','with-',1)+'=0'
144      else:
145        head, tail = name.split('=', 1)
146        if tail == '1': tail = '0'
147        name = head.replace('without-','with-',1)+'='+tail
148    sys.argv[l] = name
149
150def chksynonyms():
151  #replace common configure options with ones that PETSc BuildSystem recognizes
152  simplereplacements = {'F77' : 'FC', 'F90' : 'FC'}
153  for l in range(0,len(sys.argv)):
154    name = sys.argv[l]
155
156    name = name.replace('download-petsc4py','with-petsc4py')
157    name = name.replace('with-openmpi','with-mpi')
158    name = name.replace('with-mpich','with-mpi')
159    name = name.replace('with-blas-lapack','with-blaslapack')
160    name = name.replace('with-cuda-gencodearch','with-cuda-arch')
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  print('=============================================================================================')
400  print('                      Configuring PETSc to compile on your system                            ')
401  print('=============================================================================================')
402
403  try:
404    # Command line arguments take precedence (but don't destroy argv[0])
405    sys.argv = sys.argv[:1] + configure_options + sys.argv[1:]
406    check_for_option_mistakes(sys.argv)
407    check_for_option_changed(sys.argv)
408  except (TypeError, ValueError) as e:
409    emsg = str(e)
410    if not emsg.endswith('\n'): emsg = emsg+'\n'
411    msg ='*******************************************************************************\n'\
412    +'                ERROR in COMMAND LINE ARGUMENT to ./configure \n' \
413    +'-------------------------------------------------------------------------------\n'  \
414    +emsg+'*******************************************************************************\n'
415    sys.exit(msg)
416  # check PETSC_ARCH
417  check_for_unsupported_combinations(sys.argv)
418  check_petsc_arch(sys.argv)
419  check_broken_configure_log_links()
420
421  #rename '--enable-' to '--with-'
422  chkenable()
423  # support a few standard configure option types
424  chksynonyms()
425  # Check for broken cygwin
426  chkbrokencygwin()
427  # Disable threads on RHL9
428  chkrhl9()
429  # Make sure cygwin-python is used on windows
430  chkusingwindowspython()
431  # Threads don't work for cygwin & python...
432  chkcygwinpython()
433  chkcygwinlink()
434  chkdosfiles()
435  chkcygwinwindowscompilers()
436  chktmpnoexec()
437
438  for l in range(1,len(sys.argv)):
439    if sys.argv[l].startswith('--with-fc=') and sys.argv[l].endswith('nagfor'):
440      # need a way to save this value and later CC so that petscnagfor may use them
441      name = sys.argv[l].split('=')[1]
442      sys.argv[l] = '--with-fc='+os.path.join(os.path.abspath('.'),'lib','petsc','bin','petscnagfor')
443      break
444
445
446  # Should be run from the toplevel
447  configDir = os.path.abspath('config')
448  bsDir     = os.path.join(configDir, 'BuildSystem')
449  if not os.path.isdir(configDir):
450    raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.'))
451  sys.path.insert(0, bsDir)
452  sys.path.insert(0, configDir)
453  import config.base
454  import config.framework
455  import pickle
456  import traceback
457
458  # Check Cray without modules
459  check_cray_modules()
460
461  tbo = None
462  framework = None
463  try:
464    framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=config.compilerOptions']+sys.argv[1:], loadArgDB = 0)
465    framework.setup()
466    framework.logPrint('\n'.join(extraLogs))
467    framework.configure(out = sys.stdout)
468    framework.storeSubstitutions(framework.argDB)
469    framework.argDB['configureCache'] = pickle.dumps(framework)
470    framework.printSummary()
471    framework.argDB.save(force = True)
472    framework.logClear()
473    print_final_timestamp(framework)
474    framework.closeLog()
475    try:
476      move_configure_log(framework)
477    except:
478      # perhaps print an error about unable to shuffle logs?
479      pass
480    return 0
481  except (RuntimeError, config.base.ConfigureSetupError) as e:
482    tbo = sys.exc_info()[2]
483    emsg = str(e)
484    if not emsg.endswith('\n'): emsg = emsg+'\n'
485    msg ='*******************************************************************************\n'\
486    +'         UNABLE to CONFIGURE with GIVEN OPTIONS    (see configure.log for details):\n' \
487    +'-------------------------------------------------------------------------------\n'  \
488    +emsg+'*******************************************************************************\n'
489    se = ''
490  except (TypeError, ValueError) as e:
491    # this exception is automatically deleted by Python so we need to save it to print below
492    tbo = sys.exc_info()[2]
493    emsg = str(e)
494    if not emsg.endswith('\n'): emsg = emsg+'\n'
495    msg ='*******************************************************************************\n'\
496    +'    TypeError or ValueError possibly related to ERROR in COMMAND LINE ARGUMENT while running ./configure \n' \
497    +'-------------------------------------------------------------------------------\n'  \
498    +emsg+'*******************************************************************************\n'
499    se = ''
500  except ImportError as e :
501    # this exception is automatically deleted by Python so we need to save it to print below
502    tbo = sys.exc_info()[2]
503    emsg = str(e)
504    if not emsg.endswith('\n'): emsg = emsg+'\n'
505    msg ='*******************************************************************************\n'\
506    +'                     ImportError while runing ./configure \n' \
507    +'-------------------------------------------------------------------------------\n'  \
508    +emsg+'*******************************************************************************\n'
509    se = ''
510  except OSError as e :
511    tbo = sys.exc_info()[2]
512    emsg = str(e)
513    if not emsg.endswith('\n'): emsg = emsg+'\n'
514    msg ='*******************************************************************************\n'\
515    +'                    OSError while running ./configure \n' \
516    +'-------------------------------------------------------------------------------\n'  \
517    +emsg+'*******************************************************************************\n'
518    se = ''
519  except SystemExit as e:
520    tbo = sys.exc_info()[2]
521    if e.code is None or e.code == 0:
522      return
523    if e.code == 10:
524      sys.exit(10)
525    msg ='*******************************************************************************\n'\
526    +'         CONFIGURATION FAILURE  (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \
527    +'*******************************************************************************\n'
528    se  = str(e)
529  except Exception as e:
530    tbo = sys.exc_info()[2]
531    msg ='*******************************************************************************\n'\
532    +'        CONFIGURATION CRASH  (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \
533    +'*******************************************************************************\n'
534    se  = str(e)
535
536  print(msg)
537  if not framework is None:
538    framework.logClear()
539    if hasattr(framework, 'log'):
540      try:
541        if hasattr(framework,'compilerDefines'):
542          framework.log.write('**** Configure header '+framework.compilerDefines+' ****\n')
543          framework.outputHeader(framework.log)
544        if hasattr(framework,'compilerFixes'):
545          framework.log.write('**** C specific Configure header '+framework.compilerFixes+' ****\n')
546          framework.outputCHeader(framework.log)
547      except Exception as e:
548        framework.log.write('Problem writing headers to log: '+str(e))
549      try:
550        framework.log.write(msg+se)
551        traceback.print_tb(tbo, file = framework.log)
552        print_final_timestamp(framework)
553        if hasattr(framework,'log'): framework.log.close()
554        move_configure_log(framework)
555      except Exception as e:
556        print('Error printing error message from exception or printing the traceback:'+str(e))
557        traceback.print_tb(sys.exc_info()[2])
558      sys.exit(1)
559    else:
560      print(se)
561      traceback.print_tb(tbo)
562  else:
563    print(se)
564    traceback.print_tb(tbo)
565  if hasattr(framework,'log'): framework.log.close()
566
567if __name__ == '__main__':
568  petsc_configure([])
569