def pip_cmd(env, cmd, ignore_activated=False, **kwargs):
cmd = tuple(cmd)<EOL>dirname = safe_path(env)<EOL>if not ignore_activated:<EOL><INDENT>activated_env = os.environ.get('<STR_LIT>')<EOL>if hasattr(sys, '<STR_LIT>'):<EOL><INDENT>dirname = sys.prefix<EOL><DEDENT>elif activated_env:<EOL><INDENT>dirname = activated_env<EOL><DEDENT><DEDENT>pip_path = os.path.join(dirname, '<STR_LIT>' if IS_WINDOWS else '<STR_LIT>', '<STR_LIT>')<EOL>if kwargs.pop('<STR_LIT>', False):<EOL><INDENT>return pip_path<EOL><DEDENT>if not os.path.isfile(pip_path):<EOL><INDENT>raise OSError('<STR_LIT>'.format(pip_path))<EOL><DEDENT>if BOOTSTRAPPER_TEST_KEY in os.environ and cmd[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>cmd = list(cmd)<EOL>cmd.insert(<NUM_LIT:1>, '<STR_LIT>')<EOL>cmd = tuple(cmd)<EOL><DEDENT>with disable_error_handler():<EOL><INDENT>return run_cmd((pip_path, ) + cmd, **kwargs)<EOL><DEDENT>
r"""Run pip command in given or activated virtual environment.

    :param env: Virtual environment name.
    :param cmd: Pip subcommand to run.
    :param ignore_activated:
        Ignore activated virtual environment and use given venv instead. By
        default: False
    :param \*\*kwargs:
        Additional keyword arguments to be passed to :func:`~run_cmd`