Skip to content

Commit 130efae

Browse files
authored
adbc-driver-postgresql: add build-adbc-driver-postgresql.yml for riscv64 wheels (#1654)
* **Package**: `adbc-driver-postgresql` * **Version**: `1.12.0` * **Source**: https://github.com/apache/arrow-adbc * **Docs**: https://arrow.apache.org/adbc/ Compiles the libpq-based ADBC PostgreSQL driver (`c/driver/postgresql`, C++ over libpq) into `libadbc_driver_postgresql.so`, which the Python package loads via ctypes as a `py3-none` wheel. Upstream publishes no riscv64 wheel. Mirrors upstream's own [`packaging.yml`](https://github.com/apache/arrow-adbc/blob/apache-arrow-adbc-24/.github/workflows/packaging.yml) `python-manylinux` job and its `ci/scripts/python_wheel_unix_{build,relocate}.sh`. **Differs from upstream** - libpq comes from the manylinux image's `libpq-devel` instead of vcpkg - no riscv64 binary cache exists for vcpkg. - No cibuildwheel - the wheel is interpreter-independent, so the image is driven directly instead. **Testing** - Runs the real pytest suite against a local PostgreSQL instance on the runner instead of upstream's docker-compose one. - polars-marked tests are skipped - no riscv64 wheel. **License**: OK Built on cp312; wired against a local PostgreSQL for tests.
1 parent 161bcfd commit 130efae

1 file changed

Lines changed: 157 additions & 0 deletions

File tree

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# SPDX-FileCopyrightText: 2026 The RISE Project
2+
# SPDX-License-Identifier: MIT
3+
---
4+
# Based on upstream's own wheel build at this tag (the python-manylinux job of
5+
# .github/workflows/packaging.yml and ci/scripts/python_wheel_unix_{build,relocate}.sh):
6+
# https://github.com/apache/arrow-adbc/blob/apache-arrow-adbc-24/.github/workflows/packaging.yml
7+
# which builds libadbc_driver_postgresql.so via CMake against vcpkg's static
8+
# libpq, then setup.py copies it into the package and the relocate script
9+
# retags + auditwheel-repairs the resulting py3-none-any wheel into a
10+
# platform one. This narrows that to Linux riscv64: vcpkg has no riscv64
11+
# binary cache, so libpq comes from the manylinux image's own libpq-devel
12+
# instead, and the relocate script's retag step is reproduced inline since it
13+
# isn't vendored as a package file we can invoke directly. See
14+
# build-adbc-driver-manager.yml for why the checkout uses the Go module tag.
15+
name: Build adbc-driver-postgresql wheels (riscv64)
16+
17+
on:
18+
workflow_dispatch:
19+
inputs:
20+
version:
21+
description: 'adbc-driver-postgresql version to build (PyPI version, e.g. 1.12.0)'
22+
required: true
23+
default: '1.12.0'
24+
pull_request:
25+
paths:
26+
- '.github/workflows/build-adbc-driver-postgresql.yml'
27+
28+
concurrency:
29+
group: ${{ github.workflow }}-${{ inputs.version || '1.12.0' }}-${{ github.head_ref || github.run_id }}
30+
cancel-in-progress: true
31+
32+
permissions:
33+
contents: read # to fetch code (actions/checkout)
34+
35+
env:
36+
# `inputs.version` is empty on pull_request events; default to 1.12.0 there.
37+
ADBC_VERSION: ${{ inputs.version || '1.12.0' }}
38+
MANYLINUX_RISCV64_IMAGE: quay.io/pypa/manylinux_2_39_riscv64
39+
40+
jobs:
41+
setup:
42+
uses: $/.github/workflows/_setup.yml
43+
44+
build_wheels:
45+
needs: [setup]
46+
name: Build adbc-driver-postgresql ${{ inputs.version || '1.12.0' }} py3-none-manylinux_riscv64
47+
runs-on: ubuntu-24.04-riscv
48+
# vcpkg builds libpq and its dependencies from source (no riscv64 binary
49+
# cache exists), which alone was exceeding the previous 60-minute budget
50+
# and getting cancelled at exactly the timeout boundary twice in a row.
51+
timeout-minutes: 120
52+
53+
steps:
54+
- name: Checkout apache/arrow-adbc v${{ env.ADBC_VERSION }}
55+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
56+
with:
57+
repository: apache/arrow-adbc
58+
ref: go/adbc/v${{ env.ADBC_VERSION }}
59+
persist-credentials: false
60+
61+
# The wheel is py3-none (no compiled CPython extension, just a ctypes-loaded
62+
# .so), so cibuildwheel's per-interpreter model doesn't fit; drive the
63+
# manylinux image directly instead (gotcha 15's pattern), with the build
64+
# script written to a file rather than an inline `bash -c` one-liner.
65+
- name: Write the build script
66+
run: |
67+
cat > build.sh <<'BUILD_SCRIPT'
68+
set -euo pipefail
69+
70+
dnf install -y --setopt=install_weak_deps=False libpq-devel
71+
72+
cmake -S c -B build \
73+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
74+
-DCMAKE_INSTALL_LIBDIR=lib \
75+
-DCMAKE_INSTALL_PREFIX=/workspace/build/install \
76+
-DADBC_BUILD_SHARED=ON \
77+
-DADBC_BUILD_STATIC=OFF \
78+
-DADBC_DRIVER_POSTGRESQL=ON
79+
cmake --build build --target install -j"$(nproc)"
80+
81+
PY=/opt/python/cp312-cp312/bin
82+
"$PY"/pip install -q --upgrade pip wheel auditwheel
83+
84+
cd python/adbc_driver_postgresql
85+
ADBC_POSTGRESQL_LIBRARY=/workspace/build/install/lib/libadbc_driver_postgresql.so \
86+
"$PY"/pip wheel . --no-deps -w dist
87+
88+
# setup.py declares no ext_modules, so setuptools tags the wheel
89+
# py3-none-any/purelib even though it embeds a real .so; fix that up
90+
# the way ci/scripts/python_wheel_fix_tag.py does upstream (on every
91+
# OS, not just macOS/Windows) before repairing.
92+
plat=$("$PY"/python -c 'import sysconfig; print(sysconfig.get_platform().replace("-", "_").replace(".", "_"))')
93+
cd dist
94+
"$PY"/python -m wheel unpack ./*.whl -d unpacked
95+
meta=$(find unpacked -name WHEEL)
96+
sed -i \
97+
-e 's/^Root-Is-Purelib: true$/Root-Is-Purelib: false/' \
98+
-e "s/^Tag: py3-none-any\$/Tag: py3-none-${plat}/" \
99+
"$meta"
100+
rm ./*.whl
101+
"$PY"/python -m wheel pack unpacked/* --dest-dir .
102+
rm -rf unpacked
103+
104+
"$PY"/python -m auditwheel repair ./*.whl -w /workspace/wheelhouse --plat manylinux_2_39_riscv64
105+
BUILD_SCRIPT
106+
107+
- name: Build the driver and package the wheel
108+
run: |
109+
docker run --rm \
110+
-v "$(pwd)":/workspace \
111+
--workdir /workspace \
112+
"${{ env.MANYLINUX_RISCV64_IMAGE }}" \
113+
bash build.sh
114+
115+
- name: Install the wheel and run the test suite against a local PostgreSQL
116+
run: |
117+
set -euo pipefail
118+
sudo apt-get update -qq
119+
sudo apt-get install -y -qq --no-install-recommends python3-venv postgresql
120+
# The riscv64 self-hosted runner isn't booted with systemd as PID 1
121+
# ("Failed to connect to bus: Host is down"), so use the sysvinit-style
122+
# wrapper instead of systemctl.
123+
sudo service postgresql start
124+
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
125+
126+
python3 -m venv .venv
127+
. .venv/bin/activate
128+
# The runner's stock pip predates riscv64 manylinux tag support and
129+
# rejects the wheel as unsupported.
130+
pip install -q --upgrade pip
131+
# adbc-driver-manager/pandas/pyarrow riscv64 wheels only exist on our
132+
# own registry.
133+
PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ pip install -q \
134+
wheelhouse/*.whl adbc-driver-manager numpy pandas "pyarrow>=14.0.1" "pytest>=9"
135+
136+
export ADBC_POSTGRESQL_TEST_URI="postgresql://postgres:postgres@localhost/postgres"
137+
python -c "import adbc_driver_postgresql; import adbc_driver_postgresql.dbapi"
138+
# Mirrors upstream's own python_util.sh test_packages(): --import-mode
139+
# append keeps the installed wheel authoritative over the checkout.
140+
# polars has no riscv64 wheel, so its integration tests are skipped.
141+
python -m pytest -vv --import-mode append python/adbc_driver_postgresql/tests -m "not polars"
142+
143+
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
144+
with:
145+
name: adbc-driver-postgresql-${{ env.ADBC_VERSION }}-py3-none-manylinux_riscv64
146+
path: wheelhouse/*.whl
147+
if-no-files-found: error
148+
149+
publish:
150+
name: Publish adbc-driver-postgresql ${{ inputs.version || '1.12.0' }}
151+
needs: [setup, build_wheels]
152+
permissions:
153+
contents: write
154+
pull-requests: write
155+
uses: $/.github/workflows/_publish-wheel.yml
156+
with:
157+
artifact-pattern: adbc-driver-postgresql-${{ inputs.version || '1.12.0' }}-*-manylinux_riscv64

0 commit comments

Comments
 (0)