Skip to content

Commit 049e98b

Browse files
[3.9] bpo-43958: Document importlib.metadata.PackagePath.locate method (GH-25669) (GH-27221)
(cherry picked from commit b38b2fa) Co-authored-by: Paul Moore <[email protected]> Automerge-Triggered-By: GH:jaraco
1 parent 8187033 commit 049e98b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Doc/library/importlib.metadata.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ Distribution files
149149
You can also get the full set of files contained within a distribution. The
150150
``files()`` function takes a distribution package name and returns all of the
151151
files installed by this distribution. Each file object returned is a
152-
``PackagePath``, a :class:`pathlib.Path` derived object with additional ``dist``,
152+
``PackagePath``, a :class:`pathlib.PurePath` derived object with additional ``dist``,
153153
``size``, and ``hash`` properties as indicated by the metadata. For example::
154154

155155
>>> util = [p for p in files('wheel') if 'util.py' in str(p)][0] # doctest: +SKIP
@@ -173,6 +173,12 @@ Once you have the file, you can also read its contents::
173173
return s.encode('utf-8')
174174
return s
175175

176+
You can also use the ``locate`` method to get a the absolute path to the
177+
file::
178+
179+
>>> util.locate() # doctest: +SKIP
180+
PosixPath('/home/gustav/example/lib/site-packages/wheel/util.py')
181+
176182
In the case where the metadata file listing files
177183
(RECORD or SOURCES.txt) is missing, ``files()`` will
178184
return ``None``. The caller may wish to wrap calls to

0 commit comments

Comments
 (0)