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