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

Closed
pytestbot opened this issue Mar 27, 2015 · 9 comments
Closed
Labels
good first issue easy issue that is friendly to new contributor type: bug problem that needs to be addressed

Comments

@pytestbot
Copy link
Contributor

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 problem that needs to be addressed label Jun 15, 2015
@flub flub added the task label Jul 24, 2015
@RonnyPfannschmidt
Copy link
Member

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

@flub
Copy link
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 added the good first issue easy issue that is friendly to new contributor label Jul 25, 2015
@RonnyPfannschmidt RonnyPfannschmidt modified the milestones: 2.8, 2.8.dev Sep 13, 2015
@nicoddemus
Copy link
Member

Is this still an issue?

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

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 added a commit that referenced this issue Sep 28, 2015
@blueyed
Copy link
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
Copy link
Member

Where is the upstream source for pluggy hosted?

https://github.com/hpk42/pluggy

@blueyed
Copy link
Contributor

blueyed commented Jun 21, 2016

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

@blueyed blueyed closed this as completed Jun 21, 2016
@blueyed
Copy link
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
Copy link
Member

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
Labels
good first issue easy issue that is friendly to new contributor type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

6 participants