Skip to content

Commit

Permalink
ci(macos): Avoid linking against homebrew
Browse files Browse the repository at this point in the history
  • Loading branch information
bwoodsend committed Nov 22, 2024
1 parent a805acf commit 9c34c7f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 125 deletions.
155 changes: 31 additions & 124 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
@@ -1,132 +1,10 @@
---
name: Build packages
on:
- workflow_dispatch
- push


jobs:
build-sdist:
if: true
strategy:
fail-fast: false
matrix:
include:
- package_name: psycopg2
- package_name: psycopg2-binary

runs-on: ubuntu-latest
steps:
- name: Checkout repos
uses: actions/checkout@v4

- name: Build sdist
run: ./scripts/build/build_sdist.sh
env:
PACKAGE_NAME: ${{ matrix.package_name }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: sdist-${{ matrix.package_name }}
path: |
dist/*.tar.gz
env:
PSYCOPG2_TESTDB: postgres
PSYCOPG2_TESTDB_HOST: 172.17.0.1
PSYCOPG2_TESTDB_USER: postgres
PSYCOPG2_TESTDB_PASSWORD: password
PSYCOPG2_TEST_FAST: 1

services:
postgresql:
image: postgres:16
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
build-linux:
if: true

env:
LIBPQ_VERSION: "16.0"
OPENSSL_VERSION: "1.1.1w"

strategy:
fail-fast: false
matrix:
platform: [manylinux, musllinux]
arch: [x86_64, i686, aarch64, ppc64le]
pyver: [cp38, cp39, cp310, cp311, cp312, cp313]

runs-on: ubuntu-latest
steps:
- name: Checkout repos
uses: actions/checkout@v4

- name: Set up QEMU for multi-arch build
uses: docker/setup-qemu-action@v3

- name: Cache libpq build
uses: actions/cache@v3
with:
path: /tmp/libpq.build
key: libpq-${{ env.LIBPQ_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }}

- name: Build wheels
uses: pypa/[email protected]
env:
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
CIBW_MANYLINUX_I686_IMAGE: manylinux2014
CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014
CIBW_MANYLINUX_PPC64LE_IMAGE: manylinux2014
CIBW_BUILD: ${{matrix.pyver}}-${{matrix.platform}}_${{matrix.arch}}
CIBW_ARCHS_LINUX: auto aarch64 ppc64le
CIBW_BEFORE_ALL_LINUX: ./scripts/build/wheel_linux_before_all.sh
CIBW_REPAIR_WHEEL_COMMAND: >-
./scripts/build/strip_wheel.sh {wheel}
&& auditwheel repair -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: >-
export PYTHONPATH={project} &&
python -c "import tests; tests.unittest.main(defaultTest='tests.test_suite')"
CIBW_ENVIRONMENT_PASS_LINUX: LIBPQ_VERSION OPENSSL_VERSION
CIBW_ENVIRONMENT: >-
PACKAGE_NAME=psycopg2-binary
LIBPQ_BUILD_PREFIX=/host/tmp/libpq.build
PATH="$LIBPQ_BUILD_PREFIX/bin:$PATH"
LD_LIBRARY_PATH="$LIBPQ_BUILD_PREFIX/lib:$LIBPQ_BUILD_PREFIX/lib64"
PSYCOPG2_TESTDB=postgres
PSYCOPG2_TESTDB_HOST=172.17.0.1
PSYCOPG2_TESTDB_USER=postgres
PSYCOPG2_TESTDB_PASSWORD=password
PSYCOPG2_TEST_FAST=1
- uses: actions/upload-artifact@v4
with:
name: linux-${{matrix.pyver}}-${{matrix.platform}}_${{matrix.arch}}
path: ./wheelhouse/*.whl

services:
postgresql:
image: postgres:16
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


build-macos:
Expand Down Expand Up @@ -158,6 +36,36 @@ jobs:
- name: Checkout repos
uses: actions/checkout@v4

# The deployment target should be <= to that of the oldest supported Python version.
# e.g. https://www.python.org/downloads/release/python-380/
# The MACOSX_DEPLOYMENT_TARGET variable must not be exposed to cibuildwheel
- run: echo deployment_target=${{ matrix.arch == 'arm64' && '11.0' || '10.9' }} | tee $GITHUB_ENV
- run: echo fake_prefix="$PWD/fake-prefix" >> $GITHUB_ENV

- name: Build openssl from source
run: |
export MACOSX_DEPLOYMENT_TARGET=${{ env.deployment_target }}
curl --fail-with-body -L https://github.com/openssl/openssl/releases/download/openssl-3.4.0/openssl-3.4.0.tar.gz | tar xz
cd openssl-3.4.0
./configure --prefix="$fake_prefix"
make build_sw
make install_sw
- name: Force postgresql to not link against homebrew's openssl
run: brew uninstall openssl --ignore-dependencies

- name: Build postgresql from source
run: |
export MACOSX_DEPLOYMENT_TARGET=${{ env.deployment_target }}
export LDFLAGS="-L$fake_prefix/lib"
export CPPFLAGS="-I$fake_prefix/include"
curl --fail-with-body -L https://ftp.postgresql.org/pub/source/v16.6/postgresql-16.6.tar.bz2 | tar x
cd postgresql-16.6
./configure --without-icu --prefix="$fake_prefix" --with-ssl=openssl
make
make install
echo "$fake_prefix/bin" >> $GITHUB_PATH
- name: Build wheels
uses: pypa/[email protected]
env:
Expand All @@ -168,7 +76,6 @@ jobs:
export PYTHONPATH={project} &&
python -c "import tests; tests.unittest.main(defaultTest='tests.test_suite')"
CIBW_ENVIRONMENT: >-
MACOSX_DEPLOYMENT_TARGET=${{ matrix.macver }}.0
PG_VERSION=16
PACKAGE_NAME=psycopg2-binary
PSYCOPG2_TESTDB=postgres
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Tests

on:
push:
pull_request:

jobs:
Expand Down

0 comments on commit 9c34c7f

Please sign in to comment.