Merge branch 'fix-ci'

This commit is contained in:
Daniele Varrazzo 2025-10-09 19:00:06 +02:00
commit c4a3866c30
4 changed files with 55 additions and 36 deletions

View File

@ -5,8 +5,8 @@ on:
env: env:
PIP_BREAK_SYSTEM_PACKAGES: "1" PIP_BREAK_SYSTEM_PACKAGES: "1"
LIBPQ_VERSION: "16.0" LIBPQ_VERSION: "17.6"
OPENSSL_VERSION: "1.1.1w" OPENSSL_VERSION: "3.5.4"
jobs: jobs:
sdist: # {{{ sdist: # {{{
@ -65,7 +65,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
platform: [manylinux, musllinux] platform: [manylinux, musllinux]
arch: [x86_64, i686, aarch64, ppc64le] arch: [x86_64, aarch64, ppc64le]
pyver: [cp38, cp39, cp310, cp311, cp312, cp313] pyver: [cp38, cp39, cp310, cp311, cp312, cp313]
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@ -3,7 +3,6 @@
# Build a modern version of libpq and depending libs from source on Centos 5, Alpine or macOS # Build a modern version of libpq and depending libs from source on Centos 5, Alpine or macOS
set -euo pipefail set -euo pipefail
set -x
# Last release: https://www.postgresql.org/ftp/source/ # Last release: https://www.postgresql.org/ftp/source/
# IMPORTANT! Change the cache key in packages.yml when upgrading libraries # IMPORTANT! Change the cache key in packages.yml when upgrading libraries
@ -12,13 +11,13 @@ postgres_version="${LIBPQ_VERSION}"
# last release: https://www.openssl.org/source/ # last release: https://www.openssl.org/source/
openssl_version="${OPENSSL_VERSION}" openssl_version="${OPENSSL_VERSION}"
# last release: https://kerberos.org/dist/ # Latest release: https://kerberos.org/dist/
krb5_version="1.21.3" krb5_version="1.21.3"
# last release: https://openldap.org/software/download/ # Latest release: https://openldap.org/software/download/
ldap_version="2.6.8" ldap_version="2.6.9"
# last release: https://github.com/cyrusimap/cyrus-sasl/releases # Latest release: https://github.com/cyrusimap/cyrus-sasl/releases
sasl_version="2.1.28" sasl_version="2.1.28"
export LIBPQ_BUILD_PREFIX=${LIBPQ_BUILD_PREFIX:-/tmp/libpq.build} export LIBPQ_BUILD_PREFIX=${LIBPQ_BUILD_PREFIX:-/tmp/libpq.build}
@ -40,20 +39,30 @@ case "$(uname)" in
;; ;;
esac esac
# Install packages required for test and wheels build, regardless of whether
# we will build the libpq or not.
case "$ID" in
alpine)
apk add --no-cache krb5-libs
;;
esac
if [[ -f "${LIBPQ_BUILD_PREFIX}/lib/libpq.${library_suffix}" ]]; then if [[ -f "${LIBPQ_BUILD_PREFIX}/lib/libpq.${library_suffix}" ]]; then
echo "libpq already available: build skipped" >&2 echo "libpq already available: build skipped" >&2
exit 0 exit 0
fi fi
# Install packages required to build the libpq.
case "$ID" in case "$ID" in
centos) centos)
yum update -y yum update -y
yum install -y zlib-devel krb5-devel pam-devel yum install -y flex krb5-devel pam-devel perl-IPC-Cmd perl-Time-Piece zlib-devel
;; ;;
alpine) alpine)
apk upgrade apk upgrade
apk add --no-cache zlib-dev krb5-dev linux-pam-dev openldap-dev openssl-dev apk add --no-cache flex krb5-dev linux-pam-dev openldap-dev \
openssl-dev zlib-dev
;; ;;
macos) macos)
@ -91,18 +100,18 @@ else
make_configure_standard_flags=( \ make_configure_standard_flags=( \
--prefix=${LIBPQ_BUILD_PREFIX} \ --prefix=${LIBPQ_BUILD_PREFIX} \
CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ \ CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ \
LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib \ "LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib -L${LIBPQ_BUILD_PREFIX}/lib64" \
) )
fi fi
if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
if [[ ! -f "${LIBPQ_BUILD_PREFIX}/openssl.cnf" ]]; then
# Build openssl if needed # Build openssl if needed
openssl_tag="OpenSSL_${openssl_version//./_}" openssl_tag="openssl-${openssl_version}"
openssl_dir="openssl-${openssl_tag}" openssl_dir="openssl-${openssl_tag}"
if [ ! -d "${openssl_dir}" ]; then if [ ! -d "${openssl_dir}" ]; then
curl -sL \ curl -fsSL \
https://github.com/openssl/openssl/archive/${openssl_tag}.tar.gz \ https://github.com/openssl/openssl/archive/${openssl_tag}.tar.gz \
| tar xzf - | tar xzf -
@ -116,8 +125,8 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
./configure "darwin64-$MACOSX_ARCHITECTURE-cc" $options ./configure "darwin64-$MACOSX_ARCHITECTURE-cc" $options
fi fi
make depend make -s depend
make make -s
else else
pushd "${openssl_dir}" pushd "${openssl_dir}"
fi fi
@ -126,6 +135,7 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
make install_sw make install_sw
popd popd
fi
fi fi
@ -134,12 +144,12 @@ if [ "$ID" == "macos" ]; then
# Build kerberos if needed # Build kerberos if needed
krb5_dir="krb5-${krb5_version}/src" krb5_dir="krb5-${krb5_version}/src"
if [ ! -d "${krb5_dir}" ]; then if [ ! -d "${krb5_dir}" ]; then
curl -sL "https://kerberos.org/dist/krb5/${krb5_version%.*}/krb5-${krb5_version}.tar.gz" \ curl -fsSL "https://kerberos.org/dist/krb5/${krb5_version%.*}/krb5-${krb5_version}.tar.gz" \
| tar xzf - | tar xzf -
pushd "${krb5_dir}" pushd "${krb5_dir}"
./configure "${make_configure_standard_flags[@]}" ./configure "${make_configure_standard_flags[@]}"
make make -s
else else
pushd "${krb5_dir}" pushd "${krb5_dir}"
fi fi
@ -151,6 +161,7 @@ fi
if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
if [[ ! -f "${LIBPQ_BUILD_PREFIX}/lib/libsasl2.${library_suffix}" ]]; then
# Build libsasl2 if needed # Build libsasl2 if needed
# The system package (cyrus-sasl-devel) causes an amazing error on i686: # The system package (cyrus-sasl-devel) causes an amazing error on i686:
@ -159,7 +170,7 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
sasl_tag="cyrus-sasl-${sasl_version}" sasl_tag="cyrus-sasl-${sasl_version}"
sasl_dir="cyrus-sasl-${sasl_tag}" sasl_dir="cyrus-sasl-${sasl_tag}"
if [ ! -d "${sasl_dir}" ]; then if [ ! -d "${sasl_dir}" ]; then
curl -sL \ curl -fsSL \
https://github.com/cyrusimap/cyrus-sasl/archive/${sasl_tag}.tar.gz \ https://github.com/cyrusimap/cyrus-sasl/archive/${sasl_tag}.tar.gz \
| tar xzf - | tar xzf -
@ -167,7 +178,7 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
autoreconf -i autoreconf -i
./configure "${make_configure_standard_flags[@]}" --disable-macos-framework ./configure "${make_configure_standard_flags[@]}" --disable-macos-framework
make make -s
else else
pushd "${sasl_dir}" pushd "${sasl_dir}"
fi fi
@ -178,16 +189,18 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
make install make install
popd popd
fi
fi fi
if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
if [[ ! -f "${LIBPQ_BUILD_PREFIX}/lib/libldap.${library_suffix}" ]]; then
# Build openldap if needed # Build openldap if needed
ldap_tag="${ldap_version}" ldap_tag="${ldap_version}"
ldap_dir="openldap-${ldap_tag}" ldap_dir="openldap-${ldap_tag}"
if [ ! -d "${ldap_dir}" ]; then if [ ! -d "${ldap_dir}" ]; then
curl -sL \ curl -fsSL \
https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-${ldap_tag}.tgz \ https://www.openldap.org/software/download/OpenLDAP/openldap-release/openldap-${ldap_tag}.tgz \
| tar xzf - | tar xzf -
@ -195,10 +208,10 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
./configure "${make_configure_standard_flags[@]}" --enable-backends=no --enable-null ./configure "${make_configure_standard_flags[@]}" --enable-backends=no --enable-null
make depend make -s depend
make -C libraries/liblutil/ make -s -C libraries/liblutil/
make -C libraries/liblber/ make -s -C libraries/liblber/
make -C libraries/libldap/ make -s -C libraries/libldap/
else else
pushd "${ldap_dir}" pushd "${ldap_dir}"
fi fi
@ -210,6 +223,7 @@ if [ "$ID" == "centos" ] || [ "$ID" == "macos" ]; then
chmod +x ${LIBPQ_BUILD_PREFIX}/lib/{libldap,liblber}*.${library_suffix}* chmod +x ${LIBPQ_BUILD_PREFIX}/lib/{libldap,liblber}*.${library_suffix}*
popd popd
fi
fi fi
@ -217,7 +231,7 @@ fi
postgres_tag="REL_${postgres_version//./_}" postgres_tag="REL_${postgres_version//./_}"
postgres_dir="postgres-${postgres_tag}" postgres_dir="postgres-${postgres_tag}"
if [ ! -d "${postgres_dir}" ]; then if [ ! -d "${postgres_dir}" ]; then
curl -sL \ curl -fsSL \
https://github.com/postgres/postgres/archive/${postgres_tag}.tar.gz \ https://github.com/postgres/postgres/archive/${postgres_tag}.tar.gz \
| tar xzf - | tar xzf -
@ -231,15 +245,14 @@ if [ ! -d "${postgres_dir}" ]; then
src/include/pg_config_manual.h src/include/pg_config_manual.h
fi fi
# Often needed, but currently set by the workflow export LD_LIBRARY_PATH="${LIBPQ_BUILD_PREFIX}/lib:${LIBPQ_BUILD_PREFIX}/lib64"
# export LD_LIBRARY_PATH="${LIBPQ_BUILD_PREFIX}/lib"
./configure "${make_configure_standard_flags[@]}" --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
make -C src/interfaces/libpq make -s -C src/interfaces/libpq
make -C src/bin/pg_config make -s -C src/bin/pg_config
make -C src/include make -s -C src/include
else else
pushd "${postgres_dir}" pushd "${postgres_dir}"
fi fi

