Clean up handling of plugin distribution metadata #1073
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes and cleans up work done in #1061.
The issue is how to find the distribution which provides a particular Lektor plugin.
Importlib.metadata
provides thepackages_distribution
function which sort of does the right thing, but,it turns out that it is not totally reliable1.
In any case, under the hood,
packages_distribution
just iterates over all the distributions. It’s cleaner just toiterate the distributions to find the plugins — then we know for sure which distribution a given plugin comes from.
Issue(s) Resolved
Fixes #
Related Issues / Links
Description of Changes
Footnotes
Packages_distributions
(more-or-less) depends on the distribution(s) providing atop_level.txt
in its.pkg-info
.It appears that
top_level.txt
is not specified in any PEP and is a remnant from the days of eggs. Most distributionsstill provide them, but some do not (e.g. poetry build wheel file. not found top_level.txt python-poetry/poetry#3093.) ↩