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
43 changes: 43 additions & 0 deletions .github/workflows/alpine.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Alpine Python 3.12

on:
push:
branches: ["main"]
pull_request:

jobs:
test-alpine:
name: Alpine Python 3.12
runs-on: ubuntu-latest
container:
image: python:3.12-alpine
env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PYTHONUNBUFFERED: "1"
steps:
- name: Install system dependencies
run: |
apk update
apk add --no-cache \
bash \
curl \
git \
build-base \
postgresql-dev \
libffi-dev \
openssl-dev \
linux-headers \
gcompat \
tzdata

- name: Checkout repository
uses: actions/checkout@v5

- name: Set up uv
uses: astral-sh/setup-uv@v6

- name: Install project
run: uv sync --locked --all-extras --dev

- name: Run tests
run: uv run --python 3.12 pytest -vv
12 changes: 8 additions & 4 deletions src/tinypg/binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def __init__(self, cache_dir: Optional[Path] = None):
# Detect platform
self.os_name = self._detect_os()
self.arch = self._detect_arch()
self._using_musl = self._detect_musl()

def _detect_os(self) -> str:
"""Detect the operating system."""
Expand Down Expand Up @@ -82,9 +83,8 @@ def _get_platform_string(self) -> str:
"""Get the platform string for binary downloads."""
platform = f"{self.os_name}-{self.arch}"

# TODO not returning alpine yet for testing
# if False and self.os_name == "linux" and self._using_musl:
# return f"{platform}-alpine"
if self.os_name == "linux" and self._using_musl:
return f"{platform}-alpine"

return platform

Expand All @@ -94,7 +94,11 @@ def _detect_musl(self) -> bool:
return False

libc, _ = platform.libc_ver()
if libc and libc.lower().startswith("musl"):
force_glibc = bool(os.environ.get("TINYPG_GLIBC"))
if libc and libc.lower().startswith("musl") and not force_glibc:
# Will use a musl build unless TINYPG_GLIBC=1
# tinypg glibc binaries works on alpine (extensions as well)
# with gcompat
return True

if Path("/etc/alpine-release").exists():
Expand Down
Loading