From 69c89100501bc0d8cf36b3d84b5b92311b81d6d4 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 20:46:07 -0700 Subject: [PATCH 01/13] Attempt to fix arm wheels on macOS by toggling hatch settings --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 8c55076e4c9..1a23b4b7490 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,6 +113,7 @@ exclude = ["/profiling"] [tool.hatch.build.targets.wheel] only-include = ["src"] sources = ["src"] +macos-max-compat = false [tool.hatch.build.targets.wheel.hooks.mypyc] enable-by-default = false From 33800981e929d0d51ac4a484dd177b0470d230ec Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 20:48:04 -0700 Subject: [PATCH 02/13] tmp macos --- .github/workflows/pypi_upload.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pypi_upload.yml b/.github/workflows/pypi_upload.yml index a57013d67c1..b29b7cc8122 100644 --- a/.github/workflows/pypi_upload.yml +++ b/.github/workflows/pypi_upload.yml @@ -68,9 +68,12 @@ jobs: - name: generate matrix (PR) if: github.event_name == 'pull_request' run: | - cibuildwheel --print-build-identifiers --platform linux \ - | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \ - | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix + { + cibuildwheel --print-build-identifiers --platform linux \ + | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \ + && cibuildwheel --print-build-identifiers --platform macos \ + | pyp 'json.dumps({"only": x, "os": "macos-latest"})' + } | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix env: CIBW_BUILD: "cp38-* cp311-*" CIBW_ARCHS_LINUX: x86_64 From b7cb82006c355d7d94cf9edb2cb727f306d59e54 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 21:04:44 -0700 Subject: [PATCH 03/13] no thanks --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1a23b4b7490..4b5683cffcc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -167,6 +167,8 @@ MYPYC_DEBUG_LEVEL = "0" # from source also doesn't work. AIOHTTP_NO_EXTENSIONS = "1" +MACOSX_DEPLOYMENT_TARGET = """$(python -c 'import sysconfig; print(sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET"))')""" + [tool.cibuildwheel.linux] before-build = [ "yum install -y clang gcc", @@ -176,9 +178,10 @@ before-build = [ HATCH_BUILD_HOOKS_ENABLE = "1" MYPYC_OPT_LEVEL = "3" MYPYC_DEBUG_LEVEL = "0" +AIOHTTP_NO_EXTENSIONS = "1" + # Black needs Clang to compile successfully on Linux. CC = "clang" -AIOHTTP_NO_EXTENSIONS = "1" [tool.isort] atomic = true From fcc91fe45a2326c22ab5cc21d5ce6675056e019d Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 21:41:23 -0700 Subject: [PATCH 04/13] work around hatch's inner platform --- pyproject.toml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 4b5683cffcc..3bcf3dcb97c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -183,6 +183,13 @@ AIOHTTP_NO_EXTENSIONS = "1" # Black needs Clang to compile successfully on Linux. CC = "clang" +[tool.cibuildwheel.macos] +build-frontend = { name = "build", args = ["--no-build-isolation"] } +before-build = [ + "python -m pip install 'hatchling==1.18.0' hatch-vcs hatch-fancy-pypi-readme", + """sed -i '' -e "600,700s/10_16/11_0/" $(python -c 'import hatchling.builders.wheel as h; print(h.__file__)') """, +] + [tool.isort] atomic = true profile = "black" From 75bd6e7671d8f611d5d2a6616f7dc50a8b757db5 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 21:46:03 -0700 Subject: [PATCH 05/13] . --- .github/workflows/pypi_upload.yml | 5 ++--- pyproject.toml | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pypi_upload.yml b/.github/workflows/pypi_upload.yml index b29b7cc8122..4018a8c38c8 100644 --- a/.github/workflows/pypi_upload.yml +++ b/.github/workflows/pypi_upload.yml @@ -69,13 +69,12 @@ jobs: if: github.event_name == 'pull_request' run: | { - cibuildwheel --print-build-identifiers --platform linux \ + CIBW_BUILD="cp38-* cp311-*" cibuildwheel --print-build-identifiers --platform linux \ | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \ - && cibuildwheel --print-build-identifiers --platform macos \ + && CIBW_BUILD="cp38-*" cibuildwheel --print-build-identifiers --platform macos \ | pyp 'json.dumps({"only": x, "os": "macos-latest"})' } | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix env: - CIBW_BUILD: "cp38-* cp311-*" CIBW_ARCHS_LINUX: x86_64 - id: set-matrix run: echo "include=$(cat /tmp/matrix)" | tee -a $GITHUB_OUTPUT diff --git a/pyproject.toml b/pyproject.toml index 3bcf3dcb97c..57a2a95f31e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -167,8 +167,6 @@ MYPYC_DEBUG_LEVEL = "0" # from source also doesn't work. AIOHTTP_NO_EXTENSIONS = "1" -MACOSX_DEPLOYMENT_TARGET = """$(python -c 'import sysconfig; print(sysconfig.get_config_var("MACOSX_DEPLOYMENT_TARGET"))')""" - [tool.cibuildwheel.linux] before-build = [ "yum install -y clang gcc", @@ -184,7 +182,8 @@ AIOHTTP_NO_EXTENSIONS = "1" CC = "clang" [tool.cibuildwheel.macos] -build-frontend = { name = "build", args = ["--no-build-isolation"] } +build-frontend = { name = "build", args = ["--no-isolation"] } +# Unfortunately, hatch doesn't respect MACOSX_DEPLOYMENT_TARGET before-build = [ "python -m pip install 'hatchling==1.18.0' hatch-vcs hatch-fancy-pypi-readme", """sed -i '' -e "600,700s/10_16/11_0/" $(python -c 'import hatchling.builders.wheel as h; print(h.__file__)') """, From 757430b84aad379f5e8fdf10a40f4d63ba0eb6a2 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 21:47:10 -0700 Subject: [PATCH 06/13] . --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 57a2a95f31e..e4b81964d07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,7 +113,7 @@ exclude = ["/profiling"] [tool.hatch.build.targets.wheel] only-include = ["src"] sources = ["src"] -macos-max-compat = false +macos-max-compat = true [tool.hatch.build.targets.wheel.hooks.mypyc] enable-by-default = false From 33073bf56bb2edc0369c21c3b58d37a076c490bd Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 21:50:01 -0700 Subject: [PATCH 07/13] . --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e4b81964d07..b547295fd24 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,6 +113,7 @@ exclude = ["/profiling"] [tool.hatch.build.targets.wheel] only-include = ["src"] sources = ["src"] +# Note that we change the behaviour of this flag below macos-max-compat = true [tool.hatch.build.targets.wheel.hooks.mypyc] @@ -185,7 +186,7 @@ CC = "clang" build-frontend = { name = "build", args = ["--no-isolation"] } # Unfortunately, hatch doesn't respect MACOSX_DEPLOYMENT_TARGET before-build = [ - "python -m pip install 'hatchling==1.18.0' hatch-vcs hatch-fancy-pypi-readme", + "python -m pip install 'hatchling==1.18.0' hatch-vcs hatch-fancy-pypi-readme 'hatch-mypyc>=0.16.0' 'mypy==1.5.1' 'click==8.1.3'", """sed -i '' -e "600,700s/10_16/11_0/" $(python -c 'import hatchling.builders.wheel as h; print(h.__file__)') """, ] From bdf41053b827798c72d4f5907db1fd8187db0fc4 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 22:00:11 -0700 Subject: [PATCH 08/13] . --- .github/workflows/pypi_upload.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pypi_upload.yml b/.github/workflows/pypi_upload.yml index 4018a8c38c8..09829433c7b 100644 --- a/.github/workflows/pypi_upload.yml +++ b/.github/workflows/pypi_upload.yml @@ -71,7 +71,7 @@ jobs: { CIBW_BUILD="cp38-* cp311-*" cibuildwheel --print-build-identifiers --platform linux \ | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \ - && CIBW_BUILD="cp38-*" cibuildwheel --print-build-identifiers --platform macos \ + && CIBW_BUILD="cp38-* cp311-*" cibuildwheel --print-build-identifiers --platform macos \ | pyp 'json.dumps({"only": x, "os": "macos-latest"})' } | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix env: diff --git a/pyproject.toml b/pyproject.toml index b547295fd24..3b12a6aaa36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -187,7 +187,7 @@ build-frontend = { name = "build", args = ["--no-isolation"] } # Unfortunately, hatch doesn't respect MACOSX_DEPLOYMENT_TARGET before-build = [ "python -m pip install 'hatchling==1.18.0' hatch-vcs hatch-fancy-pypi-readme 'hatch-mypyc>=0.16.0' 'mypy==1.5.1' 'click==8.1.3'", - """sed -i '' -e "600,700s/10_16/11_0/" $(python -c 'import hatchling.builders.wheel as h; print(h.__file__)') """, + """sed -i '' -e "600,700s/'10_16'/'11_0' if 'arm64' in archs else '10_16'/" $(python -c 'import hatchling.builders.wheel as h; print(h.__file__)') """, ] [tool.isort] From e7f14d77fdc45ab5a810819501c2c01e90f550e4 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 22:24:43 -0700 Subject: [PATCH 09/13] . --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 3b12a6aaa36..7558cad2d4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -187,7 +187,7 @@ build-frontend = { name = "build", args = ["--no-isolation"] } # Unfortunately, hatch doesn't respect MACOSX_DEPLOYMENT_TARGET before-build = [ "python -m pip install 'hatchling==1.18.0' hatch-vcs hatch-fancy-pypi-readme 'hatch-mypyc>=0.16.0' 'mypy==1.5.1' 'click==8.1.3'", - """sed -i '' -e "600,700s/'10_16'/'11_0' if 'arm64' in archs else '10_16'/" $(python -c 'import hatchling.builders.wheel as h; print(h.__file__)') """, + """sed -i '' -e "600,700s/'10_16'/os.environ['MACOSX_DEPLOYMENT_TARGET'].replace('.', '_')/" $(python -c 'import hatchling.builders.wheel as h; print(h.__file__)') """, ] [tool.isort] From 7650f6e40cdf1941fbf4f81dccbfe42ac2536c7b Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 23:20:33 -0700 Subject: [PATCH 10/13] . --- .github/workflows/pypi_upload.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pypi_upload.yml b/.github/workflows/pypi_upload.yml index 09829433c7b..e2784152b92 100644 --- a/.github/workflows/pypi_upload.yml +++ b/.github/workflows/pypi_upload.yml @@ -71,7 +71,7 @@ jobs: { CIBW_BUILD="cp38-* cp311-*" cibuildwheel --print-build-identifiers --platform linux \ | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \ - && CIBW_BUILD="cp38-* cp311-*" cibuildwheel --print-build-identifiers --platform macos \ + && CIBW_BUILD="cp38-* cp311-*" CIBW_ARCHS_MACOS="x86_64 arm64" cibuildwheel --print-build-identifiers --platform macos \ | pyp 'json.dumps({"only": x, "os": "macos-latest"})' } | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix env: From 05eb557b6a0994866e4e7dfa6e64e60a0eaffabb Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 23:31:09 -0700 Subject: [PATCH 11/13] changelog --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 5ce37943693..b7a08ea6f23 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,6 +37,7 @@ ### Performance +- Fix mypyc builds on arm64 on macOS (#4017) ### Output From 5f3e84d8436c7d7090dd047c2c2e3babd6489625 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 3 Nov 2023 06:31:37 +0000 Subject: [PATCH 12/13] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index b7a08ea6f23..97084a2bfc1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -37,6 +37,7 @@ ### Performance + - Fix mypyc builds on arm64 on macOS (#4017) ### Output From f6a3033bf528d902d271389382836d21b1d1c1ea Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Thu, 2 Nov 2023 23:33:10 -0700 Subject: [PATCH 13/13] . --- .github/workflows/pypi_upload.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pypi_upload.yml b/.github/workflows/pypi_upload.yml index e2784152b92..07273f09508 100644 --- a/.github/workflows/pypi_upload.yml +++ b/.github/workflows/pypi_upload.yml @@ -69,12 +69,11 @@ jobs: if: github.event_name == 'pull_request' run: | { - CIBW_BUILD="cp38-* cp311-*" cibuildwheel --print-build-identifiers --platform linux \ - | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' \ - && CIBW_BUILD="cp38-* cp311-*" CIBW_ARCHS_MACOS="x86_64 arm64" cibuildwheel --print-build-identifiers --platform macos \ - | pyp 'json.dumps({"only": x, "os": "macos-latest"})' + cibuildwheel --print-build-identifiers --platform linux \ + | pyp 'json.dumps({"only": x, "os": "ubuntu-latest"})' } | pyp 'json.dumps(list(map(json.loads, lines)))' > /tmp/matrix env: + CIBW_BUILD: "cp38-* cp311-*" CIBW_ARCHS_LINUX: x86_64 - id: set-matrix run: echo "include=$(cat /tmp/matrix)" | tee -a $GITHUB_OUTPUT