def list_upgrades(bin_env=None,
                  user=None,
                  cwd=None):
    pip_bin = _get_pip_bin(bin_env)

    cmd = [pip_bin, 'list', '--outdated']

    cmd_kwargs = dict(cwd=cwd, runas=user)
    if bin_env and os.path.isdir(bin_env):
        cmd_kwargs['env'] = {'VIRTUAL_ENV': bin_env}

    result = __salt__['cmd.run_all'](cmd, **cmd_kwargs)
    if result['retcode'] > 0:
        logger.error(result['stderr'])
        raise CommandExecutionError(result['stderr'])

    packages = {}
    for line in result['stdout'].splitlines():
        match = re.search(r'(\S*)\s+\(.*Latest:\s+(.*)\)', line)
        if match:
            name, version_ = match.groups()
        else:
            logger.error('Can\'t parse line \'{0}\''.format(line))
            continue
        packages[name] = version_
    return packages
Check whether or not an upgrade is available for all packages
dataset/ETHPy150Open saltstack/salt/salt/modules/pip.py/list_upgrades