From 90a6413a48f39b274f9ffe9cdd309d5cda4a0b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Ean=20G=C3=BCne=C5=9F?= <180301198+sgunes-wirepas@users.noreply.github.com> Date: Tue, 3 Feb 2026 12:05:15 +0200 Subject: [PATCH 1/3] Set transport service version via environment variable Version can be now set via the WM_TRANSPORT_VERSION environment variable when building the python package. It defaults to a dev version. The PackageNotFoundError from importlib is not caught on purpose, to prevent silently setting an incorrect version in production. Bumping required python version due to importlib --- python_transport/setup.py | 8 ++++++-- python_transport/wirepas_gateway/__about__.py | 2 +- python_transport/wirepas_gateway/__init__.py | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/python_transport/setup.py b/python_transport/setup.py index 6f69ea4b..b6bdf569 100644 --- a/python_transport/setup.py +++ b/python_transport/setup.py @@ -66,13 +66,17 @@ def get_systemd_lib(key): return None +def get_version(): + return os.environ.get("WM_TRANSPORT_VERSION", "0.0.0.dev0") + + about = {} with open(get_absolute_path("./wirepas_gateway/__about__.py")) as f: exec(f.read(), about) setup( name=about["__pkg_name__"], - version=about["__version__"], + version=get_version(), description=about["__description__"], long_description=long_description, long_description_content_type="text/markdown", @@ -84,7 +88,7 @@ def get_systemd_lib(key): keywords=about["__keywords__"], packages=find_packages(exclude=["contrib", "docs", "tests", "examples"]), install_requires=get_requirements("requirements.txt"), - python_requires=">=3.7", + python_requires=">=3.8", ext_modules=[ Extension( "dbusCExtension", diff --git a/python_transport/wirepas_gateway/__about__.py b/python_transport/wirepas_gateway/__about__.py index 0af240b2..a320ef58 100644 --- a/python_transport/wirepas_gateway/__about__.py +++ b/python_transport/wirepas_gateway/__about__.py @@ -19,5 +19,5 @@ __pkg_name__ = "wirepas_gateway" __title__ = "Wirepas Gateway Transport Service" __url__ = "https://github.com/wirepas/gateway" -__version__ = "1.6.0rc1" __keywords__ = "wirepas connectivity iot mesh" + diff --git a/python_transport/wirepas_gateway/__init__.py b/python_transport/wirepas_gateway/__init__.py index 6e204a1c..7335b790 100644 --- a/python_transport/wirepas_gateway/__init__.py +++ b/python_transport/wirepas_gateway/__init__.py @@ -14,6 +14,7 @@ from . import dbus from . import protocol from . import utils +import importlib.metadata from .__about__ import ( __author__, @@ -25,6 +26,8 @@ __pkg_name__, __title__, __url__, - __version__, __keywords__, ) + +__version__ = importlib.metadata.version(__pkg_name__) + From 743388e663cbd869ffc246bf5d5e95424139f7b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Ean=20G=C3=BCne=C5=9F?= <180301198+sgunes-wirepas@users.noreply.github.com> Date: Tue, 3 Feb 2026 12:35:47 +0200 Subject: [PATCH 2/3] Set transport service version during docker build --- docker/transport_service/Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker/transport_service/Dockerfile b/docker/transport_service/Dockerfile index 7a8784c6..52a7e0ad 100644 --- a/docker/transport_service/Dockerfile +++ b/docker/transport_service/Dockerfile @@ -1,5 +1,9 @@ ARG BASE_IMAGE=python:3.13-alpine3.21 +ARG WM_TRANSPORT_VERSION=0.0.0.dev0 + FROM $BASE_IMAGE AS builder +ARG WM_TRANSPORT_VERSION +ENV WM_TRANSPORT_VERSION=$WM_TRANSPORT_VERSION RUN adduser --disabled-password wirepas From ea3b1a0e41c9607d6d28460973a3478f27010254 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=9Ean=20G=C3=BCne=C5=9F?= <180301198+sgunes-wirepas@users.noreply.github.com> Date: Wed, 4 Feb 2026 13:01:10 +0200 Subject: [PATCH 3/3] Update github workflows to set transport service version Python packaging module (packaging.version.Version()) seems to be stripping the leading 'v' in the version so stripping it here might not be needed. However, doing it just in case and to be compliant with PEP 440. --- .github/workflows/docker_transport_service.yml | 18 ++++++++++++++---- .github/workflows/release_artefacts.yml | 17 +++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker_transport_service.yml b/.github/workflows/docker_transport_service.yml index 62f38c46..f5ef128a 100644 --- a/.github/workflows/docker_transport_service.yml +++ b/.github/workflows/docker_transport_service.yml @@ -36,15 +36,23 @@ jobs: - name: Set tag for push if: github.event_name == 'push' - run: echo "TAG1=$IMAGE_NAME:edge" >> $GITHUB_ENV + run: | + echo "WM_TRANSPORT_VERSION=0.0.0.dev0.git+${{ github.sha }}" >> $GITHUB_ENV + echo "TAG1=$IMAGE_NAME:edge" >> $GITHUB_ENV - name: Set tag for manually triggered if: github.event_name == 'workflow_dispatch' - run: echo "TAG1=$IMAGE_NAME:${{ github.event.inputs.tag }}" >> $GITHUB_ENV + run: | + VERSION="${{ github.event.inputs.tag }}" + echo "WM_TRANSPORT_VERSION=${VERSION#v}" >> $GITHUB_ENV + echo "TAG1=$IMAGE_NAME:${VERSION}" >> $GITHUB_ENV - name: Set tag for release version if: github.event_name == 'release' - run: echo "TAG1=$IMAGE_NAME:${{ github.event.release.tag_name }}" >> $GITHUB_ENV + run: | + VERSION="${{ github.event.release.tag_name }}" + echo "WM_TRANSPORT_VERSION=${VERSION#v}" >> $GITHUB_ENV + echo "TAG1=$IMAGE_NAME:${VERSION}" >> $GITHUB_ENV - name: Set additionnal latest tag also for official release if: github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc') @@ -63,7 +71,9 @@ jobs: file: docker/transport_service/Dockerfile platforms: linux/amd64, linux/arm64, linux/arm/v7, linux/arm/v6 push: true - build-args: GATEWAY_BUILD_SHA1= ${{ github.sha }} + build-args: | + GATEWAY_BUILD_SHA1=${{ github.sha }} + WM_TRANSPORT_VERSION=${{ env.WM_TRANSPORT_VERSION }} tags: | ${{ env.TAG1 }} ${{ env.TAG2 }} diff --git a/.github/workflows/release_artefacts.yml b/.github/workflows/release_artefacts.yml index 913c136d..26c432ce 100644 --- a/.github/workflows/release_artefacts.yml +++ b/.github/workflows/release_artefacts.yml @@ -4,6 +4,10 @@ on: release: types: [created] workflow_dispatch: + inputs: + version: + description: 'Version to use' + required: true jobs: build: @@ -17,6 +21,18 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + - name: Set version for manually triggered + if: github.event_name == 'workflow_dispatch' + run: | + VERSION="${{ github.event.inputs.version }}" + echo "WM_TRANSPORT_VERSION=${VERSION#v}" >> $GITHUB_ENV + + - name: Set version for release + if: github.event_name == 'release' + run: | + VERSION="${{ github.event.release.tag_name }}" + echo "WM_TRANSPORT_VERSION=${VERSION#v}" >> $GITHUB_ENV + - name: Build and extract transportService wheel uses: docker/build-push-action@v6 with: @@ -25,6 +41,7 @@ jobs: platforms: linux/amd64 push: false target: export + build-args: WM_TRANSPORT_VERSION=${{ env.WM_TRANSPORT_VERSION }} outputs: ./artifacts/transportService/ - name: Move transport service wheel