diff --git a/python/sdist/amici/__init__.py b/python/sdist/amici/__init__.py index d51dcdb72c..2e29bc17f7 100644 --- a/python/sdist/amici/__init__.py +++ b/python/sdist/amici/__init__.py @@ -197,6 +197,14 @@ def import_model_module( module_name, 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 not loaded_file.samefile(needed_file): # this is not the right module, and we can't unload it raise RuntimeError(