]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Build MacOS binary packages
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Mon, 28 Jun 2021 13:07:34 +0000 (14:07 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Wed, 30 Jun 2021 00:48:41 +0000 (01:48 +0100)
.github/workflows/packages.yml
tools/build/wheel_macos_before_all.sh [new file with mode: 0755]

index 62fc1fb20890566a1b2479a548d9bb348a04c609..561cd0f19489017ce920a3728dbdad8363f62485 100644 (file)
@@ -58,3 +58,36 @@ jobs:
           --health-interval 10s
           --health-timeout 5s
           --health-retries 5
+
+  build_macos:
+    name: Build MacOS packages
+    runs-on: macos-10.15
+    strategy:
+      matrix:
+        pyver: [cp36, cp37, cp38, cp39]
+        arch: [x86_64]
+        # These archs require an Apple M1 runner: [arm64, universal2]
+
+    steps:
+      - uses: actions/checkout@v2
+
+      - name: Create the binary package source tree
+        run: python3 ./tools/build/copy_to_binary.py
+
+      - name: Build wheels
+        uses: pypa/cibuildwheel@v1.12.0
+        with:
+          package-dir: psycopg_binary
+        env:
+          CIBW_BUILD: ${{matrix.pyver}}-macosx_${{matrix.arch}}
+          CIBW_ARCHS_MACOS: x86_64 arm64 universal2
+          CIBW_BEFORE_ALL_MACOS: ./tools/build/wheel_macos_before_all.sh
+          CIBW_BEFORE_TEST: pip install ./psycopg[test]
+          CIBW_TEST_COMMAND: pytest {project}/tests -m 'not slow' --color yes
+          CIBW_ENVIRONMENT: >-
+            PSYCOPG_IMPL=binary
+            PSYCOPG_TEST_DSN='dbname=postgres'
+
+      - uses: actions/upload-artifact@v2
+        with:
+          path: ./wheelhouse/*.whl
diff --git a/tools/build/wheel_macos_before_all.sh b/tools/build/wheel_macos_before_all.sh
new file mode 100755 (executable)
index 0000000..f8b0d7c
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# Configure the environment needed to build wheel packages on Mac OS.
+# This script is designed to be used by cibuildwheel as CIBW_BEFORE_ALL_MACOS
+
+set -euo pipefail
+set -x
+
+dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+brew install gnu-sed postgresql@13
+
+# Start the database for testing
+brew services start postgresql
+
+# Wait for postgres to come up
+for i in $(seq 10 -1 0); do
+  eval pg_isready && break
+  if [ $i == 0 ]; then
+      echo "PostgreSQL service not ready, giving up"
+      exit 1
+  fi
+  echo "PostgreSQL service not ready, waiting a bit, attempts left: $i"
+  sleep 5
+done