From 419fa4b9aa8bc78982cf144f7f88ec663a614689 Mon Sep 17 00:00:00 2001 From: Niklas Hauser Date: Tue, 26 Nov 2024 22:30:33 +0100 Subject: [PATCH] [tools] fix with Python 3.13 --- .github/workflows/linux.yml | 2 +- repo.lb | 14 ++++++++++---- tools/modm_tools/jlink.py | 4 ++-- tools/modm_tools/openocd.py | 4 ++-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 1d0d4cdca6..eeb213067b 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -382,7 +382,7 @@ jobs: runs-on: ubuntu-20.04 timeout-minutes: 30 container: - image: ghcr.io/modm-ext/modm-build-base:2022-09-27 + image: ghcr.io/modm-ext/modm-build-base:2023-03-12 steps: - name: Check out repository uses: actions/checkout@v4 diff --git a/repo.lb b/repo.lb index 95caae6990..0f73ad4753 100644 --- a/repo.lb +++ b/repo.lb @@ -20,16 +20,22 @@ import platform from pathlib import Path from git import Repo from os.path import normpath +from importlib.metadata import version def StrictVersion(v): return tuple(map(int, (v.split(".")))) # Check for miminum required lbuild version -import lbuild min_lbuild_version = "1.21.6" -if StrictVersion(getattr(lbuild, "__version__", "0.1.0")) < StrictVersion(min_lbuild_version): - print("modm requires at least lbuild v{}, please upgrade!\n" - " pip3 install -U lbuild".format(min_lbuild_version)) +if StrictVersion(version("lbuild")) < StrictVersion(min_lbuild_version): + print(f"modm requires at least lbuild v{min_lbuild_version}, please upgrade!\n" + " pip3 install -U lbuild") + exit(1) + +min_modm_version = "0.2.0" +if StrictVersion(version("modm")) < StrictVersion(min_modm_version): + print(f"modm requires at least modm v{min_modm_version}, please upgrade!\n" + " pip3 install -U modm") exit(1) # Check for submodule existance and their version diff --git a/tools/modm_tools/jlink.py b/tools/modm_tools/jlink.py index 2ab8fc4bf7..e7350a6522 100644 --- a/tools/modm_tools/jlink.py +++ b/tools/modm_tools/jlink.py @@ -39,7 +39,7 @@ import time import signal import platform -import telnetlib +import telnetlib3 import subprocess from . import gdb @@ -102,7 +102,7 @@ def rtt(backend, channel=0): # Start JLinkGDBServer in the background with backend.scope(): time.sleep(0.5) - with telnetlib.Telnet("localhost", 19021) as tn: + with telnetlib3.Telnet("localhost", 19021) as tn: try: tn.interact() except KeyboardInterrupt: diff --git a/tools/modm_tools/openocd.py b/tools/modm_tools/openocd.py index 3e6d333cfe..6d0c95a9f3 100644 --- a/tools/modm_tools/openocd.py +++ b/tools/modm_tools/openocd.py @@ -41,7 +41,7 @@ import signal import tempfile import platform -import telnetlib +import telnetlib3 import subprocess from . import utils @@ -130,7 +130,7 @@ def rtt(backend, channel=0): # Start OpenOCD in the background with backend.scope(): time.sleep(0.5) - with telnetlib.Telnet("localhost", 9090+channel) as tn: + with telnetlib3.Telnet("localhost", 9090+channel) as tn: try: tn.interact() except KeyboardInterrupt: