From 7247e3887c10a6803d6e6bd300a967ceeb5be767 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 16 Jul 2025 15:00:49 -0700 Subject: [PATCH] fix: show options for --only (#2499) Signed-off-by: Henry Schreiner --- cibuildwheel/__main__.py | 3 +++ cibuildwheel/util/resources.py | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 7585ca83..60849857 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -26,6 +26,7 @@ from cibuildwheel.selector import BuildSelector, EnableGroup, selector_matches from cibuildwheel.typing import PLATFORMS, PlatformName from cibuildwheel.util.file import CIBW_CACHE_PATH from cibuildwheel.util.helpers import strtobool +from cibuildwheel.util.resources import read_all_configs @dataclasses.dataclass @@ -132,6 +133,8 @@ def main_inner(global_options: GlobalOptions) -> None: parser.add_argument( "--only", default=None, + choices=[v["identifier"] for vv in read_all_configs().values() for v in vv], + metavar="IDENTIFIER", help=""" Force a single wheel build when given an identifier. Overrides CIBW_BUILD/CIBW_SKIP. --platform and --arch cannot be specified diff --git a/cibuildwheel/util/resources.py b/cibuildwheel/util/resources.py index 0cb09a26..4be747a9 100644 --- a/cibuildwheel/util/resources.py +++ b/cibuildwheel/util/resources.py @@ -22,8 +22,11 @@ TEST_FAIL_CWD_FILE: Final[Path] = PATH / "testing_temp_dir_file.py" # this value is cached because it's used a lot in unit tests @functools.cache -def read_python_configs(config: PlatformName) -> list[dict[str, str]]: +def read_all_configs() -> dict[str, list[dict[str, str]]]: with BUILD_PLATFORMS.open("rb") as f: loaded_file = tomllib.load(f) - results: list[dict[str, str]] = list(loaded_file[config]["python_configurations"]) - return results + return {k: list[dict[str, str]](v["python_configurations"]) for k, v in loaded_file.items()} + + +def read_python_configs(config: PlatformName) -> list[dict[str, str]]: + return read_all_configs()[config]