build: derive package version from git via setuptools-scm

Replace hatchling and the static version with setuptools + setuptools-scm,
following Kaya's pre-uv packaging setup: dynamic version, generated
_version.py, and release/* tag prefix. The Docker builder now includes git
and the .git directory so the image is versioned from the checkout. CI
checks out full history and tags for the tag-triggered builds.
This commit is contained in:
2026-10-22 04:03:08 +00:00
parent 9185b5fa05
commit 5db454f8c8
8 changed files with 40 additions and 9 deletions
+6 -1
View File
@@ -6,6 +6,9 @@
FROM python:3.14-alpine3.24 AS builder
COPY --from=ghcr.io/astral-sh/uv:0.13.1 /uv /uvx /bin/
# setuptools-scm derives the package version from git history and tags.
RUN apk add --no-cache git
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=never
@@ -17,9 +20,11 @@ COPY pyproject.toml uv.lock .python-version ./
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-install-project
# Then install the project itself as a regular wheel.
# Then install the project itself as a regular wheel. The git metadata is
# required by setuptools-scm to derive the package version.
COPY README.md ./
COPY src ./src
COPY .git ./.git
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen --no-dev --no-editable