View File

@ -12,7 +12,7 @@ dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
prjdir="$( cd "${dir}/../.." && pwd )" prjdir="$( cd "${dir}/../.." && pwd )"
# Build dependency libraries # Build dependency libraries
"${prjdir}/scripts/build/build_libpq.sh" "${prjdir}/scripts/build/build_libpq.sh" > /dev/null
# Show dependency tree # Show dependency tree
otool -L /tmp/libpq.build/lib/*.dylib otool -L /tmp/libpq.build/lib/*.dylib

View File

@ -71,10 +71,13 @@ class NetworkingTestCase(testutils.ConnectingTestCase):
cur.execute("select %s", [ip.ip_interface('::ffff:102:300/128')]) cur.execute("select %s", [ip.ip_interface('::ffff:102:300/128')])
# The texual representation of addresses has changed in Python 3.13 # The texual representation of addresses has changed in Python 3.13
if sys.version_info >= (3, 13): # https://github.com/python/cpython/issues/128840
if str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:1.2.3.0/128":
self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128') self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128')
else: elif str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:102:300/128":
self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128') self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')
else:
assert False, "unexpected"
@testutils.skip_if_crdb("cidr") @testutils.skip_if_crdb("cidr")
def test_cidr_cast(self): def test_cidr_cast(self):
@ -117,10 +120,13 @@ class NetworkingTestCase(testutils.ConnectingTestCase):
cur.execute("select %s", [ip.ip_network('::ffff:102:300/128')]) cur.execute("select %s", [ip.ip_network('::ffff:102:300/128')])
# The texual representation of addresses has changed in Python 3.13 # The texual representation of addresses has changed in Python 3.13
if sys.version_info >= (3, 13): # https://github.com/python/cpython/issues/128840
if str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:1.2.3.0/128":
self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128') self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128')
else: elif str(ip.ip_interface("::ffff:102:300/128")) == "::ffff:102:300/128":
self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128') self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')
else:
assert False, "unexpected"
def test_suite(): def test_suite():