You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
No easy way to get the distribution which provided a importlib.metadata.EntryPoint #86548
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/jaraco'closed_at=<Date2021-03-07.22:43:02.795>created_at=<Date2020-11-17.06:56:21.443>labels= ['type-feature', 'library', '3.10']
title='No easy way to get the distribution which provided a importlib.metadata.EntryPoint'updated_at=<Date2021-03-07.22:47:18.618>user='https://github.com/s0undt3ch'
With pkg_resources an EntryPoint has a dist attribute which allows you to get the distribution that provided that specific entry-point, however, with importlib.metafata and importlib_metadata that's not an east task.
The above solution has the additional drawback that you're iterating the distributions list, once per EntryPoint, which, was already iterated to get the entry-points listing.
I propose we attach the Distribution instance to each of the found EntryPoint to avoid this low performance workaround.
I don't have an issue with providing a pull-request, but should that pull request be done against importlib_metadata or importlib.metadata?
Pedro - thanks for the detailed report. Pull requests against importlib_metadata are easier to accept because they can be tested more easily, released more rapidly, and there's a straightforward way to port them to CPython. Regardless, I see you've proposed a change to CPython, so I can work with that.
s0undt3ch commented on Nov 17, 2020
s0undt3chmannequin
MannequinAuthor
More actions
Guess I jumped too fast :)
Will the changes in CPythom be included in importlib_metadata?
In discussion, I realized that I don't yet understand what use-cases drive this demand? What code is it that requires resolving a distribution from an entry point?
s0undt3ch commented on Dec 6, 2020
s0undt3chmannequin
MannequinAuthor
More actions
Our software uses a plug-in based approach.
Plugins are able to add/modify internal behavior, and, as part of bug submission process we have a CLI flag which provides information about the core app as well as any intervening plugins.
This is where we need to "map" an entry point to it's distribution, so we know the name and version of it to display on this report.
Activity
s0undt3ch commentedon Nov 17, 2020
With
pkg_resourcesanEntryPointhas a dist attribute which allows you to get the distribution that provided that specific entry-point, however, withimportlib.metafataandimportlib_metadatathat's not an east task.The above solution has the additional drawback that you're iterating the distributions list, once per EntryPoint, which, was already iterated to get the entry-points listing.
I propose we attach the Distribution instance to each of the found EntryPoint to avoid this low performance workaround.
I don't have an issue with providing a pull-request, but should that pull request be done against
importlib_metadataorimportlib.metadata?jaraco commentedon Nov 17, 2020
Pedro - thanks for the detailed report. Pull requests against importlib_metadata are easier to accept because they can be tested more easily, released more rapidly, and there's a straightforward way to port them to CPython. Regardless, I see you've proposed a change to CPython, so I can work with that.
s0undt3ch commentedon Nov 17, 2020
Guess I jumped too fast :)
Will the changes in CPythom be included in
importlib_metadata?jaraco commentedon Nov 17, 2020
Yes - I keep both in sync.
jaraco commentedon Dec 6, 2020
I've ported the initial patch over to the backport and am exploring options in python/importlib_metadata#266.
jaraco commentedon Dec 6, 2020
In discussion, I realized that I don't yet understand what use-cases drive this demand? What code is it that requires resolving a distribution from an entry point?
s0undt3ch commentedon Dec 6, 2020
Our software uses a plug-in based approach.
Plugins are able to add/modify internal behavior, and, as part of bug submission process we have a CLI flag which provides information about the core app as well as any intervening plugins.
This is where we need to "map" an entry point to it's distribution, so we know the name and version of it to display on this report.
jaraco commentedon Dec 31, 2020
New changeset dfdca85 by Jason R. Coombs in branch 'master':
bpo-42382: In importlib.metadata,
EntryPointobjects now exposedist(bpo-23758)dfdca85