Skip to content

Instantly share code, notes, and snippets.

@guillaumevincent
Created March 16, 2013 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillaumevincent/5177383 to your computer and use it in GitHub Desktop.
Save guillaumevincent/5177383 to your computer and use it in GitHub Desktop.
Get from http://code.activestate.com/recipes/577708-check-for-package-updates-on-pypi-works-best-in-pi/ 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 s…
#!/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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment