python - Searching PyPI by topic -
for every python bundle can specify list of classifiers. among others there topic
classifier, puts bundle in specified categories can browsed on pypi
.
for example, numpy
has next topics:
topic :: software development topic :: scientific/engineering
is there way search topic programmatically using pip search
or other third-party libraries?
you can search pypi classifier via xmlrpc api, using browse()
method:
try: import xmlrpclib # python 2 except importerror: import xmlrpc.client xmlrpclib # python 3 pypi = xmlrpclib.serverproxy('http://pypi.python.org/pypi') packages = pypi.browse([ "topic :: software development", "topic :: scientific/engineering", ])
in illustration above, packages
contains list of [package, version]
lists packages satisfy both "topic :: software development" , "topic :: scientific/engineering" classifiers:
>>> {pkg: ver pkg, ver in packages if "numpy" in pkg} { 'nose-numpyseterr': '0.1', 'msgpack-numpy': '0.3.2', 'numpy': '1.8.1', 'idx2numpy': '1.0b' }
from there, can retrieve more info given release:
>>> release = pypi.release_data('numpy', '1.8.1') >>> release['download_url'] 'http://sourceforge.net/projects/numpy/files/numpy/' >>> release['platform'] 'windows,linux,solaris,mac os-x,unix' >>> release['downloads'] { 'last_day': 5818, 'last_month': 187688, 'last_week': 44764 }
... etc.
python pip package-managers pypi
No comments:
Post a Comment