From 17aa09f5f8fe02894a8acff5ed662cec59fed774 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 26 Nov 2024 16:02:58 +0100 Subject: [PATCH] ModuleNotFoundError --- python/sdist/amici/__init__.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/python/sdist/amici/__init__.py b/python/sdist/amici/__init__.py index f08d9e9349..f8776d8ba6 100644 --- a/python/sdist/amici/__init__.py +++ b/python/sdist/amici/__init__.py @@ -198,13 +198,20 @@ def import_model_module( module_name, f"_{module_name}{ext_suffix}", ) + # if we import a matlab-generated model where the extension + # is in a different directory + needed_file_matlab = Path( + module_path, + f"_{module_name}{ext_suffix}", + ) if not needed_file.exists(): - # if we import a matlab-generated model where the extension - # is in a different directory - needed_file = Path( - module_path, - f"_{module_name}{ext_suffix}", - ) + if needed_file_matlab.exists(): + needed_file = needed_file_matlab + else: + raise ModuleNotFoundError( + f"Cannot find extension module for {module_name} in " + f"{module_path}." + ) if not loaded_file.samefile(needed_file): # this is not the right module, and we can't unload it