def main(argv=None):
@contextmanager<EOL>def tmpdir():<EOL><INDENT>"""<STR_LIT>"""<EOL>path = mkdtemp()<EOL>try:<EOL><INDENT>yield path<EOL><DEDENT>finally:<EOL><INDENT>rmtree(path)<EOL><DEDENT>return<EOL><DEDENT>def test():<EOL><INDENT>"""<STR_LIT>"""<EOL>install = "<STR_LIT>"<EOL>check_call(install.format(pip).split())<EOL>pytest = join(path, "<STR_LIT>", "<STR_LIT>")<EOL>test = "<STR_LIT>".format(pytest)<EOL>check_call(test.split())<EOL>uninstall = "<STR_LIT>"<EOL>check_call(uninstall.format(pip).split())<EOL>return<EOL><DEDENT>args = _cmdline(argv)<EOL>path = join(abspath(args.root), args.name)<EOL>with tmpdir() as tmp:<EOL><INDENT>clone = "<STR_LIT>".format(args.repo, tmp)<EOL>check_call(clone.split())<EOL>chdir(tmp)<EOL>checkout = "<STR_LIT>".format(args.checkout)<EOL>check_call(checkout.split())<EOL>virtualenv = "<STR_LIT>".format(path)<EOL>check_call(virtualenv.split())<EOL>pip = join(path, "<STR_LIT>", "<STR_LIT>")<EOL>install = "<STR_LIT>".format(pip)<EOL>check_call(install.split())<EOL>if args.test:<EOL><INDENT>test()<EOL><DEDENT><DEDENT>return <NUM_LIT:0><EOL>
Script execution.

    The project repo will be cloned to a temporary directory, and the desired
    branch, tag, or commit will be checked out. Then, the application will be
    installed into a self-contained virtualenv environment.