def ensure_virtualenv(args, return_values):
def adjust_options(options, args):<EOL><INDENT>venv_path = return_values.venv_path = args[<NUM_LIT:0>]<EOL>if venv_path == DEFAULT_VIRTUALENV_PATH or options.prompt == '<STR_LIT>':<EOL><INDENT>from os.path import abspath, basename, dirname<EOL>options.prompt = '<STR_LIT>' % basename(dirname(abspath(venv_path)))<EOL><DEDENT>if options.python is None:<EOL><INDENT>source_python = None<EOL><DEDENT>else:<EOL><INDENT>source_python = virtualenv.resolve_interpreter(options.python)<EOL><DEDENT>destination_python = venv_python(venv_path)<EOL>if exists(destination_python):<EOL><INDENT>reason = invalid_virtualenv_reason(venv_path, source_python, destination_python, options)<EOL>if reason:<EOL><INDENT>info('<STR_LIT>' % reason)<EOL>run(('<STR_LIT>', '<STR_LIT>', venv_path))<EOL><DEDENT>else:<EOL><INDENT>info('<STR_LIT>')<EOL>raise SystemExit(<NUM_LIT:0>)  <EOL><DEDENT><DEDENT><DEDENT>import virtualenv<EOL>virtualenv.adjust_options = adjust_options<EOL>from sys import argv<EOL>argv[:] = ('<STR_LIT>',) + args<EOL>info(colorize(argv))<EOL>raise_on_failure(virtualenv.main)<EOL>if return_values.venv_path is not None:<EOL><INDENT>run(('<STR_LIT>', '<STR_LIT>', join(return_values.venv_path, '<STR_LIT>')))<EOL><DEDENT>
Ensure we have a valid virtualenv.