Skip to content

Commit 7637f0b

Browse files
committed
feat: Implement dynamic versioning using hatch-vcs and update Dockerfile to support injected versions.
1 parent 40b2b82 commit 7637f0b

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

docker/Dockerfile.sql_to_arc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ COPY middleware ./middleware
1010
# Upgrade pip and install uv
1111
RUN pip install --no-cache-dir --upgrade pip==25.3 uv==0.9.27
1212

13+
# Declare build argument for versioning
14+
ARG APP_VERSION=0.0.0
15+
1316
# We prefer to build a wheel for our package first. This ensures we have a clean,
1417
# distributable artifact that contains only the necessary files.
15-
RUN uv build --package sql_to_arc --wheel
18+
# We set SETUPTOOLS_SCM_PRETEND_VERSION so hatch-vcs can work without .git folder.
19+
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${APP_VERSION#v} uv build --package sql_to_arc --wheel
1620

1721

1822
# ---- Binary Build Stage ----
@@ -51,7 +55,8 @@ RUN uv sync --no-dev
5155
# 4. Finally, for packages like sql_to_arc that exist both as a workspace dependency
5256
# and as a pre-built wheel, we explicitly 'uv pip install' the wheel. This ensures
5357
# we use our optimized, pre-built package instead of the 'editable' source install.
54-
RUN uv pip install /tmp/wheels/*.whl pyinstaller
58+
ARG APP_VERSION=0.0.0
59+
RUN SETUPTOOLS_SCM_PRETEND_VERSION=${APP_VERSION#v} uv pip install /tmp/wheels/*.whl pyinstaller
5560

5661
# Build standalone binary using the .venv's context.
5762
RUN . .venv/bin/activate && \

middleware/sql_to_arc/pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "sql_to_arc"
3-
version = "0.0.0" # currently we disregard the version of this subpackage
3+
dynamic = ["version"]
44
description = "The FAIRagro advanced middleware SQL-to-ARC converter"
55
readme = "README.md"
66
requires-python = ">=3.12"
@@ -17,9 +17,13 @@ dependencies = [
1717
api_client = { git = "https://github.com/fairagro/m4.2_advanced_middleware_api.git", branch = "main", subdirectory = "middleware/api_client" }
1818
shared = { git = "https://github.com/fairagro/m4.2_advanced_middleware_api.git", branch = "main", subdirectory = "middleware/shared" }
1919

20+
[tool.hatch.version]
21+
source = "vcs"
22+
raw-options = { root = "../.." }
23+
2024
[tool.hatch.build.targets.wheel]
2125
packages = ["src/middleware"]
2226

2327
[build-system]
24-
requires = ["hatchling"]
28+
requires = ["hatchling", "hatch-vcs"]
2529
build-backend = "hatchling.build"

pyproject.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "m4-2-sql-to-arc"
3-
version = "0.1.0"
3+
dynamic = ["version"]
44
description = "The FAIRagro SQL-to-ARC client"
55
readme = "README.md"
66
requires-python = ">=3.12"
@@ -246,3 +246,13 @@ disable = [
246246
"C0301", # line-too-long (handled by ruff formatter)
247247
"R0801", # duplicate-code (can be noisy in tests)
248248
]
249+
250+
[tool.hatch.version]
251+
source = "vcs"
252+
253+
[tool.hatch.build.targets.wheel]
254+
include = ["README.md"]
255+
256+
[build-system]
257+
requires = ["hatchling", "hatch-vcs"]
258+
build-backend = "hatchling.build"

0 commit comments

Comments
 (0)