Skip to content

Commit 9bde7fa

Browse files
committed
Update with latest changes from importlib_metadata
1 parent a630dfa commit 9bde7fa

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

Doc/library/importlib.metadata.rst

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.. _using:
22

33
==========================
4-
Using importlib_metadata
4+
Using importlib.metadata
55
==========================
66

7-
``importlib_metadata`` is a library that provides for access to installed
7+
``importlib.metadata`` is a library that provides for access to installed
88
package metadata. Built in part on Python's import system, this library
99
intends to replace similar functionality in the `entry point
1010
API`_ and `metadata API`_ of ``pkg_resources``. Along with
@@ -37,15 +37,18 @@ Let's say you wanted to get the version string for a package you've installed
3737
using ``pip``. We start by creating a virtual environment and installing
3838
something into it::
3939

40+
.. highlight:: none
41+
4042
$ python3 -m venv example
4143
$ source example/bin/activate
42-
(example) $ pip install importlib_metadata
4344
(example) $ pip install wheel
4445

4546
You can get the version string for ``wheel`` by running the following::
4647

48+
.. highlight:: none
49+
4750
(example) $ python
48-
>>> from importlib_metadata import version
51+
>>> from importlib.metadata import version
4952
>>> version('wheel')
5053
'0.32.3'
5154

@@ -143,7 +146,7 @@ files installed by this distribution. Each file object returned is a
143146
>>> util.size
144147
859
145148
>>> util.dist
146-
<importlib_metadata._hooks.PathDistribution object at 0x101e0cef0>
149+
<importlib.metadata._hooks.PathDistribution object at 0x101e0cef0>
147150
>>> util.hash
148151
<FileHash mode: sha256 value: bYkw5oMccfazVCoYQwKkkemoVyMAFoR34mmKBx8R1NI>
149152

@@ -179,7 +182,7 @@ of that information from the ``Distribution`` class. A ``Distribution`` is an
179182
abstract object that represents the metadata for a Python package. You can
180183
get the ``Distribution`` instance::
181184

182-
>>> from importlib_metadata import distribution
185+
>>> from importlib.metadata import distribution
183186
>>> dist = distribution('wheel')
184187

185188
Thus, an alternative way to get the version number is through the
@@ -206,16 +209,16 @@ Extending the search algorithm
206209
Because package metadata is not available through ``sys.path`` searches, or
207210
package loaders directly, the metadata for a package is found through import
208211
system `finders`_. To find a distribution package's metadata,
209-
``importlib_metadata`` queries the list of `meta path finders`_ on
212+
``importlib.metadata`` queries the list of `meta path finders`_ on
210213
`sys.meta_path`_.
211214

212-
By default ``importlib_metadata`` installs a finder for distribution packages
215+
By default ``importlib.metadata`` installs a finder for distribution packages
213216
found on the file system. This finder doesn't actually find any *packages*,
214217
but it can find the packages' metadata.
215218

216219
The abstract class :py:class:`importlib.abc.MetaPathFinder` defines the
217220
interface expected of finders by Python's import system.
218-
``importlib_metadata`` extends this protocol by looking for an optional
221+
``importlib.metadata`` extends this protocol by looking for an optional
219222
``find_distributions`` callable on the finders from
220223
``sys.meta_path``. If the finder has this method, it must return
221224
an iterator over instances of the ``Distribution`` abstract class. This

0 commit comments

Comments
 (0)