simvx.core.script_embed

Virtual importlib finder/loader for embedded scripts.

Embedded scripts are source code stored directly in the scene/project file (on node._script_embedded) rather than as separate .py files. This module installs a sys.meta_path finder that makes those scripts importable via standard import machinery, so ScriptManager can load them the same way as file-backed scripts.

Usage: from simvx.core.script_embed import EmbeddedScriptFinder

EmbeddedScriptFinder.register("_simvx_embed_my_script", source_code)
import _simvx_embed_my_script  # works!
EmbeddedScriptFinder.unregister("_simvx_embed_my_script")

Module Contents

Classes

EmbeddedScriptFinder

Finds modules registered as embedded scripts.

API

class simvx.core.script_embed.EmbeddedScriptFinder

Bases: importlib.abc.MetaPathFinder

Finds modules registered as embedded scripts.

classmethod register(module_name: str, source: str)

Register source code under module_name for import.

classmethod unregister(module_name: str)

Remove an embedded module registration.

find_module(fullname, path=None)
find_spec(fullname, path, target=None)
invalidate_caches()