From e2a0839555d4d2ffd366ac4cd933262f5974fd10 Mon Sep 17 00:00:00 2001 From: laggykiller <61652821+laggykiller@users.noreply.github.com> Date: Mon, 11 Mar 2024 09:36:36 +0800 Subject: [PATCH] fix: set SYSTEM_VERSION_COMPAT=0 during pip install on macos (#1768) * Set SYSTEM_VERSION_COMPAT=0 during pip install on macos (#1767) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Only set SYSTEM_VERSION_COMPAT=0 for CPython 3.8 * Set SYSTEM_VERSION_COMPAT=0 for CPython <= 3.8 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update cibuildwheel/macos.py Co-authored-by: Joe Rickerby * Update cibuildwheel/macos.py Co-authored-by: Joe Rickerby * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Joe Rickerby --- cibuildwheel/macos.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/cibuildwheel/macos.py b/cibuildwheel/macos.py index 20aa3d940..d72d50427 100644 --- a/cibuildwheel/macos.py +++ b/cibuildwheel/macos.py @@ -583,17 +583,37 @@ def build(options: Options, tmp_path: Path) -> None: shell_with_arch(before_test_prepared, env=virtualenv_env) # install the wheel + if is_cp38 and python_arch == "x86_64": + virtualenv_env_install_wheel = virtualenv_env.copy() + virtualenv_env_install_wheel["SYSTEM_VERSION_COMPAT"] = "0" + log.notice( + unwrap( + """ + Setting SYSTEM_VERSION_COMPAT=0 to ensure CPython 3.8 can get + correct macOS version and allow installation of wheels with + MACOSX_DEPLOYMENT_TARGET >= 11.0. + See https://github.com/pypa/cibuildwheel/issues/1767 for the + details. + """ + ) + ) + else: + virtualenv_env_install_wheel = virtualenv_env + call_with_arch( "pip", "install", f"{repaired_wheel}{build_options.test_extras}", - env=virtualenv_env, + env=virtualenv_env_install_wheel, ) # 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