<s> """<STR_LIT>""" <EOL> import os <EOL> import subprocess <EOL> import sys <EOL> ROOT = os . path . dirname ( os . path . dirname ( os . path . realpath ( __file__ ) ) ) <EOL> VENV = os . path . join ( ROOT , '<STR_LIT>' ) <EOL> PIP_REQUIRES = os . path . join ( ROOT , '<STR_LIT>' , '<STR_LIT>' ) <EOL> PY_VERSION = "<STR_LIT>" % ( sys . version_info [ <NUM_LIT:0> ] , sys . version_info [ <NUM_LIT:1> ] ) <EOL> def die ( message , * args ) : <EOL> print >> sys . stderr , message % args <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> def check_python_version ( ) : <EOL> if sys . version_info < ( <NUM_LIT:2> , <NUM_LIT:6> ) : <EOL> die ( "<STR_LIT>" ) <EOL> def run_command ( cmd , redirect_output = True , check_exit_code = True ) : <EOL> """<STR_LIT>""" <EOL> if redirect_output : <EOL> stdout = subprocess . PIPE <EOL> else : <EOL> stdout = None <EOL> proc = subprocess . Popen ( cmd , cwd = ROOT , stdout = stdout ) <EOL> output = proc . communicate ( ) [ <NUM_LIT:0> ] <EOL> if check_exit_code and proc . returncode != <NUM_LIT:0> : <EOL> die ( '<STR_LIT>' , '<STR_LIT:U+0020>' . join ( cmd ) , output ) <EOL> return output <EOL> HAS_EASY_INSTALL = bool ( run_command ( [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> check_exit_code = False ) . strip ( ) ) <EOL> HAS_VIRTUALENV = bool ( run_command ( [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> check_exit_code = False ) . strip ( ) ) <EOL> def check_dependencies ( ) : <EOL> """<STR_LIT>""" <EOL> print '<STR_LIT>' <EOL> if not HAS_VIRTUALENV : <EOL> print '<STR_LIT>' <EOL> if HAS_EASY_INSTALL : <EOL> print '<STR_LIT>' , <EOL> if not ( run_command ( [ '<STR_LIT>' , '<STR_LIT>' ] ) and <EOL> run_command ( [ '<STR_LIT>' , '<STR_LIT>' ] ) ) : <EOL> die ( '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' <EOL> def create_virtualenv ( venv = VENV ) : <EOL> """<STR_LIT>""" <EOL> print '<STR_LIT>' , <EOL> run_command ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , VENV ] ) <EOL> print '<STR_LIT>' <EOL> print '<STR_LIT>' , <EOL> if not run_command ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) . strip ( ) : <EOL> die ( "<STR_LIT>" ) <EOL> print '<STR_LIT>' <EOL> def install_dependencies ( venv = VENV ) : <EOL> print '<STR_LIT>' <EOL> run_command ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , PIP_REQUIRES ] , redirect_output = False ) <EOL> def print_help ( ) : <EOL> help = """<STR_LIT>""" % VENV <EOL> print help <EOL> def main ( argv ) : <EOL> check_python_version ( ) <EOL> check_dependencies ( ) <EOL> create_virtualenv ( ) <EOL> install_dependencies ( ) <EOL> print_help ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( sys . argv ) </s>
