From def084076c8900b902b768c00ce305129c7b139f Mon Sep 17 00:00:00 2001 From: Ajit Pratap Singh Date: Thu, 22 Oct 2026 15:00:12 +0530 Subject: [PATCH 1/2] fix(ci,python): skip floating v1 tag in release changelog; fail sdist wheel builds without libgosqlx - release.yml: `git describe --match 'v[0-9]*'` also matched the floating Marketplace major tag `v1`, so moving it (`git tag -fa v1`) could make GoReleaser diff against the wrong release. Require MAJOR.MINOR.PATCH. - python/setup.py: building a wheel from the sdist on a platform with no prebuilt wheel (musl, 32-bit) produced and cached a wheel without the native library; the only signal was a stderr warning pip hides. Fail the build with an actionable error instead. PYGOSQLX_ALLOW_MISSING_LIB=1 keeps the old behaviour for users who supply GOSQLX_LIB_PATH at runtime. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RkzVu3JY9Y6BRWfjesWts9 --- .github/workflows/release.yml | 4 +++- python/README.md | 6 +++++- python/setup.py | 28 ++++++++++++++++------------ 3 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 31f4564f..43ecb6aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,11 +45,13 @@ jobs: # `git describe --tags`, which would pick a pygosqlx tag and produce a # truncated changelog and a wrong compare link. Pin both tags to the # 'v*' series explicitly (git.ignore_tags in .goreleaser.yml is Pro-only). + # The match needs two dots so the floating Marketplace major tag ('v1', + # moved with `git tag -fa v1`, see MARKETPLACE_PUBLISHING.md) never wins. - name: Resolve release tags env: TAG: ${{ github.ref_name }} run: | - prev="$(git describe --tags --abbrev=0 --match 'v[0-9]*' "${TAG}^" 2>/dev/null || true)" + prev="$(git describe --tags --abbrev=0 --match 'v[0-9]*.[0-9]*.[0-9]*' "${TAG}^" 2>/dev/null || true)" echo "GORELEASER_CURRENT_TAG=${TAG}" >> "$GITHUB_ENV" if [ -n "$prev" ]; then echo "GORELEASER_PREVIOUS_TAG=${prev}" >> "$GITHUB_ENV" diff --git a/python/README.md b/python/README.md index a2b39777..b3dbde5c 100644 --- a/python/README.md +++ b/python/README.md @@ -46,7 +46,11 @@ Linux, `libgosqlx.dylib` on macOS, `libgosqlx.dll` on Windows via MSYS2/MinGW) and places it in `python/pygosqlx/lib/`, where `pip install .` bundles it. Use `OUTPUT_DIR=/path/to/output ./build.sh` to write it elsewhere. -To use a library that is not bundled in the package, set: +Building a wheel without the library fails on purpose, so `pip install` on a +platform with no prebuilt wheel (for example musl or 32-bit Linux) stops with +an error instead of installing a package that cannot load. To install without +a bundled library and supply one at runtime instead, set +`PYGOSQLX_ALLOW_MISSING_LIB=1` for the install and: ```bash export GOSQLX_LIB_PATH=/path/to/libgosqlx.so diff --git a/python/setup.py b/python/setup.py index 0883513b..8c11e211 100644 --- a/python/setup.py +++ b/python/setup.py @@ -12,6 +12,7 @@ one wheel per OS/architecture serves every supported Python version. """ +import os import sys from pathlib import Path @@ -36,22 +37,25 @@ def get_tag(self) -> tuple: return "py3", "none", platform_tag def run(self) -> None: - # Building from the sdist on a platform with no prebuilt wheel yields - # a wheel without the native library; it installs fine and only fails - # at first use. Say so loudly at build time. + # Building from the sdist on a platform with no prebuilt wheel (musl, + # 32-bit, ...) would yield a wheel without the native library. pip + # would cache and install it, and pygosqlx would only fail at first + # use; pip hides build-time warnings, so fail the build instead. if not any( (_LIB_DIR / f"libgosqlx.{ext}").is_file() for ext in ("so", "dylib", "dll") ): - print( - "WARNING: pygosqlx/lib/libgosqlx.{so,dylib,dll} is missing; " - "this wheel will not include the native library and pygosqlx " - "will raise FileNotFoundError at first use. Build it with " - "pkg/cbinding/build.sh before installing, or set " - "GOSQLX_LIB_PATH at runtime. See 'Building from source' in " - "python/README.md.", - file=sys.stderr, + message = ( + "pygosqlx/lib/libgosqlx.{so,dylib,dll} is missing, so this " + "wheel would not include the native library. No prebuilt " + "pygosqlx wheel exists for this platform: build the library " + "with pkg/cbinding/build.sh first (see 'Building from source' " + "in python/README.md). To build anyway and point " + "GOSQLX_LIB_PATH at a library at runtime, set " + "PYGOSQLX_ALLOW_MISSING_LIB=1." ) + if os.environ.get("PYGOSQLX_ALLOW_MISSING_LIB") != "1": + raise SystemExit(f"error: {message}") + print(f"WARNING: {message}", file=sys.stderr) super().run() - setup(distclass=BinaryDistribution, cmdclass={"bdist_wheel": PlatformWheel}) From c90a0552ad042222c5a32a7136f4350b1fdb15b7 Mon Sep 17 00:00:00 2001 From: Ajit Pratap Singh Date: Thu, 22 Oct 2026 15:32:41 +0530 Subject: [PATCH 2/2] fix(python): restore blank lines before setup(); show both env vars in README Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RkzVu3JY9Y6BRWfjesWts9 --- python/README.md | 4 +++- python/setup.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/python/README.md b/python/README.md index b3dbde5c..23bc93bd 100644 --- a/python/README.md +++ b/python/README.md @@ -50,9 +50,11 @@ Building a wheel without the library fails on purpose, so `pip install` on a platform with no prebuilt wheel (for example musl or 32-bit Linux) stops with an error instead of installing a package that cannot load. To install without a bundled library and supply one at runtime instead, set -`PYGOSQLX_ALLOW_MISSING_LIB=1` for the install and: +`PYGOSQLX_ALLOW_MISSING_LIB=1` for the install and point `GOSQLX_LIB_PATH` at +the library: ```bash +PYGOSQLX_ALLOW_MISSING_LIB=1 pip install pygosqlx export GOSQLX_LIB_PATH=/path/to/libgosqlx.so ``` diff --git a/python/setup.py b/python/setup.py index 8c11e211..8f1407ab 100644 --- a/python/setup.py +++ b/python/setup.py @@ -58,4 +58,5 @@ def run(self) -> None: print(f"WARNING: {message}", file=sys.stderr) super().run() + setup(distclass=BinaryDistribution, cmdclass={"bdist_wheel": PlatformWheel})