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

Entry points can not be loaded if there is a package version conflict anywhere in the environment #31

Open
cpaulik opened this issue Feb 20, 2020 · 7 comments · May be fixed by #32
Open

Comments

@cpaulik
Copy link

cpaulik commented Feb 20, 2020

If any package dependency is not met the entry point fails to load. Even if this does not impact the functioning of the CLI at all

Could this be replaced by a warning?

E.g.

 Traceback (most recent call last):
  File "/opt/conda/envs/vds-37/lib/python3.7/site-packages/click_plugins/core.py", line 37, in decorator
    group.add_command(entry_point.load())
  File "/opt/conda/envs/vds-37/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2442, in load
    self.require(*args, **kwargs)
  File "/opt/conda/envs/vds-37/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2465, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/opt/conda/envs/vds-37/lib/python3.7/site-packages/pkg_resources/__init__.py", line 791, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (docutils 0.16 (/opt/conda/envs/vds-37/lib/python3.7/site-packages), Requirement.parse('docutils<0.16,>=0.10'), {'botocore'})
@AndrewHoos
Copy link

Related: pypa/setuptools#1826

Possible fixes would be using:

@geowurster
Copy link
Member

@AndrewHoos This is helpful information – thanks.

I'll try and spend some time on this in the near future. I did make an attempt several months ago but hit some potential issues and murkiness in my understanding of how entrypoints work. I do think this is worth addressing if possible.

@AndrewHoos
Copy link

If all you are doing is listing and loading entry points:

# Replace this
from pkg_resources import iter_entry_points
# with This
from entrypoints import get_group_all

The entry points have a .name and .load() which was enough for me. Bonus points it ran in about 40% of the pkg_resources API.

@teije01
Copy link

teije01 commented Apr 19, 2021

So far, the solution that @AndrewHoos proposed with entrypoints works great. Are you open to update the documentation with this solution?

@amrishparmar
Copy link

amrishparmar commented Jan 10, 2022

Is there any news on progress on this issue (or associated PR #32)?

We've recently updated to Celery 5.2.3 (which uses this click-plugins package) and are running into this problem (although in our case it's a clash with setuptools since Celery decided to tightly pin it)

Warning: entry point could not be loaded. Contact its author for help.
2022-01-10T11:33:01.647435486Z 
2022-01-10T11:33:01.647436986Z
2022-01-10T11:33:01.647438630Z Traceback (most recent call last):
2022-01-10T11:33:01.647440188Z   File "/usr/local/lib/python3.10/site-packages/click_plugins/core.py", line 37, in decorator
2022-01-10T11:33:01.647456725Z     group.add_command(entry_point.load())
2022-01-10T11:33:01.647458198Z   File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2449, in load
2022-01-10T11:33:01.647459768Z     self.require(*args, **kwargs)
2022-01-10T11:33:01.647461372Z   File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2472, in require
2022-01-10T11:33:01.647462998Z     items = working_set.resolve(reqs, env, installer, extras=self.extras)
2022-01-10T11:33:01.647464519Z   File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 777, in resolve
2022-01-10T11:33:01.647473224Z     raise VersionConflict(dist, req).with_context(dependent_req)
2022-01-10T11:33:01.647474930Z pkg_resources.ContextualVersionConflict: (setuptools 57.5.0 (/usr/local/lib/python3.10/site-packages), Requirement.parse('setuptools<59.7.0,>=59.1.1'), {'celery'})

@valentinsulzer
Copy link

For anyone still reading this thread and using the solution posted by @AndrewHoos, since entrypoints is now in maintenance-only mode it is better to replace from entrypoints import get_group_all with from importlib_metadata import entry_points and then replace get_group_all("foo") with entry_points(group="foo")

@teije01
Copy link

teije01 commented Jan 6, 2023

Thanks for the suggestion @tinosulzer, seems to work fine.

JarbasAl added a commit to OpenVoiceOS/ovos-plugin-manager that referenced this issue Jan 30, 2023
this avoids issues with requirement versions mismatches in skills, this should be handled at install time not runtime

solution taken from: click-contrib/click-plugins#31
JarbasAl added a commit to OpenVoiceOS/ovos-plugin-manager that referenced this issue Feb 2, 2023
this avoids issues with requirement versions mismatches in skills, this should be handled at install time not runtime

solution taken from: click-contrib/click-plugins#31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants