You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While the above API is the most common and convenient usage, you can get all
287
319
of that information from the ``Distribution`` class. A ``Distribution`` is an
288
-
abstract object that represents the metadata for a Python package. You can
320
+
abstract object that represents the metadata for
321
+
a Python `Distribution Package <https://packaging.python.org/en/latest/glossary/#term-Distribution-Package>`_. You can
289
322
get the ``Distribution`` instance::
290
323
291
324
>>> from importlib.metadata import distribution # doctest: +SKIP
@@ -305,14 +338,16 @@ instance::
305
338
>>> dist.metadata['License'] # doctest: +SKIP
306
339
'MIT'
307
340
308
-
The full set of available metadata is not described here. See :pep:`566`
309
-
for additional details.
341
+
The full set of available metadata is not described here.
342
+
See the `Core metadata specifications <https://packaging.python.org/en/latest/specifications/core-metadata/#core-metadata>`_ for additional details.
310
343
311
344
312
345
Distribution Discovery
313
346
======================
314
347
315
-
By default, this package provides built-in support for discovery of metadata for file system and zip file packages. This metadata finder search defaults to ``sys.path``, but varies slightly in how it interprets those values from how other import machinery does. In particular:
348
+
By default, this package provides built-in support for discovery of metadata
349
+
for file system and zip file `Distribution Package <https://packaging.python.org/en/latest/glossary/#term-Distribution-Package>`_\s.
350
+
This metadata finder search defaults to ``sys.path``, but varies slightly in how it interprets those values from how other import machinery does. In particular:
316
351
317
352
- ``importlib.metadata`` does not honor :class:`bytes` objects on ``sys.path``.
318
353
- ``importlib.metadata`` will incidentally honor :py:class:`pathlib.Path` objects on ``sys.path`` even though such values will be ignored for imports.
@@ -321,15 +356,18 @@ By default, this package provides built-in support for discovery of metadata for
321
356
Extending the search algorithm
322
357
==============================
323
358
324
-
Because package metadata is not available through :data:`sys.path` searches, or
325
-
package loaders directly, the metadata for a package is found through import
326
-
system :ref:`finders <finders-and-loaders>`. To find a distribution package's metadata,
359
+
Because `Distribution Package <https://packaging.python.org/en/latest/glossary/#term-Distribution-Package>`_ metadata
360
+
is not available through :data:`sys.path` searches, or
361
+
package loaders directly,
362
+
the metadata for a distribution is found through import
363
+
system `finders`_. To find a distribution package's metadata,
327
364
``importlib.metadata`` queries the list of :term:`meta path finders <meta path finder>` on
328
365
:data:`sys.meta_path`.
329
366
330
-
The default ``PathFinder`` for Python includes a hook that calls into
331
-
``importlib.metadata.MetadataPathFinder`` for finding distributions
332
-
loaded from typical file-system-based paths.
367
+
By default ``importlib_metadata`` installs a finder for distribution packages
368
+
found on the file system.
369
+
This finder doesn't actually find any *distributions*,
370
+
but it can find their metadata.
333
371
334
372
The abstract class :py:class:`importlib.abc.MetaPathFinder` defines the
335
373
interface expected of finders by Python's import system.
@@ -358,4 +396,4 @@ a custom finder, return instances of this derived ``Distribution`` in the
358
396
359
397
.. _`entry point API`: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points
0 commit comments