Derive the version from git with verri

Use verri's strawberry flavour through hatchling's code version source, so
versions look like 2026.10.21.0: the HEAD commit date plus the number of
earlier commits that day.

Container images build the sdist in a separate stage that has the git
repository, so they get the same version instead of a +vcs.missing one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Bart BroereandClaude Opus 5.5 committed 2026-10-21 12:44:26 +02:00
1 parent e7ef15fc79
commit ee980b27fe
5 files changed
+32 -10

No files matched your search

-2
View File
@@ -1,8 +1,6 @@
.git
**/__pycache__
**/*.pyc
.venv
tests
**/build
**/dist
**/*.egg-info
+17 -4
View File
@@ -35,6 +35,21 @@ RUN yarn install --frozen-lockfile --network-timeout 600000
RUN yarn build && test -f dist/index.html
# Builds peo's sdist from the git repository, because verri derives the version
# from the git history (see version.py). The unpacked sdist carries that version
# in PKG-INFO, so the images below can be built without git.
FROM ${SLIM_BASE_IMAGE} AS sdist
RUN apt-get update \
&& apt-get install -y --no-install-recommends git python3-build python3-venv \
&& rm -rf /var/lib/apt/lists/*
COPY . /src
RUN python3 -m build --sdist --outdir /dist /src \
&& mkdir /peo \
&& tar -xzf /dist/peo-*.tar.gz --strip-components=1 -C /peo
FROM ${SLIM_BASE_IMAGE} AS slim
RUN apt-get update \
@@ -45,8 +60,7 @@ RUN apt-get update \
# notices: see THIRD_PARTY_NOTICES.md.
COPY container/collect-python-licenses.py /tmp/
COPY container/licenses/ /tmp/licenses/
COPY pyproject.toml README.md LICENSE /tmp/peo/
COPY peo /tmp/peo/peo
COPY --from=sdist /peo /tmp/peo
RUN python3 -m venv --system-site-packages /opt/peo/venv \
&& /opt/peo/venv/bin/pip install --no-cache-dir "/tmp/peo[browser]" \
&& /opt/peo/venv/bin/python /tmp/collect-python-licenses.py \
@@ -94,8 +108,7 @@ RUN /opt/pgadmin/bin/python /tmp/collect-python-licenses.py \
/usr/share/doc/peo/pgadmin-python-licenses /tmp/licenses
# peo itself, using Debian's psycopg and the other dependencies from PyPI.
COPY pyproject.toml README.md LICENSE /tmp/peo/
COPY peo /tmp/peo/peo
COPY --from=sdist /peo /tmp/peo
RUN python3 -m venv --system-site-packages /opt/peo/venv \
&& /opt/peo/venv/bin/pip install --no-cache-dir "/tmp/peo[browser]" \
&& /opt/peo/venv/bin/python /tmp/collect-python-licenses.py \
+3 -1
View File
@@ -2,4 +2,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later
"""peo: serves neo4j-browser and translates Bolt/Cypher to PostgreSQL + AGE."""
__version__ = "0.1.0"
from importlib.metadata import version
__version__ = version("peo")
+7 -3
View File
@@ -2,7 +2,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
[build-system]
requires = ["hatchling>=1.27", "hatch-fancy-pypi-readme>=24.1"]
requires = ["hatchling>=1.27", "hatch-fancy-pypi-readme>=24.1", "verri>=2026.10.11"]
build-backend = "hatchling.build"
[project]
@@ -31,11 +31,15 @@ Source = "https://git.bartbroe.re/bartbroere/peo"
[project.scripts]
peo = "peo.__main__:run"
# The version is derived from the date of the HEAD commit, plus the number of
# commits made earlier that day, like 2026.10.21.0. See version.py.
[tool.hatch.version]
path = "peo/__init__.py"
source = "code"
path = "version.py"
expression = "strawberry()"
[tool.hatch.build.targets.sdist]
include = ["/peo", "/README.md", "/LICENSE"]
include = ["/peo", "/README.md", "/LICENSE", "/version.py"]
[tool.hatch.build.targets.wheel]
packages = ["peo"]
+5
View File
@@ -0,0 +1,5 @@
# SPDX-FileCopyrightText: 2026 Bart Broere
# SPDX-License-Identifier: GPL-3.0-or-later
"""Build-time version source for hatchling, see [tool.hatch.version]."""
from verri.tasty import strawberry # noqa: F401