Finding which python packages are out-of-date <a href=_http_/www.flickr.com/photos/sizemore/404504970/__Mike/index.html Atherton</a>
Photo by Mike Atherton

Finding Which Python Packages Are Out-Of-Date

by Corey Oordt •  Published 8 Apr 2011

As your projects get bigger, they collect more and more packages. It can be a chore keeping track of which packages have been updated to fix potential bugs. We have that issue and devised a simple script to tells us which installed packages could use a bit of freshening up.

You’re using pip, right?

First off, this only works with pip. pip has a freeze command that lists all the installed packages. pip also understands virtualenv isolation environments, so it can list just the packages in the current virtualenv.

Multiple index support

Many of our packages are on PyPI, but every now and then we need to host a package on our own package index. We have an instance of chishop running for our index. We had to add XML-RPC support for this script to work (as of release 0.4.3 these additions have been merged back in).

So the script needed to support multiple indexes and find the newest version between all of them.

Calling the script

If you execute the script without any arguments, it will default to searching PyPI. If you pass space-delimited URLs it will use those instead. For example we would call it:

$ python check_for_updates.py http://opensource.washingtontimes.com/pypi/ http://pypi.python.org/pypi

 

to search both PyPI and our index for updates. The output would be like:

Packages with newer versions:

BeautifulSoup (3.2.0) via http://pypi.python.org/pypi. Currently 3.1.0.1.
Django (1.3) via http://pypi.python.org/pypi. Currently 1.2.5.
IPTCInfo (1.9.5-5) via http://pypi.python.org/pypi. Currently 1.9.5-4.
RunSnakeRun (2.0.1b3) via http://pypi.python.org/pypi. Currently 2.0.0b6.
SquareMap (1.0.1b2) via http://pypi.python.org/pypi. Currently 1.0.0b25.
dashboardmods (0.2) via http://opensource.washingtontimes.com/pypi/. Currently 0.1.1.
django-alphafilter (0.5.2) via http://pypi.python.org/pypi. Currently 0.5.

 

The full code is in a gist.

blog comments powered by Disqus