Skip to content

Commit

Permalink
style: exit early to reduce indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldmccarthy committed Apr 19, 2022
1 parent 30627ae commit baf3ead
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
30 changes: 16 additions & 14 deletions cibuildwheel/macos.py
Expand Up @@ -275,21 +275,23 @@ def build(options: Options, tmp_path: Path) -> None:
options.globals.build_selector, options.globals.architectures
)

if len(python_configurations) == 0:
return

try:
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)
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)

for config in python_configurations:
build_options = options.build_options(config.identifier)
Expand Down
24 changes: 13 additions & 11 deletions cibuildwheel/windows.py
Expand Up @@ -234,18 +234,20 @@ def build(options: Options, tmp_path: Path) -> None:
options.globals.build_selector, options.globals.architectures
)

if len(python_configurations) == 0:
return

try:
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)
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)

for config in python_configurations:
build_options = options.build_options(config.identifier)
Expand Down

0 comments on commit baf3ead

Please sign in to comment.