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

Closed
pytestbot opened this Issue Mar 27, 2015 · 9 comments

Comments

Projects
None yet
6 participants
@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/config.py 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/core.py 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/__init__.py in load(self, require, *args, **kwargs)
   2318             )
   2319         if require:
-> 2320             self.require(*args, **kwargs)
   2321         return self.resolve()
   2322 

…/pyenv/project2/lib/python2.7/site-packages/pkg_resources/__init__.py 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))
   2339 

…/pyenv/project2/lib/python2.7/site-packages/pkg_resources/__init__.py 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)
    815 
    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
skipped.

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


@pytestbot pytestbot added the type: bug label Jun 15, 2015

@flub flub added the task label Jul 24, 2015

@RonnyPfannschmidt

This comment has been minimized.

Member

RonnyPfannschmidt commented Jul 25, 2015

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

@flub

This comment has been minimized.

Member

flub commented Jul 25, 2015

Yes, sure
On 25 Jul 2015 11:50, "Ronny Pfannschmidt" notifications@github.com wrote:

this is now in pluggy, @hpk42 https://github.com/hpk42 @flub
https://github.com/flub - is this a candidate for a person at the
sprint?


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

@RonnyPfannschmidt RonnyPfannschmidt modified the milestones: 2.8, 2.8.dev Sep 13, 2015

@nicoddemus

This comment has been minimized.

Member

nicoddemus commented Sep 26, 2015

Is this still an issue?

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

@RonnyPfannschmidt

This comment has been minimized.

Member

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

@blueyed

This comment has been minimized.

Contributor

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/config.py", line 39, in main
    config = _prepareconfig(args, plugins)
  File "…/pytest/_pytest/config.py", line 118, in _prepareconfig
    pluginmanager=pluginmanager, args=args)
  File "…/pytest/_pytest/vendored_packages/pluggy.py", line 724, in __call__
    return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
  File "…/pytest/_pytest/vendored_packages/pluggy.py", line 338, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "…/pytest/_pytest/vendored_packages/pluggy.py", line 333, in <lambda>
    _MultiCall(methods, kwargs, hook.spec_opts).execute()
  File "…/pytest/_pytest/vendored_packages/pluggy.py", line 595, in execute
    return _wrapped_call(hook_impl.function(*args), self.execute)
  File "…/pytest/_pytest/vendored_packages/pluggy.py", line 249, in _wrapped_call
    wrap_controller.send(call_outcome)
  File "…/pytest/_pytest/helpconfig.py", line 28, in pytest_cmdline_parse
    config = outcome.get_result()
  File "…/pytest/_pytest/vendored_packages/pluggy.py", line 278, in get_result
    raise ex[1].with_traceback(ex[2])
  File "…/pytest/_pytest/vendored_packages/pluggy.py", line 264, in __init__
    self.result = func()
  File "…/pytest/_pytest/vendored_packages/pluggy.py", line 596, in execute
    res = hook_impl.function(*args)
  File "…/pytest/_pytest/config.py", line 856, in pytest_cmdline_parse
    self.parse(args)
  File "…/pytest/_pytest/config.py", line 961, in parse
    self._preparse(args, addopts=addopts)
  File "…/pytest/_pytest/config.py", line 922, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "…/pytest/_pytest/vendored_packages/pluggy.py", line 501, in load_setuptools_entrypoints
    plugin = ep.load()
  File "…/pyenv/project/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2379, in load
    self.require(*args, **kwargs)
  File "…/pyenv/project/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2396, in require
    items = working_set.resolve(reqs, env, installer)
  File "…/pyenv/project/lib/python3.5/site-packages/pkg_resources/__init__.py", 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/ep.name):

diff --git i/_pytest/vendored_packages/pluggy.py w/_pytest/vendored_packages/pluggy.
index 2f848b2..3ed558b 100644
--- i/_pytest/vendored_packages/pluggy.py
+++ w/_pytest/vendored_packages/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,8 @@ def load_setuptools_entrypoints(self, entrypoint_name):
                 plugin = ep.load()
             except DistributionNotFound:
                 continue
+            except VersionConflict as excinfo:
+                continue
             self.register(plugin, name=ep.name)
             self._plugin_distinfo.append((plugin, ep.dist))
         return len(self._plugin_distinfo)

@blueyed blueyed reopened this Mar 4, 2016

@The-Compiler

This comment has been minimized.

Member

The-Compiler commented Mar 4, 2016

Where is the upstream source for pluggy hosted?

https://github.com/hpk42/pluggy

@blueyed

This comment has been minimized.

Contributor

blueyed commented Jun 21, 2016

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

@blueyed blueyed closed this Jun 21, 2016

@blueyed

This comment has been minimized.

Contributor

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?! https://github.com/hpk42/pluggy/blob/master/CHANGELOG

@nicoddemus

This comment has been minimized.

Member

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