From 6d009de9befddd35d0fdce5548f3089886dda651 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 11 Sep 2015 11:59:36 +0200 Subject: [PATCH] Handle VersionConflict in `load_setuptools_entrypoints` Ref: https://github.com/hpk42/pluggy/issues/7 --- pluggy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pluggy.py b/pluggy.py index c0a39e99..45192562 100644 --- a/pluggy.py +++ b/pluggy.py @@ -492,7 +492,8 @@ def check_pending(self): def load_setuptools_entrypoints(self, entrypoint_name): """ Load modules from querying the specified setuptools entrypoint name. Return the number of loaded plugins. """ - from pkg_resources import iter_entry_points, DistributionNotFound + from pkg_resources import (iter_entry_points, DistributionNotFound, + VersionConflict) for ep in iter_entry_points(entrypoint_name): # is the plugin registered or blocked? if self.get_plugin(ep.name) or self.is_blocked(ep.name): @@ -501,6 +502,9 @@ def load_setuptools_entrypoints(self, entrypoint_name): plugin = ep.load() except DistributionNotFound: continue + except VersionConflict as e: + raise PluginValidationError( + "Plugin %r could not be loaded: %s!" % (ep.name, e)) self.register(plugin, name=ep.name) self._plugin_distinfo.append((plugin, ep.dist)) return len(self._plugin_distinfo)