From 93b8dfeb4783ed19b88a2d2c2626e7a303af3fa2 Mon Sep 17 00:00:00 2001
From: Kyle Gottfried <6462596+Spitfire1900@users.noreply.github.com>
Date: Sat, 4 Jan 2025 11:26:08 -0500
Subject: [PATCH 1/9] build macos wheel on 10.15

---
 .github/workflows/wheels.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml
index f993a5d2..5bce533f 100644
--- a/.github/workflows/wheels.yml
+++ b/.github/workflows/wheels.yml
@@ -17,7 +17,7 @@ jobs:
         - name: linux
           os: ubuntu-24.04
         - name: macos
-          os: macos-13
+          os: macos-15
 
     steps:
       - uses: actions/checkout@v4

From 004c0da8ec7dedd4355a618c40a08aa04d2ed386 Mon Sep 17 00:00:00 2001
From: Kyle Gottfried <6462596+Spitfire1900@users.noreply.github.com>
Date: Sat, 4 Jan 2025 11:26:25 -0500
Subject: [PATCH 2/9] build wheel on pypy-wheel-macos branch

---
 .github/workflows/wheels.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml
index 5bce533f..533fb45d 100644
--- a/.github/workflows/wheels.yml
+++ b/.github/workflows/wheels.yml
@@ -4,6 +4,7 @@ on:
   push:
     branches:
     - master
+    - pypy-wheel-macos
     tags:
     - 'v*'
 

From 5fc755fa9a47d941b73d4953394954585d041c08 Mon Sep 17 00:00:00 2001
From: Kyle Gottfried <6462596+Spitfire1900@users.noreply.github.com>
Date: Sat, 4 Jan 2025 11:54:44 -0500
Subject: [PATCH 3/9] Update pyproject.toml - do not build a universal wheel

---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index 20a14e65..9c0577bf 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -20,7 +20,7 @@ select = "*-musllinux*"
 repair-wheel-command = "LD_LIBRARY_PATH=/project/ci/lib auditwheel repair -w {dest_dir} {wheel}"
 
 [tool.cibuildwheel.macos]
-archs = ["universal2"]
+archs = ["x86_64", "arm64"]
 environment = {LIBGIT2_VERSION="1.9.0", LIBSSH2_VERSION="1.11.1", OPENSSL_VERSION="3.2.3", LIBGIT2="/Users/runner/work/pygit2/pygit2/ci"}
 repair-wheel-command = "DYLD_LIBRARY_PATH=/Users/runner/work/pygit2/pygit2/ci/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}"
 

From 576e1b1288012c7d5df63e90b177a6244e06347c Mon Sep 17 00:00:00 2001
From: Kyle Gottfried <6462596+Spitfire1900@users.noreply.github.com>
Date: Sat, 4 Jan 2025 12:10:31 -0500
Subject: [PATCH 4/9] Revert "Update pyproject.toml - do not build a universal
 wheel"

This reverts commit 5fc755fa9a47d941b73d4953394954585d041c08.
---
 pyproject.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index 9c0577bf..20a14e65 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -20,7 +20,7 @@ select = "*-musllinux*"
 repair-wheel-command = "LD_LIBRARY_PATH=/project/ci/lib auditwheel repair -w {dest_dir} {wheel}"
 
 [tool.cibuildwheel.macos]
-archs = ["x86_64", "arm64"]
+archs = ["universal2"]
 environment = {LIBGIT2_VERSION="1.9.0", LIBSSH2_VERSION="1.11.1", OPENSSL_VERSION="3.2.3", LIBGIT2="/Users/runner/work/pygit2/pygit2/ci"}
 repair-wheel-command = "DYLD_LIBRARY_PATH=/Users/runner/work/pygit2/pygit2/ci/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}"
 

From dfbd63e4902b97a739f997daf03acdde50560f42 Mon Sep 17 00:00:00 2001
From: Kyle Gottfried <6462596+Spitfire1900@users.noreply.github.com>
Date: Sat, 4 Jan 2025 16:07:41 -0500
Subject: [PATCH 5/9] Update pyproject.toml - attempt to force zlib bundling

---
 pyproject.toml | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/pyproject.toml b/pyproject.toml
index 20a14e65..fcac721a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,9 +21,17 @@ repair-wheel-command = "LD_LIBRARY_PATH=/project/ci/lib auditwheel repair -w {de
 
 [tool.cibuildwheel.macos]
 archs = ["universal2"]
-environment = {LIBGIT2_VERSION="1.9.0", LIBSSH2_VERSION="1.11.1", OPENSSL_VERSION="3.2.3", LIBGIT2="/Users/runner/work/pygit2/pygit2/ci"}
 repair-wheel-command = "DYLD_LIBRARY_PATH=/Users/runner/work/pygit2/pygit2/ci/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}"
 
+[tool.cibuildwheel.macos.environment]
+LIBGIT2_VERSION = "1.9.0"
+LIBSSH2_VERSION = "1.11.1"
+OPENSSL_VERSION = "3.2.3"
+LIBGIT2 = "/Users/runner/work/pygit2/pygit2/ci"
+CFLAGS = "-I/usr/local/include"
+LDFLAGS = "-L/usr/local/lib"
+LDFLAGS_UNIVERSAL2 = "-lz" 
+
 [tool.ruff]
 target-version = "py310"  # oldest supported Python version
 fix = true

