From 5e0a9a1939708fdad98a1c59809f4b741d543dd2 Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Thu, 13 Aug 2026 02:04:31 -0400 Subject: [PATCH 1/4] fix: correct singular/plural in macOS platform-tag warning The list of problematic files was rebound to a joined string before the count was checked, so len() counted characters instead of files. The singular "this file" branch was therefore dead and the warning always read "these files", even for a single library. Compute the wording from the list length before joining. --- docs/news.rst | 6 ++++++ src/wheel/macosx_libfile.py | 2 +- tests/test_macosx_libfile.py | 38 ++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 tests/test_macosx_libfile.py diff --git a/docs/news.rst b/docs/news.rst index 98055c7e..52e86e6d 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -1,6 +1,12 @@ Release Notes ============= +**UNRELEASED** + +- Fixed the macOS platform-tag warning always using the plural "these files" + wording, even when only a single library required a higher deployment target + (`#697 `_) + **0.48.0 (2026-08-12)** - Added a ``--local-version`` option to ``wheel pack`` to add, replace, or remove a diff --git a/src/wheel/macosx_libfile.py b/src/wheel/macosx_libfile.py index 06e51af2..df69e50a 100644 --- a/src/wheel/macosx_libfile.py +++ b/src/wheel/macosx_libfile.py @@ -456,11 +456,11 @@ def calculate_macosx_platform_tag(archive_root: StrPath, platform_tag: str) -> s fin_base_version = "_".join([str(x) for x in base_version]) if start_version < base_version: problematic_files = [k for k, v in versions_dict.items() if v > start_version] - problematic_files = "\n".join(problematic_files) if len(problematic_files) == 1: files_form = "this file" else: files_form = "these files" + problematic_files = "\n".join(problematic_files) error_message = ( "[WARNING] This wheel needs a higher macOS version than {} " "To silence this warning, set MACOSX_DEPLOYMENT_TARGET to at least " diff --git a/tests/test_macosx_libfile.py b/tests/test_macosx_libfile.py new file mode 100644 index 00000000..64a4e57b --- /dev/null +++ b/tests/test_macosx_libfile.py @@ -0,0 +1,38 @@ +from __future__ import annotations + +from pathlib import Path + +import pytest + +from wheel import macosx_libfile +from wheel.macosx_libfile import calculate_macosx_platform_tag + + +@pytest.mark.parametrize( + ("dylib_count", "expected_form"), + [ + pytest.param(1, "this file", id="single"), + pytest.param(2, "these files", id="multiple"), + ], +) +def test_calculate_macosx_platform_tag_files_form( + tmp_path: Path, + monkeypatch: pytest.MonkeyPatch, + capsys: pytest.CaptureFixture[str], + dylib_count: int, + expected_form: str, +) -> None: + for index in range(dylib_count): + tmp_path.joinpath(f"lib{index}.dylib").write_bytes(b"") + + monkeypatch.setattr( + macosx_libfile, + "extract_macosx_min_system_version", + lambda path: (11, 0, 0), + ) + + tag = calculate_macosx_platform_tag(str(tmp_path), "macosx-10.9-x86_64") + + assert tag == "macosx_11_0_x86_64" + warning = capsys.readouterr().err + assert expected_form in warning From caa78fa64474d74747baf57ea5071f76dc4ada6f Mon Sep 17 00:00:00 2001 From: Nikolaus Schuetz Date: Thu, 13 Aug 2026 15:51:18 -0400 Subject: [PATCH 2/4] Give the joined file list a distinct variable name Per review: keep problematic_files as the list and name the joined string separately, rather than rebinding the variable's type. --- src/wheel/macosx_libfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wheel/macosx_libfile.py b/src/wheel/macosx_libfile.py index df69e50a..fb857f4f 100644 --- a/src/wheel/macosx_libfile.py +++ b/src/wheel/macosx_libfile.py @@ -460,7 +460,7 @@ def calculate_macosx_platform_tag(archive_root: StrPath, platform_tag: str) -> s files_form = "this file" else: files_form = "these files" - problematic_files = "\n".join(problematic_files) + problematic_files_text = "\n".join(problematic_files) error_message = ( "[WARNING] This wheel needs a higher macOS version than {} " "To silence this warning, set MACOSX_DEPLOYMENT_TARGET to at least " @@ -468,7 +468,7 @@ def calculate_macosx_platform_tag(archive_root: StrPath, platform_tag: str) -> s + " or recreate " + files_form + " with lower " - "MACOSX_DEPLOYMENT_TARGET: \n" + problematic_files + "MACOSX_DEPLOYMENT_TARGET: \n" + problematic_files_text ) if "MACOSX_DEPLOYMENT_TARGET" in os.environ: From a0cc6682ab83972f497e37ba04724bac71f67225 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Thu, 13 Aug 2026 23:55:39 +0300 Subject: [PATCH 3/4] Prefer touch() to write_bytes(b"") Replace writing empty bytes to touching the file. --- tests/test_macosx_libfile.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_macosx_libfile.py b/tests/test_macosx_libfile.py index 64a4e57b..2fecf6b1 100644 --- a/tests/test_macosx_libfile.py +++ b/tests/test_macosx_libfile.py @@ -23,8 +23,7 @@ def test_calculate_macosx_platform_tag_files_form( expected_form: str, ) -> None: for index in range(dylib_count): - tmp_path.joinpath(f"lib{index}.dylib").write_bytes(b"") - + tmp_path.joinpath(f"lib{index}.dylib").touch() monkeypatch.setattr( macosx_libfile, "extract_macosx_min_system_version", From 7c058a0b637d7ce24c6ad646a1ad15773d4ecc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Thu, 13 Aug 2026 23:56:06 +0300 Subject: [PATCH 4/4] Restored blank line --- tests/test_macosx_libfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_macosx_libfile.py b/tests/test_macosx_libfile.py index 2fecf6b1..568df1fe 100644 --- a/tests/test_macosx_libfile.py +++ b/tests/test_macosx_libfile.py @@ -24,6 +24,7 @@ def test_calculate_macosx_platform_tag_files_form( ) -> None: for index in range(dylib_count): tmp_path.joinpath(f"lib{index}.dylib").touch() + monkeypatch.setattr( macosx_libfile, "extract_macosx_min_system_version",