Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/build-pgserver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# SPDX-FileCopyrightText: 2026 The RISE Project
# SPDX-License-Identifier: MIT
---
# This workflow is based on the `build_wheels` job of
# https://github.com/orm011/pgserver/blob/v0.1.4/.github/workflows/build-and-test.yml
name: Build pgserver wheels (riscv64)

on:
workflow_dispatch:
inputs:
version:
description: 'Version glob to (re)build; empty builds every version of docs/packages/pgserver.yaml not released yet'
required: false
default: ''
pull_request:
branches: [main]
paths:
- '.github/workflows/build-pgserver.yml'
- 'docs/packages/pgserver.yaml'
push:
branches: [main]
paths:
- '.github/workflows/build-pgserver.yml'
- 'docs/packages/pgserver.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: pgserver
version: ${{ inputs.version }}

build_wheels:
needs: [setup]
if: needs.setup.outputs.versions != '[]'
name: Build pgserver ${{ matrix.version }} ${{ matrix.python }}-manylinux_riscv64
runs-on: ubuntu-24.04-riscv
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.setup.outputs.versions) }}
python: ["cp312", "cp313", "cp314", "cp314t"]

env:
PGSERVER_VERSION: ${{ matrix.version }}

steps:
- name: Checkout pgserver v${{ env.PGSERVER_VERSION }}
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: orm011/pgserver
ref: v${{ env.PGSERVER_VERSION }}
persist-credentials: false

- name: Checkout python-wheels
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: python-wheels
persist-credentials: false

- name: Patch pgserver source
run: git apply python-wheels/patches/pgserver/${{ env.PGSERVER_VERSION }}/00*.patch

- name: Build wheels
uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0
with:
output-dir: wheelhouse/
only: ${{ matrix.python }}-manylinux_riscv64
env:
CIBW_MANYLINUX_RISCV64_IMAGE: ${{ env.MANYLINUX_RISCV64_IMAGE }}
CIBW_ENVIRONMENT: PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/ PYTEST_ADDOPTS="--timeout=300"
# gotcha 563/564: bounds a crashed initdb (riscv64-only, unresolved) to a fast per-test failure instead of a 180-minute hang.
CIBW_TEST_REQUIRES: pytest-timeout

- name: Verify the wheel ships the compiled postgres server, pgvector and their licences
run: |
python3 - wheelhouse/*.whl <<'EOF'
import sys, zipfile
names = zipfile.ZipFile(sys.argv[1]).namelist()
assert any(n.endswith("pgserver/pginstall/bin/postgres") for n in names), names
assert any(n.endswith("pgserver/pginstall/lib/postgresql/vector.so") for n in names), names

lic = {n.split("/")[-1] for n in names if ".dist-info/licenses/" in n and not n.endswith("/")}
assert {"LICENSE", "LICENSE.postgresql", "LICENSE.pgvector"} <= lic, lic
EOF

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: pgserver-${{ env.PGSERVER_VERSION }}-${{ matrix.python }}-manylinux_riscv64
path: wheelhouse/*.whl
if-no-files-found: error

publish:
name: Publish pgserver ${{ 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: pgserver-${{ matrix.version }}-*-manylinux_riscv64
5 changes: 5 additions & 0 deletions docs/packages/pgserver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package-name: pgserver
source-code: https://github.com/orm011/pgserver
license: Apache-2.0
versions:
- version: 0.1.4
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
From cc565ab3bc1da7a419e3d5d50f2fa1f6742fcd4f Mon Sep 17 00:00:00 2001
From: Ludovic Henry <git@ludovic.dev>
Date: Thu, 24 Sep 2026 06:44:17 +0000
Subject: [PATCH] Add LICENSE.postgresql and LICENSE.pgvector matching
setuptools' default glob

setup.py declares no explicit license_files, so setuptools' default
LICEN[CS]E*/COPYING*/NOTICE*/AUTHORS* glob applies at the project root
only. pgserver's build compiles PostgreSQL 16.2 and the pgvector 0.6.2
extension from source (pgbuild/Makefile, fetched at build time from
ftp.postgresql.org and github.com/pgvector/pgvector) and bundles the
resulting binaries and libraries into every wheel, but the checkout
carries no license text for either project, so neither one lands in
dist-info/licenses/ even though their compiled code ships in every
wheel.

