mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-01-31 01:14:09 +03:00
build(macos): Enable cross compiling libpq across macOS architectures
The GitHub Actions runners look like they're only 1 year away from the last macOS x86_64 platform being removed. Get ahead of the game and build x86_64 on arm64.
This commit is contained in:
parent
1eac4fd4da
commit
d0bc154f31
21
.github/workflows/packages.yml
vendored
21
.github/workflows/packages.yml
vendored
|
@ -132,29 +132,15 @@ jobs:
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
macos: # {{{
|
macos: # {{{
|
||||||
runs-on: macos-${{ matrix.macver }}
|
runs-on: macos-latest
|
||||||
if: true
|
if: true
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
# These archs require an Apple M1 runner: [arm64, universal2]
|
# These archs require an Apple M1 runner: [arm64, universal2]
|
||||||
arch: [x86_64]
|
arch: [x86_64, arm64]
|
||||||
pyver: [cp39, cp310, cp311, cp312, cp313]
|
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:
|
steps:
|
||||||
- name: Checkout repos
|
- name: Checkout repos
|
||||||
|
@ -171,6 +157,7 @@ jobs:
|
||||||
env:
|
env:
|
||||||
CIBW_BUILD: ${{matrix.pyver}}-macosx_${{matrix.arch}}
|
CIBW_BUILD: ${{matrix.pyver}}-macosx_${{matrix.arch}}
|
||||||
CIBW_ARCHS_MACOS: ${{matrix.arch}}
|
CIBW_ARCHS_MACOS: ${{matrix.arch}}
|
||||||
|
MACOSX_ARCHITECTURE: ${{matrix.arch}}
|
||||||
CIBW_BEFORE_ALL_MACOS: ./scripts/build/wheel_macos_before_all.sh
|
CIBW_BEFORE_ALL_MACOS: ./scripts/build/wheel_macos_before_all.sh
|
||||||
CIBW_TEST_COMMAND: >-
|
CIBW_TEST_COMMAND: >-
|
||||||
export PYTHONPATH={project} &&
|
export PYTHONPATH={project} &&
|
||||||
|
@ -184,7 +171,7 @@ jobs:
|
||||||
- name: Upload artifacts
|
- name: Upload artifacts
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: macos-${{matrix.pyver}}-macos-${{matrix.macver}}_${{matrix.arch}}
|
name: macos-${{matrix.pyver}}-macos-${{matrix.arch}}
|
||||||
path: ./wheelhouse/*.whl
|
path: ./wheelhouse/*.whl
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
|
@ -68,9 +68,12 @@ case "$ID" in
|
||||||
# it, force use of system curl.
|
# it, force use of system curl.
|
||||||
brew uninstall --force --ignore-dependencies openssl gettext
|
brew uninstall --force --ignore-dependencies openssl gettext
|
||||||
curl="/usr/bin/curl"
|
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/
|
# 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
|
export MACOSX_DEPLOYMENT_TARGET=10.9
|
||||||
else
|
else
|
||||||
export MACOSX_DEPLOYMENT_TARGET=11.0
|
export MACOSX_DEPLOYMENT_TARGET=11.0
|
||||||
|
@ -83,6 +86,22 @@ case "$ID" in
|
||||||
;;
|
;;
|
||||||
esac
|
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
|
if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
|
||||||
|
|
||||||
# Build openssl if needed
|
# Build openssl if needed
|
||||||
|
@ -94,8 +113,14 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
|
||||||
|
|
||||||
cd "${openssl_dir}"
|
cd "${openssl_dir}"
|
||||||
|
|
||||||
./config --prefix=${LIBPQ_BUILD_PREFIX} --openssldir=${LIBPQ_BUILD_PREFIX} \
|
options=(--prefix=${LIBPQ_BUILD_PREFIX} --openssldir=${LIBPQ_BUILD_PREFIX} \
|
||||||
zlib -fPIC shared
|
zlib -fPIC shared)
|
||||||
|
if [ -z "$MACOSX_ARCHITECTURE" ]; then
|
||||||
|
./config $options
|
||||||
|
else
|
||||||
|
./configure "darwin64-$MACOSX_ARCHITECTURE-cc" $options
|
||||||
|
fi
|
||||||
|
|
||||||
make depend
|
make depend
|
||||||
make
|
make
|
||||||
else
|
else
|
||||||
|
@ -119,9 +144,7 @@ if [ "$ID" == "macos" ]; then
|
||||||
| tar xzf -
|
| tar xzf -
|
||||||
|
|
||||||
cd "${krb5_dir}"
|
cd "${krb5_dir}"
|
||||||
|
./configure "${make_configure_standard_flags[@]}"
|
||||||
./configure --prefix=${LIBPQ_BUILD_PREFIX} \
|
|
||||||
CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib
|
|
||||||
make
|
make
|
||||||
else
|
else
|
||||||
cd "${krb5_dir}"
|
cd "${krb5_dir}"
|
||||||
|
@ -143,9 +166,7 @@ if [ "$ID" == "macos" ]; then
|
||||||
| tar xzf -
|
| tar xzf -
|
||||||
|
|
||||||
cd "${gettext_dir}"
|
cd "${gettext_dir}"
|
||||||
|
./configure --disable-java "${make_configure_standard_flags[@]}"
|
||||||
./configure --prefix=${LIBPQ_BUILD_PREFIX} --disable-java \
|
|
||||||
CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib
|
|
||||||
make -C gettext-runtime all
|
make -C gettext-runtime all
|
||||||
else
|
else
|
||||||
cd "${gettext_dir}"
|
cd "${gettext_dir}"
|
||||||
|
@ -173,8 +194,7 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
|
||||||
cd "${sasl_dir}"
|
cd "${sasl_dir}"
|
||||||
|
|
||||||
autoreconf -i
|
autoreconf -i
|
||||||
./configure --prefix=${LIBPQ_BUILD_PREFIX} --disable-macos-framework \
|
./configure "${make_configure_standard_flags[@]}" --disable-macos-framework
|
||||||
CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib
|
|
||||||
make
|
make
|
||||||
else
|
else
|
||||||
cd "${sasl_dir}"
|
cd "${sasl_dir}"
|
||||||
|
@ -201,8 +221,7 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
|
||||||
|
|
||||||
cd "${ldap_dir}"
|
cd "${ldap_dir}"
|
||||||
|
|
||||||
./configure --prefix=${LIBPQ_BUILD_PREFIX} --enable-backends=no --enable-null \
|
./configure "${make_configure_standard_flags[@]}" --enable-backends=no --enable-null
|
||||||
CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib
|
|
||||||
|
|
||||||
make depend
|
make depend
|
||||||
make -C libraries/liblutil/
|
make -C libraries/liblutil/
|
||||||
|
@ -243,10 +262,9 @@ if [ ! -d "${postgres_dir}" ]; then
|
||||||
# Often needed, but currently set by the workflow
|
# Often needed, but currently set by the workflow
|
||||||
# export LD_LIBRARY_PATH="${LIBPQ_BUILD_PREFIX}/lib"
|
# 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 \
|
--with-gssapi --with-openssl --with-pam --with-ldap \
|
||||||
--without-readline --without-icu \
|
--without-readline --without-icu
|
||||||
CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib
|
|
||||||
make -C src/interfaces/libpq
|
make -C src/interfaces/libpq
|
||||||
make -C src/bin/pg_config
|
make -C src/bin/pg_config
|
||||||
make -C src/include
|
make -C src/include
|
||||||
|
|
Loading…
Reference in New Issue
Block a user