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..fb857f4f 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_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: diff --git a/tests/test_macosx_libfile.py b/tests/test_macosx_libfile.py new file mode 100644 index 00000000..568df1fe --- /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").touch() + + 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