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

pkg_resources.iter_entry_points fails to iterate when it encounters VersionConflict #1826

Closed
ssbarnea opened this issue Aug 20, 2019 · 2 comments
Labels

Comments

@ssbarnea
Copy link

While adding plugins support for molecule I discovered that if by any chance one plugins would encounter a VersionConflict, the entire iteration fails suddenly without giving me any chance to ignore the potentially broken plugin.

In this case alone the conflict was caused by azure-cli and it was benign by itself. As you can imagine an application developer has zero control over what happens with the plugins and one broken plugin should not affect the loading of others.

import pkg_resources

for f in pkg_resources.iter_entry_points('molecule_driver'):
   print(f)

The code above should never raise exceptions. In my case iteration stops after first plugin, as the second one happens to be the one in conflict.

Traceback (most recent call last):
File "/Users/ssbarnea/.pyenv/versions/3.6.8/bin/molecule", line 11, in <module>
load_entry_point('molecule', 'console_scripts', 'molecule')()
File "/Users/ssbarnea/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Users/ssbarnea/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2843, in load_entry_point
return ep.load()
File "/Users/ssbarnea/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2434, in load
return self.resolve()
File "/Users/ssbarnea/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2440, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Users/ssbarnea/os/molecule/molecule/__main__.py", line 21, in <module>
from .shell import main
File "/Users/ssbarnea/os/molecule/molecule/shell.py", line 28, in <module>
from molecule import command
File "/Users/ssbarnea/os/molecule/molecule/command/__init__.py", line 29, in <module>
from molecule.command import create  # noqa
File "/Users/ssbarnea/os/molecule/molecule/command/create.py", line 108, in <module>
type=click.Choice(molecule_drivers()),
File "/Users/ssbarnea/os/molecule/molecule/api.py", line 15, in molecule_drivers
for entry_point in pkg_resources.iter_entry_points('molecule_driver')
File "/Users/ssbarnea/os/molecule/molecule/api.py", line 15, in <dictcomp>
for entry_point in pkg_resources.iter_entry_points('molecule_driver')
File "/Users/ssbarnea/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2433, in load
self.require(*args, **kwargs)
File "/Users/ssbarnea/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2456, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File "/Users/ssbarnea/.pyenv/versions/3.6.8/lib/python3.6/site-packages/pkg_resources/__init__.py", line 791, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (azure-mgmt-storage 4.0.0 (/Users/ssbarnea/.pyenv/versions/3.6.8/lib/python3.6/site-packages), Requirement.parse('azure-mgmt-storage~=2.0'), {'azure-mgmt'})
@jaraco
Copy link
Member

jaraco commented Sep 2, 2019

Hi Sorin. What happens if you use the importlib_metadata or entrypoints projects? Those projects aim to replace pkg_resources and in particular behaviors like these. If importlib_metadata doesn’t suit your needs, please file a bug with Python or importlib_metadata, so we might be able to consider supporting it there.

@jaraco jaraco added the wontfix label Sep 2, 2019
@jaraco
Copy link
Member

jaraco commented Sep 2, 2019

I’m closing this a wontfix but willing to reopen as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants