From 3856f7c7409320723fa5e1de44aeeba498840a53 Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Tue, 22 Aug 2023 10:53:59 +1200 Subject: [PATCH] Skip adding directories to RECORD with `wheel tags` (#559) --- docs/news.rst | 2 ++ src/wheel/cli/tags.py | 2 ++ tests/cli/test_tags.py | 18 ++++++++++++------ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/docs/news.rst b/docs/news.rst index 9f65f030..eb9f0ead 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -5,6 +5,8 @@ Release Notes - Fixed platform tag detection for GraalPy and 32-bit python running on an aarch64 kernel (PR by Matthieu Darbois) +- Fixed ``wheel tags`` to not list directories in ``RECORD`` files + (PR by Mike Taves) **0.41.1 (2023-08-05)** diff --git a/src/wheel/cli/tags.py b/src/wheel/cli/tags.py index b9094d79..833687c7 100644 --- a/src/wheel/cli/tags.py +++ b/src/wheel/cli/tags.py @@ -120,6 +120,8 @@ def tags( ) as fout: fout.comment = fin.comment # preserve the comment for item in fin.infolist(): + if item.is_dir(): + continue if item.filename == f.dist_info_path + "/RECORD": continue if item.filename == f.dist_info_path + "/WHEEL": diff --git a/tests/cli/test_tags.py b/tests/cli/test_tags.py index 24541495..cf67c092 100644 --- a/tests/cli/test_tags.py +++ b/tests/cli/test_tags.py @@ -222,11 +222,17 @@ def test_permission_bits(capsys, wheelpath): with ZipFile(str(output_file), "r") as outf: with ZipFile(str(wheelpath), "r") as inf: for member in inf.namelist(): - if not member.endswith("/RECORD"): - out_attr = outf.getinfo(member).external_attr - inf_attr = inf.getinfo(member).external_attr - assert ( - out_attr == inf_attr - ), f"{member} 0x{out_attr:012o} != 0x{inf_attr:012o}" + member_info = inf.getinfo(member) + if member_info.is_dir(): + continue + + if member_info.filename.endswith("/RECORD"): + continue + + out_attr = outf.getinfo(member).external_attr + inf_attr = member_info.external_attr + assert ( + out_attr == inf_attr + ), f"{member} 0x{out_attr:012o} != 0x{inf_attr:012o}" output_file.unlink()