docs: def ensure_virtualenv(args, return_values):
      """Ensure we have a valid virtualenv."""
      def adjust_options(options, args):
          # TODO-TEST: proper error message with no arguments
          venv_path = return_values.venv_path = args[0]
  
          if venv_path == DEFAULT_VIRTUALENV_PATH or options.prompt == '<dirname>':
              from os.path import abspath, basename, dirname
              options.prompt = '(%s)' % basename(dirname(abspath(venv_path)))
          # end of option munging.
  
          # there are two python interpreters involved here:
          # 1) the interpreter we're instructing virtualenv to copy
          if options.python is None:
              source_python = None
          else:
              source_python = virtualenv.resolve_interpreter(options.python)
          # 2) the interpreter virtualenv will create
          destination_python = venv_python(venv_path)
  
          if exists(destination_python):
              reason = invalid_virtualenv_reason(venv_path, source_python, destination_python, options)
              if reason:
                  info('Removing invalidated virtualenv. (%s)' % reason)
                  run(('rm', '-rf', venv_path))
              else:
                  info('Keeping valid virtualenv from previous run.')
                  raise SystemExit(0)  # looks good! we're done here.
  
      # this is actually a documented extension point:
      #   http://virtualenv.readthedocs.org/en/latest/reference.html#adjust_options
      import virtualenv
      virtualenv.adjust_options = adjust_options
  
      from sys import argv
      argv[:] = ('virtualenv',) + args
      info(colorize(argv))
      raise_on_failure(virtualenv.main)
      # There might not be a venv_path if doing something like "venv= --version"
      # and not actually asking virtualenv to make a venv.
      if return_values.venv_path is not None:
          run(('rm', '-rf', join(return_values.venv_path, 'local')))