[Distutils] EasyInstall: List of installed packages

Phillip J. Eby pje at telecommunity.com
Sun Jun 5 20:12:57 CEST 2005

At 04:40 PM 6/5/2005 +0100, Paul Moore wrote:
>Is there a way of asking EasyInstall "what packages are installed"?

Not the command-line script.  However "ls site-packages/*.egg" or "dir 
site-packages\*.egg" depending on your platform will give you the answer.

I though about having a --list-packages option, but I tend to dislike 
having options that completely change a script's behavior and complicate 
the logic of determining whether you supplied valid options.  Still, I 
suppose I could add it if it just made it list all installed packages after 
completing its regular operations.  That list could get pretty long, though.

Maybe there should be a separate command altogether; certainly it'd be easy 
to write one.  Here's some sample code for a package lister:

     import pkg_resources
     distros = pkg_resources.AvailableDistributions()  # scan sys.path
     for key in distros:
         for dist in distros[key]:
             print dist.name, dist.version

If you give AvailableDistributions a list of directories, it'll search 
those instead of sys.path.  Or, you can call its 'scan()' method to scan 
additional directories after you've created it.

>Without that, I can't see myself moving away from bdist_wininst.
>I know that a registry of installed packages starts to move away from
>the "easy" bit of "EasyInstall", but to be honest,

Ah, I see the confusion.  Yes, there's a "registry" of packages installed 
by EasyInstall.  They're eggs, so they're in directories or files named for 
the distribution, version, python version, and platform.  So the 
installation *itself* is the registry, and therefore can't be corrupted or 
out of date.

>  EasyInstall is no
>easier *for me* than double clicking on a bdist_wininst executable.

Perhaps.  I hope this weekend however to complete PyPI integration for 
EasyInstall.  It's still not a GUI, but it'll be convenient.

More information about the Distutils-SIG mailing list