--- /dev/null
+name: Build packages
+
+on:
+ workflow_dispatch:
+
+jobs:
+ build_linux:
+ name: Build Linux packages
+ runs-on: ubuntu-20.04
+
+ strategy:
+ matrix:
+ pyver: [cp36, cp37, cp38, cp39]
+ arch: [x86_64, i686, ppc64le, aarch64]
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up QEMU for multi-arch build
+ uses: docker/setup-qemu-action@v1
+
+ - name: Create the binary package source tree
+ run: ./tools/build/copy_to_binary.sh
+
+ - name: Build wheels
+ uses: pypa/cibuildwheel@v1.12.0
+ with:
+ package-dir: psycopg_binary
+ env:
+ CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_24
+ CIBW_MANYLINUX_I686_IMAGE: manylinux_2_24
+ CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_24
+ CIBW_MANYLINUX_PPC64LE_IMAGE: manylinux_2_24
+ CIBW_BUILD: ${{matrix.pyver}}-manylinux_${{matrix.arch}}
+ CIBW_ARCHS_LINUX: auto aarch64 ppc64le
+ CIBW_BEFORE_ALL_LINUX: ./tools/build/wheel_linux_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='host=172.17.0.1 user=postgres'
+ PGPASSWORD=password
+
+ - uses: actions/upload-artifact@v2
+ with:
+ path: ./wheelhouse/*.whl
+
+ services:
+ postgresql:
+ image: postgres:13
+ env:
+ POSTGRES_PASSWORD: password
+ ports:
+ - 5432:5432
+ # Set health checks to wait until postgres has started
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
--- /dev/null
+#!/bin/bash
+
+# Create the psycopg-binary package by renaming and patching psycopg-c
+# This script is designed to run
+
+set -euo pipefail
+set -x
+
+dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+pdir="$( cd "${dir}/../.." && pwd )"
+target="${pdir}/psycopg_binary"
+
+cp -r "${pdir}/psycopg_c" "${target}"
+mv "${target}"/{psycopg_c,psycopg_binary}/
+sed -i 's/psycopg-c/psycopg-binary/' "${target}"/setup.cfg
+sed -i "s/__impl__[[:space:]]*=.*/__impl__ = 'binary'/" \
+ "${target}"/psycopg_binary/pq.pyx
+find "${target}" -name \*.pyx -or -name \*.pxd -or -name \*.py \
+ | xargs sed -i 's/\bpsycopg_c\b/psycopg_binary/'
--- /dev/null
+#!/bin/bash
+
+# Configure the libraries needed to build wheel packages on linux.
+# This script is designed to be used by cibuildwheel as CIBW_BEFORE_ALL_LINUX
+
+set -euo pipefail
+set -x
+
+dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+# Install libpq
+# Note that the pgdg doesn't have an aarch64 repository so wheels are build
+# with the libpq packaged with Debian 9, which is 9.6.
+if [[ ! "$AUDITWHEEL_ARCH" = "aarch64" ]]; then
+ source /etc/os-release
+ echo "deb http://apt.postgresql.org/pub/repos/apt ${VERSION_CODENAME}-pgdg main" \
+ > /etc/apt/sources.list.d/pgdg.list
+ curl --silent https://www.postgresql.org/media/keys/ACCC4CF8.asc \
+ | apt-key add -
+fi
+apt-get update
+apt-get -y install libpq-dev