Reputation:
Currently I'm using a very ugly approach based on a regex for finding links and taking them apart.
I'm unhappy with the code, so I'm asking for nicer solutions, preferably using only the stdlib.
The task at hand has 2 parts:
The expected result is a mapping of distribution -> versions -> files.
Upvotes: 4
Views: 1057
Reputation:
its unfortunate, but due to the lack of xmlrpc on other indexes i need to keep my solution
Upvotes: 0
Reputation: 6907
We are going to release distutils2 to PyPI in the short-term future. It contains a distutils2.pypi module which lets you search PyPI from Python code and a pysetup program which is a command-line script to do the same thing (among others). The doc is still a work in progress, but there are some examples and an API reference:
Upvotes: 1
Reputation: 71464
There is an XML-RPC interface. See the Python.org wiki page on Cheese Shop (old name for PyPi) API.
Excerpt from that wiki:
>>> import xmlrpclib
>>> server = xmlrpclib.Server('http://pypi.python.org/pypi')
>>> server.package_releases('roundup')
['1.1.2']
>>> server.package_urls('roundup', '1.1.2')
[{'has_sig': True, 'comment_text': '', 'python_version': 'source', 'url': 'http://pypi.python.org/packages/source/r/roundup/roundup-1.1.2.tar.gz', 'md5_digest': '7c395da56412e263d7600fa7f0afa2e5', 'downloads': 2989, 'filename': 'roundup-1.1.2.tar.gz', 'packagetype': 'sdist', 'size': 876455}, {'has_sig': True, 'comment_text': '', 'python_version': 'any', 'url': 'http://pypi.python.org/packages/any/r/roundup/roundup-1.1.2.win32.exe', 'md5_digest': '983d565b0b87f83f1b6460e54554a845', 'downloads': 2020, 'filename': 'roundup-1.1.2.win32.exe', 'packagetype': 'bdist_wininst', 'size': 614270}]
list_packages
and package_releases
seem to be exactly what you're looking for.
You just have to write some code in Python to determine which of the listed packages satisfy the criterion; i.e. if the package name must start with foo
:
>>> packages = server.list_packages()
>>> match_foo = [package for package in packages if package.startswith('foo')]
>>> print len(match_foo)
2
Upvotes: 1
Reputation: 1271
In a buildout which access pypi i pin versions like this:
Products.PloneFormGen==1.2.5
Here it searches for version 1.2.5 an uses this..
Dont know if it is this what u looking for...
Upvotes: -1