From 68c03665d3e9ad24035bc4765aba75a4408c8513 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Sun, 27 Jul 2025 21:58:03 +0200 Subject: [PATCH] feat: add deprecation warning for `cpython-experimental-riscv64` enable (#2526) --- cibuildwheel/__main__.py | 7 ++++ cibuildwheel/options.py | 2 +- unit_test/main_tests/main_options_test.py | 47 +++++++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 0d9914d2..2a4be883 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -417,6 +417,13 @@ def detect_warnings(*, options: Options) -> Generator[str, None, None]: build_selector = options.globals.build_selector test_selector = options.globals.test_selector + if EnableGroup.CPythonExperimentalRiscV64 in build_selector.enable: + yield ( + "'cpython-experimental-riscv64' enable is deprecated and will be removed in a future version. " + "It should be removed from tool.cibuildwheel.enable in pyproject.toml " + "or CIBW_ENABLE environment variable." + ) + all_valid_identifiers = [ config.identifier for module in ALL_PLATFORM_MODULES.values() diff --git a/cibuildwheel/options.py b/cibuildwheel/options.py index 00deb0f8..6bda5cef 100644 --- a/cibuildwheel/options.py +++ b/cibuildwheel/options.py @@ -665,7 +665,7 @@ class Options: build_config = args.only skip_config = "" architectures = Architecture.all_archs(self.platform) - enable = set(EnableGroup) + enable |= set(EnableGroup) - {EnableGroup.CPythonExperimentalRiscV64} build_selector = BuildSelector( build_config=build_config, diff --git a/unit_test/main_tests/main_options_test.py b/unit_test/main_tests/main_options_test.py index 7c8a6dde..c3889881 100644 --- a/unit_test/main_tests/main_options_test.py +++ b/unit_test/main_tests/main_options_test.py @@ -1,3 +1,4 @@ +import os import sys import tomllib from fnmatch import fnmatch @@ -141,6 +142,52 @@ def test_empty_selector(monkeypatch): assert e.value.code == 3 +@pytest.mark.usefixtures("platform", "intercepted_build_args") +def test_riscv64_warning1(monkeypatch, capsys): + monkeypatch.setenv("CIBW_ENABLE", "cpython-experimental-riscv64") + + main() + + _, err = capsys.readouterr() + print(err) + assert "'cpython-experimental-riscv64' enable is deprecated" in err + + +@pytest.mark.usefixtures("platform", "intercepted_build_args") +def test_riscv64_warning2(monkeypatch, capsys, tmp_path): + local_path = tmp_path / "tmp_project" + os.mkdir(local_path) # noqa:PTH102 Path.mkdir has been monkeypatched already + local_path.joinpath("setup.py").touch() + + monkeypatch.setattr( + sys, "argv", ["cibuildwheel", "--only", "cp313-manylinux_riscv64", str(local_path)] + ) + monkeypatch.setenv("CIBW_ENABLE", "cpython-experimental-riscv64") + + main() + + _, err = capsys.readouterr() + print(err) + assert "'cpython-experimental-riscv64' enable is deprecated" in err + + +@pytest.mark.usefixtures("platform", "intercepted_build_args") +def test_riscv64_no_warning(monkeypatch, capsys, tmp_path): + local_path = tmp_path / "tmp_project" + os.mkdir(local_path) # noqa:PTH102 Path.mkdir has been monkeypatched already + local_path.joinpath("setup.py").touch() + + monkeypatch.setattr( + sys, "argv", ["cibuildwheel", "--only", "cp313-manylinux_riscv64", str(local_path)] + ) + + main() + + _, err = capsys.readouterr() + print(err) + assert "'cpython-experimental-riscv64' enable is deprecated" not in err + + @pytest.mark.parametrize( ("architecture", "image", "full_image"), [