Customise merge behaviour depending on option. Fix #1803 (#1984)

Fix for #1803, where the method used for merging the config-settings option - string concatenation - was of little use.

I broke out the TableFmt object into a protocol-like object called OptionFormat, where the formatting and merge rules can be customised more deeply. This is more explicit, and lets us be a bit more precise with how TOML object get converted into the options.

I intend to use the flexibility of the OptionsFormat structure to tackle the remaining abiguity around environment variable quoting, as seen in the xfails in the options_test.py unit test and discussed in #1271.


Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com>
This commit is contained in:
Joe Rickerby
2024-09-03 16:05:00 +01:00
committed by GitHub
co-authored by Matthieu Darbois
parent 229029e112
commit ca08f5fbcf
3 changed files with 251 additions and 148 deletions
+1 -2
View File
@@ -10,7 +10,6 @@ import pytest
from cibuildwheel import errors
from cibuildwheel.__main__ import get_build_identifiers, get_platform_module
from cibuildwheel.bashlex_eval import local_environment_executor
from cibuildwheel.environment import parse_environment
from cibuildwheel.options import (
CommandLineArguments,
Options,
@@ -66,7 +65,7 @@ def test_options_1(tmp_path, monkeypatch):
default_build_options = options.build_options(identifier=None)
assert default_build_options.environment == parse_environment('FOO="BAR"')
assert default_build_options.environment.as_dictionary(prev_environment={}) == {"FOO": "BAR"}
all_pinned_container_images = _get_pinned_container_images()
pinned_x86_64_container_image = all_pinned_container_images["x86_64"]