<s> """<STR_LIT>""" <EOL> dependencies = [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT:url>' : ( "<STR_LIT>" <EOL> "<STR_LIT>" ) } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : False , <EOL> '<STR_LIT>' : "<STR_LIT>" , <EOL> '<STR_LIT:url>' : ( "<STR_LIT>" <EOL> "<STR_LIT>" ) } , <EOL> ] <EOL> import sys <EOL> import subprocess <EOL> import os <EOL> from os import path <EOL> import tempfile <EOL> import shutil <EOL> import urllib <EOL> import hashlib <EOL> def download_to ( url , folder_path ) : <EOL> file_name = url . rsplit ( '<STR_LIT:/>' , <NUM_LIT:1> ) [ <NUM_LIT:1> ] <EOL> download_path = path . join ( folder_path , file_name ) <EOL> got_path , headers = urllib . urlretrieve ( url , download_path ) <EOL> return file_name <EOL> def verify ( file_path , md5sum ) : <EOL> checksum = hashlib . md5 ( ) <EOL> with open ( file_path , '<STR_LIT:rb>' ) as f : <EOL> while True : <EOL> buf = f . read ( <NUM_LIT:2> ** <NUM_LIT:16> ) <EOL> if not buf : <EOL> break <EOL> checksum . update ( buf ) <EOL> if checksum . hexdigest ( ) != md5sum : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> def install ( package , build_path , install_path ) : <EOL> archive_name = download_to ( package [ '<STR_LIT:url>' ] , build_path ) <EOL> verify ( path . join ( build_path , archive_name ) , package [ '<STR_LIT>' ] ) <EOL> dev_null = open ( '<STR_LIT>' , '<STR_LIT:wb>' ) <EOL> tgz_ext = '<STR_LIT>' <EOL> zip_ext = '<STR_LIT>' <EOL> if archive_name . endswith ( tgz_ext ) : <EOL> subprocess . check_call ( [ '<STR_LIT>' , '<STR_LIT>' , archive_name ] , <EOL> cwd = build_path , stdout = dev_null , stderr = dev_null ) <EOL> dist_path = path . join ( build_path , archive_name [ : - len ( tgz_ext ) ] ) <EOL> elif archive_name . endswith ( zip_ext ) : <EOL> subprocess . check_call ( [ '<STR_LIT>' , archive_name ] , <EOL> cwd = build_path , stdout = dev_null , stderr = dev_null ) <EOL> dist_path = path . join ( build_path , archive_name [ : - len ( zip_ext ) ] ) <EOL> else : <EOL> raise ValueError ( "<STR_LIT>" % archive_name ) <EOL> cmd = [ sys . executable , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' + install_path ] <EOL> if package [ '<STR_LIT>' ] : <EOL> cmd . append ( '<STR_LIT>' ) <EOL> subprocess . check_call ( cmd , cwd = dist_path , stdout = dev_null , stderr = dev_null ) <EOL> def main ( ) : <EOL> deps_path = path . join ( path . abspath ( path . dirname ( __file__ ) ) , '<STR_LIT>' ) <EOL> if not path . isdir ( deps_path ) : <EOL> os . mkdir ( deps_path ) <EOL> temp_path = tempfile . mkdtemp ( ) <EOL> try : <EOL> build_path = path . join ( temp_path , '<STR_LIT>' ) <EOL> os . mkdir ( build_path ) <EOL> for package in dependencies : <EOL> package_name = package [ '<STR_LIT>' ] <EOL> dest_path = path . join ( deps_path , package_name ) <EOL> if path . isdir ( dest_path ) : <EOL> print "<STR_LIT>" % package_name <EOL> else : <EOL> install ( package , build_path , temp_path ) <EOL> site_pkg = '<STR_LIT>' <EOL> install_path = path . join ( temp_path , site_pkg , package_name ) <EOL> shutil . copytree ( install_path , dest_path ) <EOL> print "<STR_LIT>" % dest_path <EOL> finally : <EOL> shutil . rmtree ( temp_path ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
