[Distutils] upgrade functionality

Phillip J. Eby pje at telecommunity.com
Sat Jun 30 16:56:28 CEST 2007

At 09:22 AM 6/30/2007 -0300, Flavio Codeco Coelho wrote:
>Does setuptools have any mechanism for upgrading all packages installed
>with easy_install? Something similar to an "apt-get upgrade"?

Well, you can do something like

     from setuptools.command.easy_install import main as install
     from pkg_resources import Environment
     install(['-U'] + list(Environment()))

That would be the equivalent of running "easy_install -U names of 
packages" for all installed packages.

>I have dozens of packages that have been installed with easy_install, to
>the point that I can't even recall the whole list.

A quick recipe for listing active installed packages:

     python -c "for dist in __import__('pkg_resources').working_set: 
print dist"

This won't list eggs that are installed but not active on 
sys.path.  (e.g. older versions of packages, or ones installed in 
--multi-version mode).

More information about the Distutils-SIG mailing list