xref: /petsc/config/PETSc/options/externalpackagesdir.py (revision a275d695918c70f398ddcaf8dc549cd4eb487631)
1import config.base
2import os
3import re
4
5class Configure(config.base.Configure):
6  def __init__(self, framework):
7    config.base.Configure.__init__(self, framework)
8    return
9
10  def setupDependencies(self, framework):
11    self.installdir    = framework.require('PETSc.options.installDir',self)
12    self.arch          = framework.require('PETSc.options.arch',self)
13    return
14
15  def setExternalPackagesDir(self):
16    '''Set location where external packages will be downloaded to'''
17    if self.framework.externalPackagesDir is None:
18      self.dir = os.path.join(os.path.abspath(os.path.join(self.arch.arch)), 'externalpackages')
19    else:
20      self.dir = os.path.join(self.framework.externalPackagesDir,self.arch.arch)
21    return
22
23  def cleanExternalpackagesDir(self):
24    '''Remove all downloaded external packages, from --with-clean'''
25    import shutil
26    if self.framework.argDB['with-clean'] and os.path.isdir(self.dir):
27      self.logPrintWarning('"with-clean" is specified. Removing all externalpackage files from '+ self.dir)
28      shutil.rmtree(self.dir)
29    return
30
31  def configure(self):
32    self.executeTest(self.setExternalPackagesDir)
33    self.executeTest(self.cleanExternalpackagesDir)
34    return
35