Pi66

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

← back to log

fix: reload plugin modules fresh on each build to avoid stale cache

author: pi66
date: 2026-07-04 22:59
hash: 08f47ab3266c732465956b68481e583b3f780146

Diffstat:

M

src/build.py
5 ++++++++++++++++++++++++++++++
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
diff --git a/src/build.py b/src/build.py
index cf4bbfb..45efff4 100644
--- a/src/build.py
+++ b/src/build.py
@@ -29,8 +29,13 @@ def load_plugins(path):
     module_dir = dirname(abspath(path))
     sys.path.insert(0, module_dir)
     try:
+        for name in list(sys.modules):
+            mod_file = getattr(sys.modules[name], "__file__", "") or ""
+            if mod_file.startswith(module_dir):
+                del sys.modules[name]
         spec = importlib.util.spec_from_file_location("plugins", path)
         module = importlib.util.module_from_spec(spec)
+        module.CONFIG = settings.CONFIG
         spec.loader.exec_module(module)

         return {