summaryrefslogtreecommitdiff
path: root/Lib/importlib/_bootstrap_external.py
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2019-09-10 14:53:31 +0100
committerBrett Cannon <54418+brettcannon@users.noreply.github.com>2019-09-10 14:53:31 +0100
commit17499d82702432955d8e442a1871ff276ca64bc5 (patch)
tree377a62315e01cf4b38e06b713645f30910a284c7 /Lib/importlib/_bootstrap_external.py
parent97d7906e30eeee1261b20a45a22242a8accb1cfb (diff)
downloadcpython-git-17499d82702432955d8e442a1871ff276ca64bc5.tar.gz
bpo-38086: Sync importlib.metadata with importlib_metadata 0.21. (GH-15840)
https://gitlab.com/python-devs/importlib_metadata/-/tags/0.21
Diffstat (limited to 'Lib/importlib/_bootstrap_external.py')
-rw-r--r--Lib/importlib/_bootstrap_external.py18
1 files changed, 8 insertions, 10 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index 671b043c73..ec4bbec41e 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -1370,21 +1370,19 @@ class PathFinder:
return spec.loader
@classmethod
- def find_distributions(cls, name=None, path=None):
+ def find_distributions(self, context=None):
"""
Find distributions.
Return an iterable of all Distribution instances capable of
- loading the metadata for packages matching the ``name``
- (or all names if not supplied) along the paths in the list
- of directories ``path`` (defaults to sys.path).
+ loading the metadata for packages matching ``context.name``
+ (or all names if ``None`` indicated) along the paths in the list
+ of directories ``context.path``.
"""
- import re
- from importlib.metadata import PathDistribution
- if path is None:
- path = sys.path
- pattern = '.*' if name is None else re.escape(name)
- found = cls._search_paths(pattern, path)
+ from importlib.metadata import PathDistribution, DistributionFinder
+ if context is None:
+ context = DistributionFinder.Context()
+ found = self._search_paths(context.pattern, context.path)
return map(PathDistribution, found)
@classmethod