Is there a PyPI API?

Mike Driscoll kyosohma at gmail.com
Sat May 10 14:43:06 EDT 2008


Hi,

I am experimenting on creating a GUI wrapper for easy_install and I
would like to be able to allow the user the browse PyPI topically.
However, I am having some trouble figuring out how to get the
information in a topical manner.

I can get the list of classifiers easily using urllib2 like so:

def getPyPiClassifiers():
    print 'Get list of Topics from PyPI...'

    url = 'http://pypi.python.org/pypi?%3Aaction=list_classifiers'
    res = urllib2.urlopen(url)
    page = res.read()

And there's a "light-weight" list of all the packages on PyPI here:
http://pypi.python.org/simple/

I just can't figure out how to get the metadata, I guess. I found Paul
Boddies SGMLParser example (http://www.boddie.org.uk/python/HTML.html)
which can get me some URLs, but what I really need is some kind of
dict of tuples or lists like this:

{'Framework':(('Buildout', 'bazaarrecipe', 'Buildout recipe for
Bazaar'),
                   ('Buildout', 'buildout_script', 'zc.buildout
recipes for generating script and conf files from templates.')
)}

Any ideas on how best to approach this would be great. I'm still
learning HTML/XML parsing techniques and am having trouble wrapping my
mind around it.

Thanks!

Mike



More information about the Python-list mailing list