[Distutils] distlib updated with "locators" API

Vinay Sajip vinay_sajip at yahoo.co.uk
Sun Oct 14 02:16:10 CEST 2012


I've updated distlib with an experimental API for locating distributions. A
locator is just something whose "get_project" method you invoke with a "project"
name such as "flask" or "sqlalchemy", and it returns a dictionary whose keys
are versions of the project which were located, and the corresponding value is
a tuple whose first element is a Metadata object and whose second element is a
list of dicts pointing to archives for that version of the project.

I've implemented three locators with some basic tests and docs:

* DirectoryLocator - looks in a file system directory tree for archives
* PyPIRPCLocator - uses PyPI's XML-RPC interface to locate archives
* SimpleScrapingLocator - uses PyPI's "simple" web scraping interface to
  locate archives - similar to pip's PackageFinder

A very basic script showing how to use it is at

https://gist.github.com/3886402

There's plenty more work to do - if there's mileage in this idea, instead of
returning Metadata and lists of dicts, Distribution instances can be returned
which can be queried for dependencies in a more natural way. At the moment,
this (dependency querying) isn't fully doable because all the metadata is not
declarative. However, the work I've been doing with the package.yaml metadata
format indicates that setup()-kwarg metadata can be automatically pulled out of
setup.py for many (most) of the projects on PyPI.

Feedback welcome.

Regards,

Vinay Sajip




More information about the Distutils-SIG mailing list