From 4a614d6127d2d0d3c7c5a696eded5dd227cf90b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Schm=C3=B6lder?= Date: Thu, 8 Jan 2026 16:51:52 +0100 Subject: [PATCH] Insert path at first position of sys.path This ensures the first entry is always used and removed when calling `sys.path.remove()`, improving consistency. --- cadetrdm/repositories.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cadetrdm/repositories.py b/cadetrdm/repositories.py index 595e79f..b114195 100644 --- a/cadetrdm/repositories.py +++ b/cadetrdm/repositories.py @@ -832,11 +832,13 @@ def module(self): cur_dir = os.getcwd() os.chdir(self.path) - sys.path.append(str(self.path)) - module = importlib.import_module(self.name) + try: + sys.path.insert(0, str(self.path)) + module = importlib.import_module(self.name) + finally: + sys.path.remove(str(self.path)) + os.chdir(cur_dir) - sys.path.remove(str(self.path)) - os.chdir(cur_dir) return module def _update_version(self, metadata, cadetrdm_version):