Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Needs to handle VersionConflict in consider_setuptools_entrypoints #704

pytestbot opened this issue Mar 27, 2015 · 9 comments

Needs to handle VersionConflict in consider_setuptools_entrypoints #704

pytestbot opened this issue Mar 27, 2015 · 9 comments


Copy link

@pytestbot pytestbot commented Mar 27, 2015

Originally reported by: Daniel Hahler (BitBucket: blueyed, GitHub: blueyed)

I was getting the following error, caused by the testmon plugin, which
requires pytest<2.7:

…/pyenv/project2/lib/python2.7/site-packages/_pytest/ in _preparse(self, args, addopts)
    711         self._checkversion()
    712         self.pluginmanager.consider_preparse(args)
--> 713         self.pluginmanager.consider_setuptools_entrypoints()
    714         self.pluginmanager.consider_env()
    715         self.known_args_namespace = ns = self._parser.parse_known_args(args)

…/pyenv/project2/lib/python2.7/site-packages/_pytest/ in consider_setuptools_entrypoints(self)
    276                 continue
    277             try:
--> 278                 plugin = ep.load()
    279             except DistributionNotFound:
    280                 continue

…/pyenv/project2/lib/python2.7/site-packages/pkg_resources/ in load(self, require, *args, **kwargs)
   2318             )
   2319         if require:
-> 2320             self.require(*args, **kwargs)
   2321         return self.resolve()

…/pyenv/project2/lib/python2.7/site-packages/pkg_resources/ in require(self, env, installer)
   2335             raise UnknownExtra("Can't require() without a distribution", self)
   2336         reqs = self.dist.requires(self.extras)
-> 2337         items = working_set.resolve(reqs, env, installer)
   2338         list(map(working_set.add, items))

…/pyenv/project2/lib/python2.7/site-packages/pkg_resources/ in resolve(self, requirements, env, installer, replace_conflicting)
    812                 dependent_req = required_by[req]
    813                 import ipdb; ipdb.set_trace()  # noqa
--> 814                 raise VersionConflict(dist, req).with_context(dependent_req)
    816             # push the new requirements onto the stack

VersionConflict: (pytest 2.7.0 (…/pyenv/project2/lib/python2.7/site-packages), Requirement.parse('pytest<2.7'))

ipdb> args
self = <pkg_resources.WorkingSet object at 0x7f3ec2a55cd0>
requirements = [Requirement.parse('pathtools>=0.1.1'), Requirement.parse('argh>=0.24.1'), Requirement.parse('PyYAML>=3.10'), Requirement.parse('execnet>=1.1.dev1'), Requ
irement.parse('pytest>=2.2')]                                                                                                                                            env = None
installer = None
replace_conflicting = False

ep is EntryPoint.parse('testmon = testmon.plugin').

It would be nice if there was a warning in such a case and the plugin was

A warning might be useful with the current handling of DistributionNotFound,

@pytestbot pytestbot added the type: bug label Jun 15, 2015
@flub flub added the task label Jul 24, 2015
Copy link

@RonnyPfannschmidt RonnyPfannschmidt commented Jul 25, 2015

this is now in pluggy, @hpk42 @flub - is this a candidate for a person at the sprint?

Copy link

@flub flub commented Jul 25, 2015

Yes, sure
On 25 Jul 2015 11:50, "Ronny Pfannschmidt" wrote:

this is now in pluggy, @hpk42 @flub - is this a candidate for a person at the

Reply to this email directly or view it on GitHub
#704 (comment).

@RonnyPfannschmidt RonnyPfannschmidt modified the milestones: 2.8, Sep 13, 2015
Copy link

@nicoddemus nicoddemus commented Sep 26, 2015

Is this still an issue?

@nicoddemus nicoddemus removed this from the 2.8.1 milestone Sep 26, 2015
Copy link

@RonnyPfannschmidt RonnyPfannschmidt commented Sep 27, 2015

