From 0c5ac5ab9295d77c4b8c80108da14df9b920e3d1 Mon Sep 17 00:00:00 2001 From: Kevin Wenner Date: Sat, 27 Sep 2025 13:43:14 +0000 Subject: [PATCH 1/3] test on alpine --- .github/workflows/alpine.yml | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/alpine.yml diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml new file mode 100644 index 0000000..3331c94 --- /dev/null +++ b/.github/workflows/alpine.yml @@ -0,0 +1,42 @@ +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 \ + 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 From 233eb3c1a3b8f1f6767ddb5bef21249ca2a7a144 Mon Sep 17 00:00:00 2001 From: Kevin Wenner Date: Sat, 27 Sep 2025 13:51:13 +0000 Subject: [PATCH 2/3] try with gcompat --- .github/workflows/alpine.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/alpine.yml b/.github/workflows/alpine.yml index 3331c94..16843ae 100644 --- a/.github/workflows/alpine.yml +++ b/.github/workflows/alpine.yml @@ -27,6 +27,7 @@ jobs: libffi-dev \ openssl-dev \ linux-headers \ + gcompat \ tzdata - name: Checkout repository From b55ae0ef478965413a32ca9937f32d0c451a2439 Mon Sep 17 00:00:00 2001 From: Kevin Wenner Date: Sat, 27 Sep 2025 14:23:49 +0000 Subject: [PATCH 3/3] use musl libc builds on alpine etc --- src/tinypg/binaries.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/tinypg/binaries.py b/src/tinypg/binaries.py index 6d88e06..b11d30c 100644 --- a/src/tinypg/binaries.py +++ b/src/tinypg/binaries.py @@ -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.""" @@ -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 @@ -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():