mirror of https://github.com/python/cpython
gh-103661: Apply bugfix from importlib_metadata 6.5.1 and restore test. (#103681)
This commit is contained in:
parent
3d2a46845b
commit
916de04fd1
|
@ -516,27 +516,29 @@ class Distribution(DeprecatedNonAbstract):
|
||||||
"""
|
"""
|
||||||
Read installed-files.txt and return lines in a similar
|
Read installed-files.txt and return lines in a similar
|
||||||
CSV-parsable format as RECORD: each file must be placed
|
CSV-parsable format as RECORD: each file must be placed
|
||||||
relative to the site-packages directory, and must also be
|
relative to the site-packages directory and must also be
|
||||||
quoted (since file names can contain literal commas).
|
quoted (since file names can contain literal commas).
|
||||||
|
|
||||||
This file is written when the package is installed by pip,
|
This file is written when the package is installed by pip,
|
||||||
but it might not be written for other installation methods.
|
but it might not be written for other installation methods.
|
||||||
Hence, even if we can assume that this file is accurate
|
Assume the file is accurate if it exists.
|
||||||
when it exists, we cannot assume that it always exists.
|
|
||||||
"""
|
"""
|
||||||
text = self.read_text('installed-files.txt')
|
text = self.read_text('installed-files.txt')
|
||||||
# We need to prepend the .egg-info/ subdir to the lines in this file.
|
# Prepend the .egg-info/ subdir to the lines in this file.
|
||||||
# But this subdir is only available in the PathDistribution's self._path
|
# But this subdir is only available from PathDistribution's
|
||||||
# which is not easily accessible from this base class...
|
# self._path.
|
||||||
subdir = getattr(self, '_path', None)
|
subdir = getattr(self, '_path', None)
|
||||||
if not text or not subdir:
|
if not text or not subdir:
|
||||||
return
|
return
|
||||||
with contextlib.suppress(Exception):
|
|
||||||
ret = [
|
paths = (
|
||||||
str((subdir / line).resolve().relative_to(self.locate_file('')))
|
(subdir / name)
|
||||||
for line in text.splitlines()
|
.resolve()
|
||||||
]
|
.relative_to(self.locate_file('').resolve())
|
||||||
return map('"{}"'.format, ret)
|
.as_posix()
|
||||||
|
for name in text.splitlines()
|
||||||
|
)
|
||||||
|
return map('"{}"'.format, paths)
|
||||||
|
|
||||||
def _read_files_egginfo_sources(self):
|
def _read_files_egginfo_sources(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -76,23 +76,12 @@ class APITests(
|
||||||
expect_content,
|
expect_content,
|
||||||
)
|
)
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _workaround_103661(tests):
|
|
||||||
"""
|
|
||||||
Skip failing test for now is it's failing on buildbot workers.
|
|
||||||
See https://github.com/python/cpython/issues/103661.
|
|
||||||
"""
|
|
||||||
import platform
|
|
||||||
if platform.system() == 'Windows':
|
|
||||||
tests.remove(('egg_with_no_modules-pkg', '\n'))
|
|
||||||
return tests
|
|
||||||
|
|
||||||
def test_read_text(self):
|
def test_read_text(self):
|
||||||
tests = [
|
tests = [
|
||||||
('egginfo-pkg', 'mod\n'),
|
('egginfo-pkg', 'mod\n'),
|
||||||
('egg_with_no_modules-pkg', '\n'),
|
('egg_with_no_modules-pkg', '\n'),
|
||||||
]
|
]
|
||||||
for pkg_name, expect_content in self._workaround_103661(tests):
|
for pkg_name, expect_content in tests:
|
||||||
with self.subTest(pkg_name):
|
with self.subTest(pkg_name):
|
||||||
top_level = [
|
top_level = [
|
||||||
path for path in files(pkg_name) if path.name == 'top_level.txt'
|
path for path in files(pkg_name) if path.name == 'top_level.txt'
|
||||||
|
|
Loading…
Reference in New Issue