I think pluggy has a better handling now, wed need to vendor and test

nicoddemus added a commit to nicoddemus/pytest that referenced this issue Sep 27, 2015
@hpk42 hpk42 closed this in #1077 Sep 28, 2015
hpk42 added a commit that referenced this issue Sep 28, 2015
Copy link

@blueyed blueyed commented Mar 4, 2016

Still not better:

Traceback (most recent call last):
  File "…/pyenv/project/bin/py.test", line 9, in <module>
    load_entry_point('pytest', 'console_scripts', 'py.test')()
  File "…/pytest/_pytest/", line 39, in main
    config = _prepareconfig(args, plugins)
  File "…/pytest/_pytest/", line 118, in _prepareconfig
    pluginmanager=pluginmanager, args=args)
  File "…/pytest/_pytest/vendored_packages/", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "…/pytest/_pytest/vendored_packages/", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "…/pytest/_pytest/vendored_packages/", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "…/pytest/_pytest/vendored_packages/", line 595, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "…/pytest/_pytest/vendored_packages/", line 249, in _wrapped_call
  File "…/pytest/_pytest/", line 28, in pytest_cmdline_parse
    config = outcome.get_result()
  File "…/pytest/_pytest/vendored_packages/", line 278, in get_result
    raise ex[1].with_traceback(ex[2])
  File "…/pytest/_pytest/vendored_packages/", line 264, in __init__
    self.result = func()
  File "…/pytest/_pytest/vendored_packages/", line 596, in execute
    res = hook_impl.function(*args)
  File "…/pytest/_pytest/", line 856, in pytest_cmdline_parse
  File "…/pytest/_pytest/", line 961, in parse
    self._preparse(args, addopts=addopts)
  File "…/pytest/_pytest/", line 922, in _preparse
  File "…/pytest/_pytest/vendored_packages/", line 501, in load_setuptools_entrypoints
    plugin = ep.load()
  File "…/pyenv/project/lib/python3.5/site-packages/pkg_resources/", line 2379, in load
    self.require(*args, **kwargs)
  File "…/pyenv/project/lib/python3.5/site-packages/pkg_resources/", line 2396, in require
    items = working_set.resolve(reqs, env, installer)
  File "…/pyenv/project/lib/python3.5/site-packages/pkg_resources/", line 854, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pytest 2.9.1.dev1 (…/pytest), Requirement.parse('pytest<2.9,>=2.7.0'))

This happened with an older pytest-testmon package, after only updating pytest.

Where is the upstream source for pluggy hosted?

A patch could look like this, but should also display the error / problem (mentioning also ep/

diff --git i/_pytest/vendored_packages/ w/_pytest/vendored_packages/pluggy.
index 2f848b2..3ed558b 100644
--- i/_pytest/vendored_packages/
+++ w/_pytest/vendored_packages/
@@ -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( or self.is_blocked(
@@ -501,6 +502,8 @@ def load_setuptools_entrypoints(self, entrypoint_name):
                 plugin = ep.load()
             except DistributionNotFound:
+            except VersionConflict as excinfo:
+                continue
             self._plugin_distinfo.append((plugin, ep.dist))
         return len(self._plugin_distinfo)
@blueyed blueyed reopened this Mar 4, 2016
Copy link

@The-Compiler The-Compiler commented Mar 4, 2016

Where is the upstream source for pluggy hosted?

Copy link

@blueyed blueyed commented Jun 21, 2016

Thanks, it was fixed in pytest-dev/pluggy#8.

@blueyed blueyed closed this Jun 21, 2016
Copy link

@blueyed blueyed commented Jun 21, 2016

But 0.3.2 is not released and vendored yet.
Not sure if this issue for pytest should get re-opened.
A new release of pluggy seems to be a good idea for the (end of the) sprint?!

Copy link

@nicoddemus nicoddemus commented Jun 22, 2016

That's a good idea @blueyed, created an issue for it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants