From: Daniele Varrazzo Date: Sun, 22 Nov 2020 21:37:53 +0000 (+0000) Subject: Added in-progress script to build wheel packages X-Git-Tag: 3.0.dev0~329 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fdd0e00733d5482d3fa206b96d9eea86190c26f2;p=thirdparty%2Fpsycopg.git Added in-progress script to build wheel packages --- diff --git a/.gitignore b/.gitignore index 1abeb25fe..dba64de3c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /.eggs/ /build /dist +/wheels *.pstats /.mypy_cache __pycache__/ diff --git a/tools/build_wheels.sh b/tools/build_wheels.sh new file mode 100755 index 000000000..548ac8c2a --- /dev/null +++ b/tools/build_wheels.sh @@ -0,0 +1,68 @@ +#!/bin/bash + +# Script to build binary psycopg3-c package. +# Built packages will be available in the `wheels` directory. + +# Copyright (C) 2020 The Psycopg Team + +set -euo pipefail +set -x + +# work in progress: currently running with: +# +# docker run --rm \ +# -e PLAT=manylinux2014_x86_64 \ +# -e PSYCOPG3_TEST_DSN="host=172.17.0.1 user=piro dbname=psycopg3_test" \ +# -v `pwd`:/psycopg3 \ +# quay.io/pypa/manylinux2014_x86_64 /psycopg3/tools/build_wheels.sh + +# The version of psycopg we are building +version=$( \ + (cat psycopg3/psycopg3/psycopg3/version.py && echo "print(__version__)") \ + | python) + +function repair_wheel { + wheel="$1" + if ! auditwheel show "$wheel"; then + echo "Skipping non-platform wheel $wheel" + else + auditwheel repair "$wheel" --plat "$PLAT" -w /psycopg3/wheels/ + fi +} + +# Install system packages required to build the library +yum_url=https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm +yum install -y $yum_url +yum install -y postgresql13-devel + +# Make pg_config available +export PATH="/usr/pgsql-13/bin/:$PATH" + +# Using --global-option="-L/usr/pgsql-13/lib/" disables wheels, so no-go. +cp -avr /usr/pgsql-13/lib/* /usr/lib/ + +# Compile wheels +for PYBIN in /opt/python/*/bin; do + if [[ $PYBIN =~ "cp35" ]]; then continue; fi + "${PYBIN}/pip" wheel /psycopg3/psycopg3_c/ --no-deps -w /tmpwheels/ +done + +# Bundle external shared libraries into the wheels +for whl in /tmpwheels/*.whl; do + repair_wheel "$whl" +done + +# Create a sdist package with the basic psycopg3 package in order to install +# psycopg3[binary] with packages from a single dir. +"${PYBIN}/python" /psycopg3/psycopg3/setup.py sdist --dist-dir /psycopg3/wheels/ + +# Delete the libpq to make sure the package is independent +rm -v /usr/lib/libpq.* +rm -v /usr/pgsql-13/lib/libpq.* + +# Install packages and test +for PYBIN in /opt/python/*/bin/; do + if [[ $PYBIN =~ "cp35" ]]; then continue; fi + "${PYBIN}/pip" install psycopg3[c,test]==$version -f /psycopg3/wheels + PSYCOPG3_IMPL=c "${PYBIN}/pytest" /psycopg3/tests -m "not slow" +done