diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 2693f4f3d..7750f6f2d 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -586,10 +586,20 @@ def build(options: Options, tmp_path: Path) -> None: env=virtualenv_env, ) + # setting virtualenv_env used for pip install wheel + # set SYSTEM_VERSION_COMPAT=0 to ensure x86_64 cp38 python on + # arm64 runner can get correct macos version and allow installation + # of wheels with MACOSX_DEPLOYMENT_TARGET >= 11.0 + # https://github.com/pypa/cibuildwheel/issues/1767 + virtualenv_env_install_wheel = virtualenv_env.copy() + virtualenv_env_install_wheel["SYSTEM_VERSION_COMPAT"] = 0 + # test the wheel if build_options.test_requires: call_with_arch( - "pip", "install", *build_options.test_requires, env=virtualenv_env + "pip", "install", + *build_options.test_requires, + env=virtualenv_env_install_wheel ) # run the tests from a temp dir, with an absolute path in the command