Skip to content

Commit 22d9ea5

Browse files
committed
Distribution.files: Only return files that actually exist
Add an extra filter on the paths returned from Distribution.files, to prevent paths that don't exist on the filesystem from being returned. This attempts to solve the issue of .files returning incorrect information based on the inaccuracies of SOURCES.txt. As the code currently is organized, it is more complicated to write this such that it only applies to the information read from SOURCES.txt specifically, hence we apply it to _all_ of .files instead. This fixes #115, also in the case where there is no installed-files.txt file available. [1]: https://pip.pypa.io/en/stable/news/#v0-3 [2]: https://setuptools.pypa.io/en/latest/deprecated/python_eggs.html#sources-txt-source-files-manifest
1 parent 8026db2 commit 22d9ea5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

importlib_metadata/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,12 @@ def make_file(name, hash=None, size_str=None):
474474

475475
@pass_none
476476
def make_files(lines):
477-
return list(starmap(make_file, csv.reader(lines)))
477+
return list(
478+
filter(
479+
lambda package_path: package_path.locate().exists(),
480+
list(starmap(make_file, csv.reader(lines))),
481+
)
482+
)
478483

479484
return make_files(
480485
self._read_files_distinfo()

0 commit comments

Comments
 (0)