From b39d5d64923a3e321672847bd57c002145f57430 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 28 Sep 2023 09:16:38 +0200 Subject: [PATCH] chore: bundle libpq 16 - https://github.com/psycopg/psycopg/issues/650 - https://github.com/psycopg/psycopg/discussions/528 --- .appveyor/cache_rebuild | 4 ++-- .appveyor/packages.yml | 4 ++-- .appveyor/tests.yml | 6 ++---- .github/workflows/packages.yml | 10 ++++++---- NEWS | 7 +++++++ scripts/build/build_libpq.sh | 3 ++- scripts/build/build_macos_arm64.sh | 22 +++++++++++++++++----- scripts/build/wheel_macos_before_all.sh | 4 +++- setup.py | 2 +- 9 files changed, 42 insertions(+), 20 deletions(-) diff --git a/.appveyor/cache_rebuild b/.appveyor/cache_rebuild index 94541cfa8..7100c04d7 100644 --- a/.appveyor/cache_rebuild +++ b/.appveyor/cache_rebuild @@ -8,8 +8,8 @@ To invalidate the cache, update this file and check it into git. Currently used modules built in the cache: -- OPENSSL_VERSION: 1.1.1v -- POSTGRES_VERSION: 15.3 +- OPENSSL_VERSION: 1.1.1w +- POSTGRES_VERSION: 16.0 NOTE: to zap the cache manually you can also use: diff --git a/.appveyor/packages.yml b/.appveyor/packages.yml index 8a0dfbbec..890048e0a 100644 --- a/.appveyor/packages.yml +++ b/.appveyor/packages.yml @@ -24,8 +24,8 @@ environment: WORKFLOW: packages - OPENSSL_VERSION: "1_1_1v" - POSTGRES_VERSION: "15_3" + OPENSSL_VERSION: "1_1_1w" + POSTGRES_VERSION: "16_0" PSYCOPG2_TESTDB: psycopg2_test PSYCOPG2_TESTDB_USER: postgres diff --git a/.appveyor/tests.yml b/.appveyor/tests.yml index ad370cf9b..f460b4ba6 100644 --- a/.appveyor/tests.yml +++ b/.appveyor/tests.yml @@ -16,13 +16,11 @@ environment: - {PY_VER: "38", PY_ARCH: "64", APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015} - {PY_VER: "37", PY_ARCH: "32", APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015} - {PY_VER: "37", PY_ARCH: "64", APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015} - - {PY_VER: "36", PY_ARCH: "32", APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015} - - {PY_VER: "36", PY_ARCH: "64", APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015} WORKFLOW: tests - OPENSSL_VERSION: "1_1_1v" - POSTGRES_VERSION: "15_3" + OPENSSL_VERSION: "1_1_1w" + POSTGRES_VERSION: "16_0" PSYCOPG2_TESTDB: psycopg2_test PSYCOPG2_TESTDB_USER: postgres diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml index fd59cfde5..11ad9db48 100644 --- a/.github/workflows/packages.yml +++ b/.github/workflows/packages.yml @@ -56,8 +56,8 @@ jobs: if: true env: - LIBPQ_VERSION: "15.3" - OPENSSL_VERSION: "1.1.1v" + LIBPQ_VERSION: "16.0" + OPENSSL_VERSION: "1.1.1w" strategy: fail-fast: false @@ -81,7 +81,7 @@ jobs: key: libpq-${{ env.LIBPQ_VERSION }}-${{ matrix.platform }}-${{ matrix.arch }} - name: Build wheels - uses: pypa/cibuildwheel@v2.14.1 + uses: pypa/cibuildwheel@v2.16.1 env: CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_MANYLINUX_I686_IMAGE: manylinux2014 @@ -143,7 +143,7 @@ jobs: uses: actions/checkout@v3 - name: Build wheels - uses: pypa/cibuildwheel@v2.14.1 + uses: pypa/cibuildwheel@v2.16.1 env: CIBW_BUILD: ${{matrix.pyver}}-macosx_${{matrix.arch}} CIBW_ARCHS_MACOS: x86_64 @@ -152,9 +152,11 @@ jobs: 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@v3 diff --git a/NEWS b/NEWS index a81a06ea7..29d922ff4 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,13 @@ Current release --------------- +What's new in psycopg 2.9.8 +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +- Wheel package bundled with PostgreSQL 16 libpq in order to add support for + recent features, such as ``sslcertmode``. + + What's new in psycopg 2.9.7 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/scripts/build/build_libpq.sh b/scripts/build/build_libpq.sh index 18b84abc9..6c722336c 100755 --- a/scripts/build/build_libpq.sh +++ b/scripts/build/build_libpq.sh @@ -155,7 +155,8 @@ if [ ! -d "${postgres_dir}" ]; then # export LD_LIBRARY_PATH="${LIBPQ_BUILD_PREFIX}/lib" ./configure --prefix=${LIBPQ_BUILD_PREFIX} --sysconfdir=/etc/postgresql-common \ - --without-readline --with-gssapi --with-openssl --with-pam --with-ldap \ + --with-gssapi --with-openssl --with-pam --with-ldap \ + --without-readline --without-icu \ CPPFLAGS=-I${LIBPQ_BUILD_PREFIX}/include/ LDFLAGS=-L${LIBPQ_BUILD_PREFIX}/lib make -C src/interfaces/libpq make -C src/bin/pg_config diff --git a/scripts/build/build_macos_arm64.sh b/scripts/build/build_macos_arm64.sh index 32c6f2d52..498c7a0ea 100755 --- a/scripts/build/build_macos_arm64.sh +++ b/scripts/build/build_macos_arm64.sh @@ -8,10 +8,14 @@ # so it can pretty much only be executed by a sudo user as it is. set -euo pipefail -set -x +# set -x python_versions="3.8.10 3.9.13 3.10.5 3.11.0" -pg_version=15 +pg_version=16 + +function log { + echo "$@" >&2 +} # Move to the root of the project dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -26,6 +30,7 @@ fi if [[ -x /opt/homebrew/bin/brew ]]; then eval "$(/opt/homebrew/bin/brew shellenv)" else + log "installing brew" command -v brew > /dev/null || ( # Not necessary: already installed # xcode-select --install @@ -39,11 +44,12 @@ export PGDATA=/opt/homebrew/var/postgresql@${pg_version} # Install PostgreSQL, if necessary command -v pg_config > /dev/null || ( + log "installing postgres" brew install postgresql@${pg_version} ) -# After PostgreSQL 15, the bin path is not in the path. -export PATH=$(ls -d1 /opt/homebrew/Cellar/postgresql@${pg_version}/*/bin):$PATH +# Starting from PostgreSQL 15, the bin path is not in the path. +export PATH="$(ls -d1 /opt/homebrew/Cellar/postgresql@${pg_version}/*/bin):$PATH" # Make sure the server is running @@ -51,7 +57,8 @@ export PATH=$(ls -d1 /opt/homebrew/Cellar/postgresql@${pg_version}/*/bin):$PATH # brew services start postgresql@${pg_version} if ! pg_ctl status; then - pg_ctl -l /opt/homebrew/var/log/postgresql@${pg_version}.log start + log "starting the server" + pg_ctl -l "/opt/homebrew/var/log/postgresql@${pg_version}.log" start fi @@ -59,6 +66,7 @@ fi for ver3 in $python_versions; do ver2=$(echo $ver3 | sed 's/\([^\.]*\)\(\.[^\.]*\)\(.*\)/\1\2/') command -v python${ver2} > /dev/null || ( + log "installing Python $ver3" (cd /tmp && curl -fsSl -O \ https://www.python.org/ftp/python/${ver3}/python-${ver3}-macos11.pkg) @@ -68,12 +76,16 @@ done # Create a virtualenv where to work if [[ ! -x .venv/bin/python ]]; then + log "creating a virtualenv" python3 -m venv .venv fi +log "installing cibuildwheel" source .venv/bin/activate pip install cibuildwheel +log "building wheels" + # Build the binary packages export CIBW_PLATFORM=macos export CIBW_ARCHS=arm64 diff --git a/scripts/build/wheel_macos_before_all.sh b/scripts/build/wheel_macos_before_all.sh index febb12d1e..4aaee3f81 100755 --- a/scripts/build/wheel_macos_before_all.sh +++ b/scripts/build/wheel_macos_before_all.sh @@ -2,6 +2,8 @@ # Configure the environment needed to build wheel packages on Mac OS. # This script is designed to be used by cibuildwheel as CIBW_BEFORE_ALL_MACOS +# +# The PG_VERSION env var must be set to a Postgres major version (e.g. 16). set -euo pipefail set -x @@ -9,7 +11,7 @@ set -x dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" prjdir="$( cd "${dir}/../.." && pwd )" -brew install gnu-sed postgresql@15 +brew install gnu-sed postgresql@${PG_VERSION} # Start the database for testing brew services start postgresql diff --git a/setup.py b/setup.py index ed4c6af7a..7a7ad13e2 100644 --- a/setup.py +++ b/setup.py @@ -44,7 +44,7 @@ # Take a look at https://www.python.org/dev/peps/pep-0440/ # for a consistent versioning pattern. -PSYCOPG_VERSION = '2.9.7' +PSYCOPG_VERSION = '2.9.8' # note: if you are changing the list of supported Python version please fix