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):