Add a copy of each project's own license text at the root as
LICENSE.postgresql and LICENSE.pgvector, which the existing default
glob already matches with no setup.py/pyproject.toml change. Both are
the permissive, non-copyleft PostgreSQL License.

Upstream-Status: To upstream [not submitted from this automated port run; needs a pull request against orm011/pgserver]
---
LICENSE.pgvector | 20 ++++++++++++++++++++
LICENSE.postgresql | 23 +++++++++++++++++++++++
2 files changed, 43 insertions(+)
create mode 100644 LICENSE.pgvector
create mode 100644 LICENSE.postgresql

diff --git a/LICENSE.pgvector b/LICENSE.pgvector
new file mode 100644
index 0000000..066b96a
--- /dev/null
+++ b/LICENSE.pgvector
@@ -0,0 +1,20 @@
+Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
+
+Portions Copyright (c) 1994, The Regents of the University of California
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose, without fee, and without a written agreement
+is hereby granted, provided that the above copyright notice and this
+paragraph and the following two paragraphs appear in all copies.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
+LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
+DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
+PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
diff --git a/LICENSE.postgresql b/LICENSE.postgresql
new file mode 100644
index 0000000..16f9b46
--- /dev/null
+++ b/LICENSE.postgresql
@@ -0,0 +1,23 @@
+PostgreSQL Database Management System
+(formerly known as Postgres, then as Postgres95)
+
+Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
+
+Portions Copyright (c) 1994, The Regents of the University of California
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose, without fee, and without a written agreement
+is hereby granted, provided that the above copyright notice and this
+paragraph and the following two paragraphs appear in all copies.
+
+IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
+LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
+DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+
+THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
+ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
+PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From 728980fe6d03379af74d1bb4f04fab977d5039d9 Mon Sep 17 00:00:00 2001
From: Ludovic Henry <git@ludovic.dev>
Date: Thu, 24 Sep 2026 11:26:36 +0000
Subject: [PATCH] Do not pass -march=native to the pgvector build

pgvector's Makefile sets `OPTFLAGS = -march=native` unconditionally,
with hand-written exceptions only for Mac ARM and ppc64 (neither of
which supports -march=native either). On the manylinux_riscv64
(quay.io/pypa/manylinux_2_39_riscv64) image, GCC's -march=native
self-detection produces an empty/invalid ISA string on riscv64 and
the build fails outright:

gcc: error: '-march=native': ISA string must begin with rv32 or rv64

pgvector is fetched and built by pgserver's own pgbuild/Makefile at
build time (not vendored in this checkout), so the fix lives here
rather than as a patch to a downloaded tarball: override OPTFLAGS to
empty on the two `make -C $(PGVECTOR_DIR)` invocations, the same way
pgvector's own Makefile already blanks OPTFLAGS for architectures
that reject -march=native. pgvector still gets the auto-vectorization
flags (-ftree-vectorize etc.) at the baseline rv64gc ISA; only the
native/RVV-specific tuning is dropped.

Upstream-Status: Inappropriate [riscv64/CI-infra-specific override of a downstream build script; pgvector's own -march=native default is correct for every architecture it targets]
---
pgbuild/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pgbuild/Makefile b/pgbuild/Makefile
index d6f8b13..f9ecbb4 100644
--- a/pgbuild/Makefile
+++ b/pgbuild/Makefile
@@ -55,8 +55,8 @@ $(PGVECTOR_DIR)/Makefile: $(PGVECTOR_DIR).tar.gz
$(INSTALL_PREFIX)/lib/vector.so: $(PGVECTOR_DIR)/Makefile $(INSTALL_PREFIX)/bin/postgres
unset MAKELEVEL && unset MAKEFLAGS && unset MFLAGS \
&& export PG_CONFIG=$(INSTALL_PREFIX)/bin/pg_config \
- && $(MAKE) -C $(PGVECTOR_DIR) -j \
- && $(MAKE) -C $(PGVECTOR_DIR) install
+ && $(MAKE) -C $(PGVECTOR_DIR) -j OPTFLAGS= \
+ && $(MAKE) -C $(PGVECTOR_DIR) install OPTFLAGS=

.PHONY: pgvector
pgvector: postgres $(INSTALL_PREFIX)/lib/vector.so
--
2.43.0

Loading