Support loading plugins via pkg_resources entry points

Review Request #1429 - Created Dec. 5, 2014 and submitted

Information
David Taylor
pants
843
6be1933...
Reviewers
pants-reviews
benjyw, ity, jsirois, patricklaw, zundel

This provides an alternative way to find the methods build_file_aliases and register_goals that
are called as part of extension loading, specifically that for off-the-shelf plugins installed as
distrubutions, these methods are found using pkg_resources' entry points configuration.

Source backends are useful for quick and easy loading of custom tasks or aliases from sources that
live in a project. This change is not entended to replace source backends, but rather to make use
of richer metadata avilable on packaged distributions used for deploying off-the-shelf plugins.

Distributions (egg/sdist/etc) have version information and can define their entry points, which allows
cleaner separation of layout and implementation from core pants. Version requirements can be checked at
load and plugins can assert other plugins are loaded before them (since order matters eg "replace=True").

Adding such a plugin when using virtualenv pants would consist of adding it to requirements.txt used to
setup the virtualenv (or simply pip installing if using global site-packages), then adding it to
pants.ini's plugins list under the section backends.

For deployments running pants from a pex, the plugins could either be built into the distributed pex or
plugins could still be installed to a virualenv using a requirments.txt if that env were somehow then
added to the python path when invoking the pex.

This change does not include support for resolving, fetching or in any way installing plugins at
runtime -- requested plugins are loaded if they are found or an error is raised if not. If or how how
to support loading plugins that are not previously installed is left for a separate discussion.

https://travis-ci.org/pantsbuild/pants/builds/43419387
Added tests with mocked out distributions to test_extension_loader.py.
Demo repo: https://github.com/foursquare/pants-plugins-demo

Issues

  • 0
  • 5
  • 0
  • 5
Description From Last Updated
David Taylor
David Taylor
Eric Ayers
David Taylor
Patrick Lawson
John Sirois
John Sirois
David Taylor
Patrick Lawson
David Taylor
John Sirois
John Sirois
David Taylor
David Taylor
David Taylor
Eric Ayers
John Sirois
David Taylor
Review request changed

Status: Closed (submitted)

Change Summary:

43c2ad5df1ac6088208bddc08f66671a7e6eb6b6
Loading...