def build(spec, distpath, workpath, clean_build):
 from ..config import CONF
 def TkPKG(*args, **kwargs):
  global _old_api_error
  _old_api_error('TkPKG')
 def TkTree(*args, **kwargs):
  global _old_api_error
  _old_api_error('TkTree')
 distpath = compat.expand_path(distpath)
 workpath = compat.expand_path(workpath)
 CONF['spec'] = compat.expand_path(spec)
 (CONF['specpath'], CONF['specnm']) = os.path.split(spec)
 CONF['specnm'] = os.path.splitext(CONF['specnm'])[0]
 if (os.path.dirname(distpath) == HOMEPATH):
  distpath = os.path.join(HOMEPATH, CONF['specnm'], os.path.basename(distpath))
 CONF['distpath'] = distpath
 if (os.path.dirname(workpath) == HOMEPATH):
  workpath = os.path.join(HOMEPATH, CONF['specnm'], os.path.basename(workpath), CONF['specnm'])
 else:
  workpath = os.path.join(workpath, CONF['specnm'])
 CONF['warnfile'] = os.path.join(workpath, ('warn%s.txt' % CONF['specnm']))
 CONF['dot-file'] = os.path.join(workpath, ('graph-%s.dot' % CONF['specnm']))
 CONF['xref-file'] = os.path.join(workpath, ('xref-%s.html' % CONF['specnm']))
 if clean_build:
  logger.info('Removing temporary files and cleaning cache in %s', CONF['cachedir'])
  for pth in (CONF['cachedir'], workpath):
   if os.path.exists(pth):
    for f in glob.glob((pth + '/*')):
     if os.path.isdir(f):
      shutil.rmtree(f)
     else:
      os.remove(f)
 for pth in (CONF['distpath'], workpath):
  if (not os.path.exists(pth)):
   os.makedirs(pth)
 spec_namespace = {'DISTPATH': CONF['distpath'], 'HOMEPATH': HOMEPATH, 'SPEC': CONF['spec'], 'specnm': CONF['specnm'], 'SPECPATH': CONF['specpath'], 'WARNFILE': CONF['warnfile'], 'workpath': workpath, 'TOC': TOC, 'Analysis': Analysis, 'BUNDLE': BUNDLE, 'COLLECT': COLLECT, 'EXE': EXE, 'MERGE': MERGE, 'PYZ': PYZ, 'Tree': Tree, 'TkPKG': TkPKG, 'TkTree': TkTree, 'os': os, 'pyi_crypto': pyz_crypto}
 from ..config import CONF
 CONF['workpath'] = workpath
 with open(spec, 'r') as f:
  text = f.read()
 exec text in spec_namespace

def build ( spec , distpath , workpath , clean_build ) : from . . config import CONF def TkPKG ( * args , ** kwargs ) : global _old_api_error _old_api_error ( 'TkPKG' ) def TkTree ( * args , ** kwargs ) : global _old_api_error _old_api_error ( 'TkTree' ) distpath = compat . expand_path ( distpath ) workpath = compat . expand_path ( workpath ) CONF [ 'spec' ] = compat . expand_path ( spec ) ( CONF [ 'specpath' ] , CONF [ 'specnm' ] ) = os . path . split ( spec ) CONF [ 'specnm' ] = os . path . splitext ( CONF [ 'specnm' ] ) [ 0 ] if ( os . path . dirname ( distpath ) == HOMEPATH ) : distpath = os . path . join ( HOMEPATH , CONF [ 'specnm' ] , os . path . basename ( distpath ) ) CONF [ 'distpath' ] = distpath if ( os . path . dirname ( workpath ) == HOMEPATH ) : workpath = os . path . join ( HOMEPATH , CONF [ 'specnm' ] , os . path . basename ( workpath ) , CONF [ 'specnm' ] ) else : workpath = os . path . join ( workpath , CONF [ 'specnm' ] ) CONF [ 'warnfile' ] = os . path . join ( workpath , ( 'warn%s.txt' % CONF [ 'specnm' ] ) ) CONF [ 'dot-file' ] = os . path . join ( workpath , ( 'graph-%s.dot' % CONF [ 'specnm' ] ) ) CONF [ 'xref-file' ] = os . path . join ( workpath , ( 'xref-%s.html' % CONF [ 'specnm' ] ) ) if clean_build : logger . info ( 'Removing temporary files and cleaning cache in %s' , CONF [ 'cachedir' ] ) for pth in ( CONF [ 'cachedir' ] , workpath ) : if os . path . exists ( pth ) : for f in glob . glob ( ( pth + '/*' ) ) : if os . path . isdir ( f ) : shutil . rmtree ( f ) else : os . remove ( f ) for pth in ( CONF [ 'distpath' ] , workpath ) : if ( not os . path . exists ( pth ) ) : os . makedirs ( pth ) spec_namespace = { 'DISTPATH' : CONF [ 'distpath' ] , 'HOMEPATH' : HOMEPATH , 'SPEC' : CONF [ 'spec' ] , 'specnm' : CONF [ 'specnm' ] , 'SPECPATH' : CONF [ 'specpath' ] , 'WARNFILE' : CONF [ 'warnfile' ] , 'workpath' : workpath , 'TOC' : TOC , 'Analysis' : Analysis , 'BUNDLE' : BUNDLE , 'COLLECT' : COLLECT , 'EXE' : EXE , 'MERGE' : MERGE , 'PYZ' : PYZ , 'Tree' : Tree , 'TkPKG' : TkPKG , 'TkTree' : TkTree , 'os' : os , 'pyi_crypto' : pyz_crypto } from . . config import CONF CONF [ 'workpath' ] = workpath with open ( spec , 'r' ) as f : text = f . read ( ) exec text in spec_namespace
given the output target and the list of things to do .