<s> """<STR_LIT>""" <EOL> import os <EOL> import shutil <EOL> import sys <EOL> import tempfile <EOL> import urllib <EOL> import urllib2 <EOL> import subprocess <EOL> from optparse import OptionParser <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> def quote ( c ) : <EOL> if '<STR_LIT:U+0020>' in c : <EOL> return '<STR_LIT>' % c <EOL> else : <EOL> return c <EOL> else : <EOL> quote = str <EOL> stdout , stderr = subprocess . Popen ( <EOL> [ sys . executable , '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ] , <EOL> stdout = subprocess . PIPE , stderr = subprocess . PIPE ) . communicate ( ) <EOL> has_broken_dash_S = bool ( int ( stdout . strip ( ) ) ) <EOL> if not has_broken_dash_S and '<STR_LIT>' in sys . modules : <EOL> args = sys . argv [ : ] <EOL> args [ <NUM_LIT:0> : <NUM_LIT:0> ] = [ sys . executable , '<STR_LIT>' ] <EOL> args = map ( quote , args ) <EOL> os . execv ( sys . executable , args ) <EOL> clean_path = sys . path [ : ] <EOL> site = __import__ ( '<STR_LIT>' ) <EOL> sys . path [ : ] = clean_path <EOL> for k , v in sys . modules . items ( ) : <EOL> if k in ( '<STR_LIT>' , '<STR_LIT>' ) or ( <EOL> hasattr ( v , '<STR_LIT>' ) and <EOL> len ( v . __path__ ) == <NUM_LIT:1> and <EOL> not os . path . exists ( os . path . join ( v . __path__ [ <NUM_LIT:0> ] , '<STR_LIT>' ) ) ) : <EOL> sys . modules . pop ( k ) <EOL> is_jython = sys . platform . startswith ( '<STR_LIT>' ) <EOL> setuptools_source = '<STR_LIT>' <EOL> distribute_source = '<STR_LIT>' <EOL> def normalize_to_url ( option , opt_str , value , parser ) : <EOL> if value : <EOL> if '<STR_LIT>' not in value : <EOL> value = '<STR_LIT>' % ( <EOL> urllib . pathname2url ( <EOL> os . path . abspath ( os . path . expanduser ( value ) ) ) , ) <EOL> if opt_str == '<STR_LIT>' and not value . endswith ( '<STR_LIT:/>' ) : <EOL> value += '<STR_LIT:/>' <EOL> else : <EOL> value = None <EOL> name = opt_str [ <NUM_LIT:2> : ] . replace ( '<STR_LIT:->' , '<STR_LIT:_>' ) <EOL> setattr ( parser . values , name , value ) <EOL> usage = '''<STR_LIT>''' <EOL> parser = OptionParser ( usage = usage ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> dest = "<STR_LIT:version>" , <EOL> help = "<STR_LIT>" <EOL> ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> dest = "<STR_LIT>" , <EOL> default = False , <EOL> help = "<STR_LIT>" <EOL> ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , <EOL> action = "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> callback = normalize_to_url , <EOL> nargs = <NUM_LIT:1> , <EOL> type = "<STR_LIT:string>" , <EOL> help = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" + <EOL> setuptools_source + "<STR_LIT>" <EOL> "<STR_LIT>" + distribute_source + "<STR_LIT:.>" <EOL> ) <EOL> ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , <EOL> action = "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> callback = normalize_to_url , <EOL> nargs = <NUM_LIT:1> , <EOL> type = "<STR_LIT:string>" , <EOL> help = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , <EOL> help = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> dest = '<STR_LIT>' , <EOL> action = "<STR_LIT:store_true>" , <EOL> default = False , <EOL> help = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> ) <EOL> parser . add_option ( <EOL> "<STR_LIT:-c>" , None , <EOL> action = "<STR_LIT:store>" , <EOL> dest = "<STR_LIT>" , <EOL> help = ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) <EOL> ) <EOL> options , args = parser . parse_args ( ) <EOL> if options . config_file is not None : <EOL> args += [ '<STR_LIT:-c>' , options . config_file ] <EOL> if options . eggs : <EOL> eggs_dir = os . path . abspath ( os . path . expanduser ( options . eggs ) ) <EOL> else : <EOL> eggs_dir = tempfile . mkdtemp ( ) <EOL> if options . setup_source is None : <EOL> if options . use_distribute : <EOL> options . setup_source = distribute_source <EOL> else : <EOL> options . setup_source = setuptools_source <EOL> if options . accept_buildout_test_releases : <EOL> args . append ( '<STR_LIT>' ) <EOL> args . append ( '<STR_LIT>' ) <EOL> try : <EOL> import pkg_resources <EOL> import setuptools <EOL> if not hasattr ( pkg_resources , '<STR_LIT>' ) : <EOL> raise ImportError <EOL> except ImportError : <EOL> ez_code = urllib2 . urlopen ( <EOL> options . setup_source ) . read ( ) . replace ( '<STR_LIT:\r\n>' , '<STR_LIT:\n>' ) <EOL> ez = { } <EOL> exec ez_code in ez <EOL> setup_args = dict ( to_dir = eggs_dir , download_delay = <NUM_LIT:0> ) <EOL> if options . download_base : <EOL> setup_args [ '<STR_LIT>' ] = options . download_base <EOL> if options . use_distribute : <EOL> setup_args [ '<STR_LIT>' ] = True <EOL> ez [ '<STR_LIT>' ] ( ** setup_args ) <EOL> if '<STR_LIT>' in sys . modules : <EOL> reload ( sys . modules [ '<STR_LIT>' ] ) <EOL> import pkg_resources <EOL> for path in sys . path : <EOL> if path not in pkg_resources . working_set . entries : <EOL> pkg_resources . working_set . add_entry ( path ) <EOL> cmd = [ quote ( sys . executable ) , <EOL> '<STR_LIT:-c>' , <EOL> quote ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' , <EOL> quote ( eggs_dir ) ] <EOL> if not has_broken_dash_S : <EOL> cmd . insert ( <NUM_LIT:1> , '<STR_LIT>' ) <EOL> find_links = options . download_base <EOL> if not find_links : <EOL> find_links = os . environ . get ( '<STR_LIT>' ) <EOL> if find_links : <EOL> cmd . extend ( [ '<STR_LIT>' , quote ( find_links ) ] ) <EOL> if options . use_distribute : <EOL> setup_requirement = '<STR_LIT>' <EOL> else : <EOL> setup_requirement = '<STR_LIT>' <EOL> ws = pkg_resources . working_set <EOL> setup_requirement_path = ws . find ( <EOL> pkg_resources . Requirement . parse ( setup_requirement ) ) . location <EOL> env = dict ( <EOL> os . environ , <EOL> PYTHONPATH = setup_requirement_path ) <EOL> requirement = '<STR_LIT>' <EOL> version = options . version <EOL> if version is None and not options . accept_buildout_test_releases : <EOL> import setuptools . package_index <EOL> _final_parts = '<STR_LIT>' , '<STR_LIT>' <EOL> def _final_version ( parsed_version ) : <EOL> for part in parsed_version : <EOL> if ( part [ : <NUM_LIT:1> ] == '<STR_LIT:*>' ) and ( part not in _final_parts ) : <EOL> return False <EOL> return True <EOL> index = setuptools . package_index . PackageIndex ( <EOL> search_path = [ setup_requirement_path ] ) <EOL> if find_links : <EOL> index . add_find_links ( ( find_links , ) ) <EOL> req = pkg_resources . Requirement . parse ( requirement ) <EOL> if index . obtain ( req ) is not None : <EOL> best = [ ] <EOL> bestv = None <EOL> for dist in index [ req . project_name ] : <EOL> distv = dist . parsed_version <EOL> if _final_version ( distv ) : <EOL> if bestv is None or distv > bestv : <EOL> best = [ dist ] <EOL> bestv = distv <EOL> elif distv == bestv : <EOL> best . append ( dist ) <EOL> if best : <EOL> best . sort ( ) <EOL> version = best [ - <NUM_LIT:1> ] . version <EOL> if version : <EOL> requirement = '<STR_LIT>' . join ( ( requirement , version ) ) <EOL> cmd . append ( requirement ) <EOL> if is_jython : <EOL> import subprocess <EOL> exitcode = subprocess . Popen ( cmd , env = env ) . wait ( ) <EOL> else : <EOL> exitcode = os . spawnle ( * ( [ os . P_WAIT , sys . executable ] + cmd + [ env ] ) ) <EOL> if exitcode != <NUM_LIT:0> : <EOL> sys . stdout . flush ( ) <EOL> sys . stderr . flush ( ) <EOL> print ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> sys . exit ( exitcode ) <EOL> ws . add_entry ( eggs_dir ) <EOL> ws . require ( requirement ) <EOL> import zc . buildout . buildout <EOL> zc . buildout . buildout . main ( args ) <EOL> if not options . eggs : <EOL> shutil . rmtree ( eggs_dir ) </s>
