Documentation
Since pkg_resources is deprecated, I'm trying to migrate pkg_resources.working_set to importlib.metadata.
working set
A collection of distributions actually available for importing, as on sys.path. At most one distribution (release version) of a given project may be present in a working set, as otherwise there would be ambiguity as to what to import.
--- https://setuptools.pypa.io/en/latest/pkg_resources.html
The doc doesn't provide an example for retrieving all installed packages.
By searching in the source code, distributions returns the installed Distributions.
|
def distributions(**kwargs) -> Iterable[Distribution]: |
|
"""Get all ``Distribution`` instances in the current environment. |
|
|
|
:return: An iterable of ``Distribution`` instances. |
|
""" |
|
return Distribution.discover(**kwargs) |
I think it's a useful function and should be added to the document.
Linked PRs
Documentation
Since
pkg_resourcesis deprecated, I'm trying to migratepkg_resources.working_settoimportlib.metadata.The doc doesn't provide an example for retrieving all installed packages.
By searching in the source code,
distributionsreturns the installed Distributions.cpython/Lib/importlib/metadata/__init__.py
Lines 963 to 968 in ea25f4a
I think it's a useful function and should be added to the document.
Linked PRs
importlib.metadata.distributions#136024