diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index 94db07be..c69489cd 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -132,29 +132,15 @@ jobs: # }}} macos: # {{{ - runs-on: macos-${{ matrix.macver }} + runs-on: macos-latest if: true strategy: fail-fast: false matrix: # These archs require an Apple M1 runner: [arm64, universal2] - arch: [x86_64] + arch: [x86_64, arm64] pyver: [cp39, cp310, cp311, cp312, cp313] - macver: ["13"] - 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 @@ -171,6 +157,7 @@ jobs: env: CIBW_BUILD: ${{matrix.pyver}}-macosx_${{matrix.arch}} CIBW_ARCHS_MACOS: ${{matrix.arch}} + MACOSX_ARCHITECTURE: ${{matrix.arch}} CIBW_BEFORE_ALL_MACOS: ./scripts/build/wheel_macos_before_all.sh CIBW_TEST_COMMAND: >- export PYTHONPATH={project} && @@ -184,7 +171,7 @@ jobs: - name: Upload artifacts uses: actions/upload-artifact@v4 with: - name: macos-${{matrix.pyver}}-macos-${{matrix.macver}}_${{matrix.arch}} + name: macos-${{matrix.pyver}}-macos-${{matrix.arch}} path: ./wheelhouse/*.whl # }}} diff --git a/scripts/build/build_libpq.sh b/scripts/build/build_libpq.sh index 5281d629..83090a82 100755 --- a/scripts/build/build_libpq.sh +++ b/scripts/build/build_libpq.sh @@ -68,9 +68,12 @@ case "$ID" in # it, force use of system curl. brew uninstall --force --ignore-dependencies openssl gettext curl="/usr/bin/curl" - # The deployment target should be <= to that of the oldest supported Python version. + if [ -z "$MACOSX_ARCHITECTURE" ]; then + MACOSX_ARCHITECTURE="$(uname -m)" + fi + # Set the deployment target to be <= to that of the oldest supported Python version. # e.g. https://www.python.org/downloads/release/python-380/ - if [ "$(uname -m)" == "x86_64" ]; then + if [ "$MACOSX_ARCHITECTURE" == "x86_64" ]; then export MACOSX_DEPLOYMENT_TARGET=10.9 else export MACOSX_DEPLOYMENT_TARGET=11.0 @@ -83,6 +86,22 @@ case "$ID" in ;; esac + +if [ "$ID" == "macos" ]; then + make_configure_standard_flags=( \ + --prefix=${LIBPQ_BUILD_PREFIX} \ + "CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ -arch $MACOSX_ARCHITECTURE" \ + "LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib -arch $MACOSX_ARCHITECTURE" \ + ) +else + make_configure_standard_flags=( \ + --prefix=${LIBPQ_BUILD_PREFIX} \ + CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ \ + LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib \ + ) +fi + + if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then # Build openssl if needed @@ -94,8 +113,14 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then cd "${openssl_dir}" - ./config --prefix=${LIBPQ_BUILD_PREFIX} --openssldir=${LIBPQ_BUILD_PREFIX} \ - zlib -fPIC shared + options=(--prefix=${LIBPQ_BUILD_PREFIX} --openssldir=${LIBPQ_BUILD_PREFIX} \ + zlib -fPIC shared) + if [ -z "$MACOSX_ARCHITECTURE" ]; then + ./config $options + else + ./configure "darwin64-$MACOSX_ARCHITECTURE-cc" $options + fi + make depend make else @@ -119,9 +144,7 @@ if [ "$ID" == "macos" ]; then | tar xzf - cd "${krb5_dir}" - - ./configure --prefix=${LIBPQ_BUILD_PREFIX} \ - CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib + ./configure "${make_configure_standard_flags[@]}" make else cd "${krb5_dir}" @@ -143,9 +166,7 @@ if [ "$ID" == "macos" ]; then | tar xzf - cd "${gettext_dir}" - - ./configure --prefix=${LIBPQ_BUILD_PREFIX} --disable-java \ - CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib + ./configure --disable-java "${make_configure_standard_flags[@]}" make -C gettext-runtime all else cd "${gettext_dir}" @@ -173,8 +194,7 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then cd "${sasl_dir}" autoreconf -i - ./configure --prefix=${LIBPQ_BUILD_PREFIX} --disable-macos-framework \ - CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib + ./configure "${make_configure_standard_flags[@]}" --disable-macos-framework make else cd "${sasl_dir}" @@ -201,8 +221,7 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then cd "${ldap_dir}" - ./configure --prefix=${LIBPQ_BUILD_PREFIX} --enable-backends=no --enable-null \ - CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib + ./configure "${make_configure_standard_flags[@]}" --enable-backends=no --enable-null make depend make -C libraries/liblutil/ @@ -243,10 +262,9 @@ if [ ! -d "${postgres_dir}" ]; then # Often needed, but currently set by the workflow # export LD_LIBRARY_PATH="${LIBPQ_BUILD_PREFIX}/lib" - ./configure --prefix=${LIBPQ_BUILD_PREFIX} --sysconfdir=/etc/postgresql-common \ + ./configure "${make_configure_standard_flags[@]}" --sysconfdir=/etc/postgresql-common \ --with-gssapi --with-openssl --with-pam --with-ldap \ - --without-readline --without-icu \ - CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib + --without-readline --without-icu make -C src/interfaces/libpq make -C src/bin/pg_config make -C src/include