diff --git a/plux/__init__.py b/plux/__init__.py index 5f8fb7e..b41be3b 100644 --- a/plux/__init__.py +++ b/plux/__init__.py @@ -17,7 +17,7 @@ name = "plux" -__version__ = "1.11.0" +__version__ = "1.11.1" __all__ = [ "FunctionPlugin", diff --git a/plux/runtime/metadata.py b/plux/runtime/metadata.py index e6070ac..053826b 100644 --- a/plux/runtime/metadata.py +++ b/plux/runtime/metadata.py @@ -3,7 +3,6 @@ """ import collections -import importlib.metadata import inspect import io import os @@ -34,12 +33,24 @@ def metadata_packages_distributions() -> t.Mapping[str, t.List[str]]: @lru_cache() def packages_distributions() -> t.Mapping[str, t.List[str]]: """ - Cache wrapper around metadata.packages_distributions, which returns a mapping of top-level packages to - their distributions. + Cache wrapper around ``metadata.packages_distributions``, which returns a mapping of top-level packages to + their distributions. This index is created by scanning all ``top_level.txt`` metadata files in the path. + + Unlike ``metadata.packages_distributions``, this implementation will contain a de-duplicated list of + distribution names per package. With editable installs, ``packages_distributions()`` may return the + distribution metadata for both the ``.egg-info`` in the linked source directory, and the ``.dist-info`` + in the site-packages directory created by the editable install. Therefore, a distribution name may + appear twice for the same package, which is unhelpful information, so we deduplicate it here. :return: package to distribution mapping """ - return metadata_packages_distributions() + distributions = dict(metadata_packages_distributions()) + + for k in distributions.keys(): + # remove duplicates occurrences of the same distribution name + distributions[k] = list(set(distributions[k])) + + return distributions def resolve_distribution_information(plugin_spec: PluginSpec) -> t.Optional[Distribution]: