diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index 7585ca830..60849857a 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -26,6 +26,7 @@ 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 0cb09a26d..4be747a96 100644 --- a/cibuildwheel/util/resources.py +++ b/cibuildwheel/util/resources.py @@ -22,8 +22,11 @@ # 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]