From 7f935511d05e6f78780dac5a01058cb9f2271199 Mon Sep 17 00:00:00 2001
From: Kyle Gottfried <6462596+Spitfire1900@users.noreply.github.com>
Date: Sat, 4 Jan 2025 18:08:36 -0500
Subject: [PATCH 6/9] attempt to force zlib bundling with LDFLAGS

---
 pyproject.toml | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index fcac721a..a0aec646 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -29,8 +29,7 @@ LIBSSH2_VERSION = "1.11.1"
 OPENSSL_VERSION = "3.2.3"
 LIBGIT2 = "/Users/runner/work/pygit2/pygit2/ci"
 CFLAGS = "-I/usr/local/include"
-LDFLAGS = "-L/usr/local/lib"
-LDFLAGS_UNIVERSAL2 = "-lz" 
+LDFLAGS = "-L/usr/local/lib -lz"
 
 [tool.ruff]
 target-version = "py310"  # oldest supported Python version

From cfd52a3f615122d0875abb5948054a01a2b4b439 Mon Sep 17 00:00:00 2001
From: Kyle Gottfried <6462596+Spitfire1900@users.noreply.github.com>
Date: Sat, 4 Jan 2025 22:05:26 -0500
Subject: [PATCH 7/9] use bundled zlib

---
 build.sh | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/build.sh b/build.sh
index 646e46a1..8a4edb54 100644
--- a/build.sh
+++ b/build.sh
@@ -85,19 +85,6 @@ else
     cd ci
 fi
 
-# Install zlib
-# XXX Build libgit2 with USE_BUNDLED_ZLIB instead?
-if [ -n "$ZLIB_VERSION" ]; then
-    FILENAME=zlib-$ZLIB_VERSION
-    wget https://www.zlib.net/$FILENAME.tar.gz -N
-    tar xf $FILENAME.tar.gz
-    cd $FILENAME
-    ./configure --prefix=$PREFIX
-    make
-    make install
-    cd ..
-fi
-
 # Install openssl
 if [ -n "$OPENSSL_VERSION" ]; then
     FILENAME=openssl-$OPENSSL_VERSION
@@ -189,6 +176,7 @@ if [ -n "$LIBGIT2_VERSION" ]; then
                 -DOPENSSL_SSL_LIBRARY="../openssl-universal/$LIBSSL" \
                 -DOPENSSL_INCLUDE_DIR="../openssl-x86/include" \
                 -DCMAKE_INSTALL_PREFIX=$PREFIX \
+                -DUSE_BUNDLED_ZLIB=ON \
                 -DUSE_SSH=$USE_SSH
     else
         export CFLAGS=-I$PREFIX/include
@@ -197,6 +185,7 @@ if [ -n "$LIBGIT2_VERSION" ]; then
                 -DBUILD_TESTS=OFF \
                 -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
                 -DCMAKE_INSTALL_PREFIX=$PREFIX \
+                -DUSE_BUNDLED_ZLIB=ON \
                 -DUSE_SSH=$USE_SSH
     fi
     cmake --build . --target install

From d3b28f67c0558d62822ba6d2769cd5158908be05 Mon Sep 17 00:00:00 2001
From: Kyle Gottfried <6462596+Spitfire1900@users.noreply.github.com>
Date: Sat, 4 Jan 2025 22:06:12 -0500
Subject: [PATCH 8/9] revert pyproject.toml to master version

---
 pyproject.toml | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index a0aec646..20a14e65 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -21,16 +21,9 @@ repair-wheel-command = "LD_LIBRARY_PATH=/project/ci/lib auditwheel repair -w {de
 
 [tool.cibuildwheel.macos]
 archs = ["universal2"]
+environment = {LIBGIT2_VERSION="1.9.0", LIBSSH2_VERSION="1.11.1", OPENSSL_VERSION="3.2.3", LIBGIT2="/Users/runner/work/pygit2/pygit2/ci"}
 repair-wheel-command = "DYLD_LIBRARY_PATH=/Users/runner/work/pygit2/pygit2/ci/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}"
 
-[tool.cibuildwheel.macos.environment]
-LIBGIT2_VERSION = "1.9.0"
-LIBSSH2_VERSION = "1.11.1"
-OPENSSL_VERSION = "3.2.3"
-LIBGIT2 = "/Users/runner/work/pygit2/pygit2/ci"
-CFLAGS = "-I/usr/local/include"
-LDFLAGS = "-L/usr/local/lib -lz"
-
 [tool.ruff]
 target-version = "py310"  # oldest supported Python version
 fix = true

From 2f38d53bfe799805e1c816646abf9403b739adbb Mon Sep 17 00:00:00 2001
From: Kyle Gottfried <6462596+Spitfire1900@users.noreply.github.com>
Date: Sun, 5 Jan 2025 10:20:13 -0500
Subject: [PATCH 9/9] cibuildwheel==2.22.0

(cherry picked from commit 8285741b979a591a360ba028bce62908bfe4cf6c)
---
 .github/workflows/wheels.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml
index 533fb45d..ee6bde4b 100644
--- a/.github/workflows/wheels.yml
+++ b/.github/workflows/wheels.yml
@@ -33,7 +33,7 @@ jobs:
           platforms: all
 
       - name: Install cibuildwheel
-        run: python -m pip install cibuildwheel==2.21.3
+        run: python -m pip install cibuildwheel==2.22.0
 
       - name: Build wheels
         run: python -m cibuildwheel --output-dir wheelhouse