Skip to content
Merged
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
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 7 additions & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,15 @@ 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 point `GOSQLX_LIB_PATH` at
the library:

```bash
PYGOSQLX_ALLOW_MISSING_LIB=1 pip install pygosqlx
export GOSQLX_LIB_PATH=/path/to/libgosqlx.so
```

Expand Down
27 changes: 16 additions & 11 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
one wheel per OS/architecture serves every supported Python version.
"""

import os
import sys
from pathlib import Path

Expand All @@ -36,21 +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()


Expand Down
Loading