import importlib.util from pathlib import Path def load_secure_memory_module(temp_path = "./modules/secure_memory.py"): """ Dynamically loads secure_memory.py from a temporary path. Returns the module object. """ secure_memory = Path(temp_path) if not secure_memory.exists(): raise FileNotFoundError(f"{temp_path} not found.") spec = importlib.util.spec_from_file_location("secure_memory", temp_path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) return module