Welcome, guest | Sign In | My Account | Store | Cart

Pip has an option to upgrade a package (_pip install -U_), however it always downloads sources even if there is already a newest version installed. If you want to check updates for all installed packages then some scripting is required.

This script checks if there is a newer version on PyPI for every installed package. It only prints information about available version and doesn't do any updates. Example output:

distribute 0.6.15                        0.6.16 available
Baker 1.1                                up to date
Django 1.3                               up to date
ipython 0.10.2                           up to date
gunicorn 0.12.1                          0.12.2 available
pyprof2calltree 1.1.0                    up to date
profilestats 1.0.2                       up to date
mercurial 1.8.3                          up to date
Python, 20 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

import xmlrpclib
import pip

pypi = xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
for dist in pip.get_installed_distributions():
    available = pypi.package_releases(dist.project_name)
    if not available:
        # Try to capitalize pkg name
        available = pypi.package_releases(dist.project_name.capitalize())
        
    if not available:
        msg = 'no releases at pypi'
    elif available[0] != dist.version:
        msg = '{} available'.format(available[0])
    else:
        msg = 'up to date'
    pkg_info = '{dist.project_name} {dist.version}'.format(dist=dist)
    print '{pkg_info:40} {msg}'.format(pkg_info=pkg_info, msg=msg)

1 comment

Fabrice Romand 9 years, 10 months ago  # | flag

or you can use pip-tools package