.. versionadded:: 2015.5.0

    Upgrades outdated pip packages.

    .. note::
        On Windows you can't update salt from pip using salt, so salt will be
        skipped

    Returns a dict containing the changes.

        {'<package>':  {'old': '<old-version>',
                        'new': '<new-version>'}}


    CLI Example:

    .. code-block:: bash

        salt '*' pip.upgrade

def upgrade(bin_env=None,
            user=None,
            cwd=None,
            use_vt=False):
    '''
    .. versionadded:: 2015.5.0

    Upgrades outdated pip packages.

    .. note::
        On Windows you can't update salt from pip using salt, so salt will be
        skipped

    Returns a dict containing the changes.

        {'<package>':  {'old': '<old-version>',
                        'new': '<new-version>'}}


    CLI Example:

    .. code-block:: bash

        salt '*' pip.upgrade
    '''
    ret = {'changes': {},
           'result': True,
           'comment': '',
           }
    cmd = _get_pip_bin(bin_env)
    cmd.extend(['install', '-U'])

    old = list_(bin_env=bin_env, user=user, cwd=cwd)

    cmd_kwargs = dict(cwd=cwd, use_vt=use_vt)
    if bin_env and os.path.isdir(bin_env):
        cmd_kwargs['env'] = {'VIRTUAL_ENV': bin_env}
    errors = False
    for pkg in list_upgrades(bin_env=bin_env, user=user, cwd=cwd):
        if pkg == 'salt':
            if salt.utils.platform.is_windows():
                continue
        result = __salt__['cmd.run_all'](cmd + [pkg], **cmd_kwargs)
        if result['retcode'] != 0:
            errors = True
        if 'stderr' in result:
            ret['comment'] += result['stderr']
    if errors:
        ret['result'] = False

    _clear_context(bin_env)
    new = list_(bin_env=bin_env, user=user, cwd=cwd)

    ret['changes'] = salt.utils.data.compare_dicts(old, new)

    return ret