<s> import logging <EOL> from os . path import basename , join , normpath <EOL> from os import makedirs <EOL> from shutil import copyfile <EOL> from sys import prefix <EOL> from vext . env import run_in_syspy <EOL> from vext . gatekeeper import open_spec <EOL> from vext import logger , vext_pth <EOL> DEFAULT_PTH_CONTENT = """<STR_LIT>""" <EOL> def check_sysdeps ( vext_files ) : <EOL> """<STR_LIT>""" <EOL> @ run_in_syspy <EOL> def run ( * modules ) : <EOL> result = { } <EOL> for m in modules : <EOL> if m : <EOL> try : <EOL> __import__ ( m ) <EOL> result [ m ] = True <EOL> except ImportError : <EOL> result [ m ] = False <EOL> return result <EOL> success = True <EOL> for vext_file in vext_files : <EOL> with open ( vext_file ) as f : <EOL> vext = open_spec ( f ) <EOL> install_hint = "<STR_LIT:U+0020>" . join ( vext . get ( '<STR_LIT>' , [ '<STR_LIT>' ] ) ) <EOL> modules = vext . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> logger . debug ( "<STR_LIT>" , vext_file , modules ) <EOL> result = run ( * modules ) <EOL> if logging . getLogger ( ) . getEffectiveLevel ( ) == logging . DEBUG : <EOL> for k , v in result . items ( ) : <EOL> logger . debug ( "<STR_LIT>" , k , v ) <EOL> if not all ( result . values ( ) ) : <EOL> success = False <EOL> print ( install_hint ) <EOL> return success <EOL> def install_vexts ( vext_files , verify = True ) : <EOL> """<STR_LIT>""" <EOL> if verify and not check_sysdeps ( vext_files ) : <EOL> return <EOL> spec_dir = join ( prefix , '<STR_LIT>' ) <EOL> try : <EOL> makedirs ( spec_dir ) <EOL> except OSError : <EOL> pass <EOL> for vext_file in vext_files : <EOL> dest = normpath ( join ( spec_dir , basename ( vext_file ) ) ) <EOL> try : <EOL> logger . debug ( "<STR_LIT>" % ( vext_file , dest ) ) <EOL> copyfile ( vext_file , dest ) <EOL> yield vext_file , dest <EOL> except IOError as e : <EOL> logger . error ( "<STR_LIT>" % ( vext_file , e ) ) <EOL> def create_pth ( ) : <EOL> """<STR_LIT>""" <EOL> if prefix == '<STR_LIT>' : <EOL> print ( "<STR_LIT>" % prefix ) <EOL> return False <EOL> with open ( vext_pth , '<STR_LIT:w>' ) as f : <EOL> f . write ( DEFAULT_PTH_CONTENT ) <EOL> return True </s>
