From f02431ba55c0ebe4f1fe37dccb4b3249a6155da1 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Tue, 28 Oct 2025 21:57:06 +0100 Subject: [PATCH] Fix extension re-import check for swig v4.4.0 Extension initialization changed there. `%init` code is now executed each time the extension is executed, not only during the initial import. Fixes #2991. --- swig/modelname.template.i | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/swig/modelname.template.i b/swig/modelname.template.i index c3d953c7fa..7998d57cce 100644 --- a/swig/modelname.template.i +++ b/swig/modelname.template.i @@ -57,7 +57,7 @@ using namespace amici; // store the time a module was imported %{ #include -static std::chrono::time_point _module_import_time; +static std::chrono::time_point _module_import_time = std::chrono::system_clock::now(); static double _get_import_time() { auto epoch = _module_import_time.time_since_epoch(); @@ -68,7 +68,9 @@ static double _get_import_time() { static double _get_import_time(); %init %{ - _module_import_time = std::chrono::system_clock::now(); + // NOTE: from SWIG 4.4.0 onwards, %init code is executed every time the + // module is executed - not only on first import + // This code ends up in `SWIG_mod_exec`. %}