ci(macos): Avoid linking against homebrew #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build packages | |
on: | |
- push | |
jobs: | |
build-macos: | |
runs-on: macos-${{ matrix.macver }} | |
if: true | |
strategy: | |
fail-fast: false | |
matrix: | |
# These archs require an Apple M1 runner: [arm64, universal2] | |
arch: [x86_64] | |
pyver: [cp38, cp39, cp310, cp311, cp312, cp313] | |
macver: ["12"] | |
include: | |
- arch: arm64 | |
pyver: cp310 | |
macver: "14" | |
- arch: arm64 | |
pyver: cp311 | |
macver: "14" | |
- arch: arm64 | |
pyver: cp312 | |
macver: "14" | |
- arch: arm64 | |
pyver: cp313 | |
macver: "14" | |
steps: | |
- 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: Build postgresql from source | |
run: | | |
curl --fail-with-body -L https://ftp.postgresql.org/pub/source/v16.6/postgresql-16.6.tar.bz2 | tar x | |
brew uninstall openssl --ignore-dependencies | |
export MACOSX_DEPLOYMENT_TARGET=${{ env.deployment_target }} | |
export LDFLAGS="-L$fake_prefix/lib" | |
export CPPFLAGS="-I$fake_prefix/include" | |
cd postgresql-16.6 | |
./configure --without-icu --prefix="$fake_prefix" --with-ssl=openssl | |
make | |
make install | |
echo "$fake_prefix/bin" >> $GITHUB_PATH | |
brew install openssl | |
- name: Build wheels | |
uses: pypa/[email protected] | |
env: | |
CIBW_BUILD: ${{matrix.pyver}}-macosx_${{matrix.arch}} | |
CIBW_ARCHS_MACOS: ${{matrix.arch}} | |
CIBW_BEFORE_ALL_MACOS: ./scripts/build/wheel_macos_before_all.sh | |
CIBW_TEST_COMMAND: >- | |
export PYTHONPATH={project} && | |
python -c "import tests; tests.unittest.main(defaultTest='tests.test_suite')" | |
CIBW_ENVIRONMENT: >- | |
PG_VERSION=16 | |
PACKAGE_NAME=psycopg2-binary | |
PSYCOPG2_TESTDB=postgres | |
PSYCOPG2_TEST_FAST=1 | |
PATH="/usr/local/opt/postgresql@${PG_VERSION}/bin:$PATH" | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: macos-${{matrix.pyver}}-macos-${{matrix.macver}}_${{matrix.arch}} | |
path: ./wheelhouse/*.whl |