mirror of
https://github.com/python/cpython.git
synced 2025-10-10 00:43:41 +00:00
bpo-38086: Sync importlib.metadata with importlib_metadata 0.21. (GH-15840)
https://gitlab.com/python-devs/importlib_metadata/-/tags/0.21
This commit is contained in:
parent
97d7906e30
commit
17499d8270
8 changed files with 712 additions and 661 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue