Skip to content

Commit

Permalink
chore: bundle libpq 16
Browse files Browse the repository at this point in the history
  • Loading branch information
dvarrazzo committed Sep 28, 2023
1 parent 921510d commit b39d5d6
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .appveyor/cache_rebuild
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions .appveyor/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions .appveyor/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -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
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
3 changes: 2 additions & 1 deletion scripts/build/build_libpq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 17 additions & 5 deletions scripts/build/build_macos_arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 )"
Expand All @@ -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
Expand All @@ -39,26 +44,29 @@ 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

# Currently not working
# 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


# Install the Python versions we want to build
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)
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion scripts/build/wheel_macos_before_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

# 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

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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b39d5d6

Please sign in to comment.