From aa6e89765f096e076369a8018b3e9ec643a2f72e Mon Sep 17 00:00:00 2001 From: Asher Foa Date: Thu, 8 Apr 2021 16:53:33 -0700 Subject: [PATCH] Add macOS workaround to build wheels step (#11864) ### Problem See: https://github.com/pantsbuild/pants/pull/11733 This issue now happens during wheel build: https://github.com/pantsbuild/pants/runs/2300092374?check_suite_focus=true#step:8:1129 ### Solution Apply the same solution that we use for running other things on macos to the build wheels job. --- .github/workflows/test.yaml | 4 +- .../bin/generate_github_workflows.py | 40 +++++++++++-------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 10244ea6752..92d3122a21f 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -340,7 +340,9 @@ jobs: restore-keys: '${{ runner.os }}-cargo-${{ hashFiles(''rust-toolchain'') }}- ' - - if: github.event_name == 'push' || !contains(env.COMMIT_MESSAGE, '[ci skip-build-wheels]') + - env: + ARCHFLAGS: -arch x86_64 + if: github.event_name == 'push' || !contains(env.COMMIT_MESSAGE, '[ci skip-build-wheels]') name: Build wheels and fs_util run: '[[ "${GITHUB_EVENT_NAME}" == "pull_request" ]] && export MODE=debug diff --git a/build-support/bin/generate_github_workflows.py b/build-support/bin/generate_github_workflows.py index 785ceba6655..2527dd237ed 100644 --- a/build-support/bin/generate_github_workflows.py +++ b/build-support/bin/generate_github_workflows.py @@ -235,6 +235,28 @@ def expose_all_pythons() -> Sequence[Step]: ] +def get_build_wheels_step(is_macos: bool) -> Step: + step = { + "name": "Build wheels and fs_util", + "run": dedent( + # We use MODE=debug on PR builds to speed things up, given that those are only + # smoke tests of our release process. + """\ + [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]] && export MODE=debug + ./build-support/bin/release.sh -n + USE_PY38=true ./build-support/bin/release.sh -n + ./build-support/bin/release.sh -f + """ + ), + "if": DONT_SKIP_WHEELS, + } + if is_macos: + # Works around bad `-arch arm64` flag embedded in Xcode 12.x Python interpreters on + # intel machines. See: https://github.com/giampaolo/psutil/issues/1832 + step["env"] = {"ARCHFLAGS": "-arch x86_64"} # type: ignore[assignment] + return step + + def test_workflow_jobs(primary_python_version: str, *, cron: bool) -> Jobs: jobs = { "bootstrap_pants_linux": { @@ -354,20 +376,6 @@ def test_workflow_jobs(primary_python_version: str, *, cron: bool) -> Jobs: }, } if not cron: - build_wheels_step = { - "name": "Build wheels and fs_util", - "run": dedent( - # We use MODE=debug on PR builds to speed things up, given that those are only - # smoke tests of our release process. - """\ - [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]] && export MODE=debug - ./build-support/bin/release.sh -n - USE_PY38=true ./build-support/bin/release.sh -n - ./build-support/bin/release.sh -f - """ - ), - "if": DONT_SKIP_WHEELS, - } deploy_to_s3_step = { "name": "Deploy to S3", "run": "./build-support/bin/deploy_to_s3.py", @@ -393,7 +401,7 @@ def test_workflow_jobs(primary_python_version: str, *, cron: bool) -> Jobs: '/opt/python/cp38-cp38/bin" >> $GITHUB_ENV' ), }, - build_wheels_step, + get_build_wheels_step(is_macos=False), deploy_to_s3_step, ], }, @@ -408,7 +416,7 @@ def test_workflow_jobs(primary_python_version: str, *, cron: bool) -> Jobs: # multiple Python versions, whereas that caching assumes only one primary # Python version (marked via matrix.strategy). *rust_caches(), - build_wheels_step, + get_build_wheels_step(is_macos=True), deploy_to_s3_step, ], },