diff --git a/cibuildwheel/__main__.py b/cibuildwheel/__main__.py index e171ab20..3040ccb6 100644 --- a/cibuildwheel/__main__.py +++ b/cibuildwheel/__main__.py @@ -118,7 +118,7 @@ def main() -> None: if platform == 'linux': repair_command_default = 'auditwheel repair -w {dest_dir} {wheel}' elif platform == 'macos': - repair_command_default = 'delocate-listdeps {wheel} && delocate-wheel --require-archs x86_64 -w {dest_dir} {wheel}' + repair_command_default = 'delocate-listdeps {wheel} && delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}' else: repair_command_default = '' diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 2af1cc8d..efa99a1a 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -250,7 +250,20 @@ def build(options: BuildOptions) -> None: if options.repair_command: log.step('Repairing wheel...') - repair_command_prepared = prepare_command(options.repair_command, wheel=built_wheel, dest_dir=repaired_wheel_dir) + + if config.identifier.endswith('universal2'): + delocate_archs = 'x86_64,arm64' + elif config.identifier.endswith('arm64'): + delocate_archs = 'arm64' + else: + delocate_archs = 'x86_64' + + repair_command_prepared = prepare_command( + options.repair_command, + wheel=built_wheel, + dest_dir=repaired_wheel_dir, + delocate_archs=delocate_archs, + ) call(repair_command_prepared, env=env, shell=True) else: shutil.move(str(built_wheel), repaired_wheel_dir) diff --git a/docs/options.md b/docs/options.md index 73c25b3b..ad976cd7 100644 --- a/docs/options.md +++ b/docs/options.md @@ -255,7 +255,7 @@ CIBW_BEFORE_BUILD: "{package}/bin/prepare_for_build.sh" Default: - on Linux: `'auditwheel repair -w {dest_dir} {wheel}'` -- on macOS: `'delocate-listdeps {wheel} && delocate-wheel --require-archs x86_64 -w {dest_dir} {wheel}'` +- on macOS: `'delocate-listdeps {wheel} && delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}'` - on Windows: `''` A shell command to repair a built wheel by copying external library dependencies into the wheel tree and relinking them. @@ -264,7 +264,8 @@ The command is run on each built wheel (except for pure Python ones) before test The following placeholders must be used inside the command and will be replaced by `cibuildwheel`: - `{wheel}` for the absolute path to the built wheel -- `{dest_dir}` for the absolute path of the directory where to create the repaired wheel. +- `{dest_dir}` for the absolute path of the directory where to create the repaired wheel +- `{delocate_archs}` (macOS only) comma-separated list of architectures in the wheel. The command is run in a shell, so you can run multiple commands like `cmd1 && cmd2`.