The startup_code.py module#

Summary#

Description#

Bootstrap code fed into the framework’s persistent Python subprocess.

The framework’s PersistentPythonSession pipes startup code into a python -u -i stdin, whose line-oriented parser treats a blank line at column 0 as the end of a compound statement, so multi-line def/try blocks can’t be sent directly. Instead, the real helpers live in the normal, lint-friendly ansys.lumerical.mcp._subprocess_helpers module. Its source is read, base64-encoded, and shipped as a two-line wrapper that decodes and executes it. (exec parses the whole string as a module, so blank lines and docstrings work.)

_subprocess_helpers is never imported in this parent process. Its source is only read via importlib.resources, keeping the parent free of its import-time side effects (matplotlib.use('Agg') and the ansys.lumerical.core probe) and letting the subprocess run without ansys.lumerical.mcp installed (only built-in base64 is needed).

Seeded subprocess globals: FDTD/MODE/DEVICE/INTERCONNECT (from ansys.lumerical.core), the _lumerical_sessions registry, and the _lum_* helpers. (See ansys.lumerical.mcp._subprocess_helpers.)

Module detail#

startup_code.LUMERICAL_STARTUP_CODE#