]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Added in-progress script to build wheel packages
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 22 Nov 2020 21:37:53 +0000 (21:37 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sun, 22 Nov 2020 21:42:48 +0000 (21:42 +0000)
.gitignore
tools/build_wheels.sh [new file with mode: 0755]

index 1abeb25fe6421fb548211f4a22927e15d16dcc31..dba64de3cfe2bd01268c716d9ec505d73d9ac113 100644 (file)
@@ -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 (executable)
index 0000000..548ac8c
--- /dev/null
@@ -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