Skip to content

Commit edb1d44

Browse files
pfmoorejaraco
authored andcommitted
Document importlib.metadata.PackagePath.locate method (GH-25669)
1 parent 81bccbc commit edb1d44

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docs/using.rst

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

189189
>>> util = [p for p in files('wheel') if 'util.py' in str(p)][0]
@@ -207,6 +207,12 @@ Once you have the file, you can also read its contents::
207207
return s.encode('utf-8')
208208
return s
209209

210+
You can also use the ``locate`` method to get a the absolute path to the
211+
file::
212+
213+
>>> util.locate() # doctest: +SKIP
214+
PosixPath('/home/gustav/example/lib/site-packages/wheel/util.py')
215+
210216
In the case where the metadata file listing files
211217
(RECORD or SOURCES.txt) is missing, ``files()`` will
212218
return ``None``. The caller may wish to wrap calls to

0 commit comments

Comments
 (0)