From be9a635f9bbc97d9baf63ec82e1d24cedf5e77f5 Mon Sep 17 00:00:00 2001 From: Paul McCarthy Date: Wed, 13 Apr 2022 10:47:00 +0100 Subject: [PATCH] fix: don't assume that any configurations are active --- cibuildwheel/macos.py | 21 +++++++++++---------- cibuildwheel/windows.py | 19 ++++++++++--------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index a5818612..839e2508 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -276,17 +276,18 @@ def build(options: Options, tmp_path: Path) -> None: ) try: - before_all_options_identifier = python_configurations[0].identifier - before_all_options = options.build_options(before_all_options_identifier) + if len(python_configurations) > 0: + before_all_options_identifier = python_configurations[0].identifier + before_all_options = options.build_options(before_all_options_identifier) - if before_all_options.before_all: - log.step("Running before_all...") - env = before_all_options.environment.as_dictionary(prev_environment=os.environ) - env.setdefault("MACOSX_DEPLOYMENT_TARGET", "10.9") - before_all_prepared = prepare_command( - before_all_options.before_all, project=".", package=before_all_options.package_dir - ) - shell(before_all_prepared, env=env) + if before_all_options.before_all: + log.step("Running before_all...") + env = before_all_options.environment.as_dictionary(prev_environment=os.environ) + env.setdefault("MACOSX_DEPLOYMENT_TARGET", "10.9") + before_all_prepared = prepare_command( + before_all_options.before_all, project=".", package=before_all_options.package_dir + ) + shell(before_all_prepared, env=env) for config in python_configurations: build_options = options.build_options(config.identifier) diff --git a/cibuildwheel/windows.py b/cibuildwheel/windows.py index 86d01fa8..874445fa 100644 --- a/cibuildwheel/windows.py +++ b/cibuildwheel/windows.py @@ -235,16 +235,17 @@ def build(options: Options, tmp_path: Path) -> None: ) try: - before_all_options_identifier = python_configurations[0].identifier - before_all_options = options.build_options(before_all_options_identifier) + if len(python_configurations) > 0: + before_all_options_identifier = python_configurations[0].identifier + before_all_options = options.build_options(before_all_options_identifier) - if before_all_options.before_all: - log.step("Running before_all...") - env = before_all_options.environment.as_dictionary(prev_environment=os.environ) - before_all_prepared = prepare_command( - before_all_options.before_all, project=".", package=options.globals.package_dir - ) - shell(before_all_prepared, env=env) + if before_all_options.before_all: + log.step("Running before_all...") + env = before_all_options.environment.as_dictionary(prev_environment=os.environ) + before_all_prepared = prepare_command( + before_all_options.before_all, project=".", package=options.globals.package_dir + ) + shell(before_all_prepared, env=env) for config in python_configurations: build_options = options.build_options(config.identifier)