From c6818608d23a2f54b26e48b22c28fceb40ce2c57 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 10 Mar 2023 12:00:51 -0500 Subject: [PATCH 1/2] fix: pip config options were broken Signed-off-by: Henry Schreiner --- cibuildwheel/linux.py | 4 +++- cibuildwheel/macos.py | 4 +++- cibuildwheel/util.py | 5 +++-- cibuildwheel/windows.py | 4 +++- unit_test/main_tests/main_options_test.py | 8 +++++++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index acf00667c..5cc19bf55 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -240,7 +240,9 @@ def build_in_container( container.call(["mkdir", "-p", built_wheel_dir]) verbosity_flags = get_build_verbosity_extra_flags(build_options.build_verbosity) - extra_flags = split_config_settings(build_options.config_settings) + extra_flags = split_config_settings( + build_options.config_settings, plural=build_options.build_frontend == "pip" + ) if build_options.build_frontend == "pip": extra_flags += verbosity_flags diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index a94caa66c..49068ab89 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -374,7 +374,9 @@ def build(options: Options, tmp_path: Path) -> None: built_wheel_dir.mkdir() verbosity_flags = get_build_verbosity_extra_flags(build_options.build_verbosity) - extra_flags = split_config_settings(build_options.config_settings) + extra_flags = split_config_settings( + build_options.config_settings, plural=build_options.build_frontend == "pip" + ) if build_options.build_frontend == "pip": extra_flags += verbosity_flags diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index c0af81823..f217af081 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -208,9 +208,10 @@ def get_build_verbosity_extra_flags(level: int) -> list[str]: return [] -def split_config_settings(config_settings: str) -> list[str]: +def split_config_settings(config_settings: str, *, plural: bool) -> list[str]: config_settings_list = shlex.split(config_settings) - return [f"--config-setting={setting}" for setting in config_settings_list] + s = "s" if plural else "" + return [f"--config-setting{s}={setting}" for setting in config_settings_list] def read_python_configs(config: PlatformName) -> list[dict[str, str]]: diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 9182f0461..3eeee294d 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -411,7 +411,9 @@ def build(options: Options, tmp_path: Path) -> None: built_wheel_dir.mkdir() verbosity_flags = get_build_verbosity_extra_flags(build_options.build_verbosity) - extra_flags = split_config_settings(build_options.config_settings) + extra_flags = split_config_settings( + build_options.config_settings, plural=build_options.build_frontend == "pip" + ) if build_options.build_frontend == "pip": extra_flags += verbosity_flags diff --git a/unit_test/main_tests/main_options_test.py b/unit_test/main_tests/main_options_test.py index 80f446a06..ec9b0725d 100644 --- a/unit_test/main_tests/main_options_test.py +++ b/unit_test/main_tests/main_options_test.py @@ -283,12 +283,18 @@ def test_config_settings(platform_specific, platform, intercepted_build_args, mo assert build_options.config_settings == config_settings - assert split_config_settings(config_settings) == [ + assert split_config_settings(config_settings, plural=False) == [ "--config-setting=setting=value", "--config-setting=setting=value2", "--config-setting=other=something else", ] + assert split_config_settings(config_settings, plural=True) == [ + "--config-settings=setting=value", + "--config-settings=setting=value2", + "--config-settings=other=something else", + ] + @pytest.mark.parametrize( "selector", From 2e48667e29fa128d96738dd6bb585aaab232b580 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 10 Mar 2023 13:46:42 -0500 Subject: [PATCH 2/2] refactor: use frontend instead of plural Signed-off-by: Henry Schreiner --- cibuildwheel/linux.py | 2 +- cibuildwheel/macos.py | 2 +- cibuildwheel/util.py | 4 ++-- cibuildwheel/windows.py | 2 +- unit_test/main_tests/main_options_test.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cibuildwheel/linux.py b/cibuildwheel/linux.py index 5cc19bf55..f5d8710e1 100644 --- a/cibuildwheel/linux.py +++ b/cibuildwheel/linux.py @@ -241,7 +241,7 @@ def build_in_container( verbosity_flags = get_build_verbosity_extra_flags(build_options.build_verbosity) extra_flags = split_config_settings( - build_options.config_settings, plural=build_options.build_frontend == "pip" + build_options.config_settings, build_options.build_frontend ) if build_options.build_frontend == "pip": diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 49068ab89..3bb1324db 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -375,7 +375,7 @@ def build(options: Options, tmp_path: Path) -> None: verbosity_flags = get_build_verbosity_extra_flags(build_options.build_verbosity) extra_flags = split_config_settings( - build_options.config_settings, plural=build_options.build_frontend == "pip" + build_options.config_settings, build_options.build_frontend ) if build_options.build_frontend == "pip": diff --git a/cibuildwheel/util.py b/cibuildwheel/util.py index f217af081..72cff3260 100644 --- a/cibuildwheel/util.py +++ b/cibuildwheel/util.py @@ -208,9 +208,9 @@ def get_build_verbosity_extra_flags(level: int) -> list[str]: return [] -def split_config_settings(config_settings: str, *, plural: bool) -> list[str]: +def split_config_settings(config_settings: str, frontend: Literal["pip", "build"]) -> list[str]: config_settings_list = shlex.split(config_settings) - s = "s" if plural else "" + s = "s" if frontend == "pip" else "" return [f"--config-setting{s}={setting}" for setting in config_settings_list] diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 3eeee294d..cb83a324b 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -412,7 +412,7 @@ def build(options: Options, tmp_path: Path) -> None: verbosity_flags = get_build_verbosity_extra_flags(build_options.build_verbosity) extra_flags = split_config_settings( - build_options.config_settings, plural=build_options.build_frontend == "pip" + build_options.config_settings, build_options.build_frontend ) if build_options.build_frontend == "pip": diff --git a/unit_test/main_tests/main_options_test.py b/unit_test/main_tests/main_options_test.py index ec9b0725d..6cda8967b 100644 --- a/unit_test/main_tests/main_options_test.py +++ b/unit_test/main_tests/main_options_test.py @@ -283,13 +283,13 @@ def test_config_settings(platform_specific, platform, intercepted_build_args, mo assert build_options.config_settings == config_settings - assert split_config_settings(config_settings, plural=False) == [ + assert split_config_settings(config_settings, "build") == [ "--config-setting=setting=value", "--config-setting=setting=value2", "--config-setting=other=something else", ] - assert split_config_settings(config_settings, plural=True) == [ + assert split_config_settings(config_settings, "pip") == [ "--config-settings=setting=value", "--config-settings=setting=value2", "--config-settings=other=something else",