diff options
| author | PJ Eby <distutils-sig@python.org> | 2006-02-14 19:05:04 +0000 |
|---|---|---|
| committer | PJ Eby <distutils-sig@python.org> | 2006-02-14 19:05:04 +0000 |
| commit | 38aa9be2b1edfa477277d4c1494642061cf43a0f (patch) | |
| tree | 622d8895245d5cceed05da865a7f8bac9479b92a /api_tests.txt | |
| parent | f4be07202e3e615ba7fc0e2256d236356cdc6902 (diff) | |
| download | python-setuptools-git-38aa9be2b1edfa477277d4c1494642061cf43a0f.tar.gz | |
Added the ``extras`` attribute to ``Distribution``, the ``find_plugins()``
method to ``WorkingSet``, and the ``__add__()`` and ``__iadd__()`` methods
to ``Environment``.
--HG--
branch : setuptools
extra : convert_revision : svn%3A6015fed2-1504-0410-9fe1-9d1591cc4771/sandbox/trunk/setuptools%4042358
Diffstat (limited to 'api_tests.txt')
| -rwxr-xr-x | api_tests.txt | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/api_tests.txt b/api_tests.txt index 25f3193f..2197bd74 100755 --- a/api_tests.txt +++ b/api_tests.txt @@ -243,10 +243,47 @@ And adding a callback more than once has no effect, either:: >>> ws.subscribe(added) # no callbacks # and no double-callbacks on subsequent additions, either - >>> ws.add(Distribution(project_name="JustATest", version="0.99")) + >>> just_a_test = Distribution(project_name="JustATest", version="0.99") + >>> ws.add(just_a_test) Added JustATest 0.99 +Finding Plugins +--------------- + +``WorkingSet`` objects can be used to figure out what plugins in an +``Environment`` can be loaded without any resolution errors:: + + >>> from pkg_resources import Environment + + >>> plugins = Environment([]) # normally, a list of plugin directories + >>> plugins.add(foo12) + >>> plugins.add(foo14) + >>> plugins.add(just_a_test) + +In the simplest case, we just get the newest version of each distribution in +the plugin environment:: + + >>> ws = WorkingSet([]) + >>> ws.find_plugins(plugins) + ([JustATest 0.99, Foo 1.4 (f14)], {}) + +But if there's a problem with a version conflict or missing requirements, the +method falls back to older versions, and the error info dict will contain an +exception instance for each unloadable plugin:: + + >>> ws.add(foo12) # this will conflict with Foo 1.4 + >>> ws.find_plugins(plugins) + ([JustATest 0.99, Foo 1.2 (f12)], {Foo 1.4 (f14): <...VersionConflict...>}) + +But if you disallow fallbacks, the failed plugin will be skipped instead of +trying older versions:: + + >>> ws.find_plugins(plugins, fallback=False) + ([JustATest 0.99], {Foo 1.4 (f14): <...VersionConflict...>}) + + + Platform Compatibility Rules ---------------------------- |
