brian2wasm.__main__ module
- brian2wasm.__main__.check_emsdk()[source]
Verify that the Emscripten SDK (EMSDK) is installed and attempt to activate it.
This function checks for EMSDK in the current environment, using either the system path (
emsdkexecutable) or theCONDA_EMSDK_DIRvariable. If EMSDK is missing, it prints installation instructions and exits. If EMSDK is found but not activated, it attempts to activate the latest version, optionally prompting the user to install and activate it.- Parameters:
None – This function takes no arguments.
- Raises:
SystemExit – If EMSDK is not found, not activated, or installation/activation fails, the process exits with status code
1.RuntimeError – If subprocess execution encounters an unexpected failure during EMSDK activation.
- Returns:
This function is intended as a setup check and does not return a value. Its success or failure is indicated by process exit.
- Return type:
None
- brian2wasm.__main__.main()[source]
Command-line interface entry point for Brian2Wasm.
This function validates the given script, injects the required
set_device('wasm_standalone', …)call, ensures EMSDK is available (unless skipped), and executes the modified script.- Parameters:
script (str) – Path to the Python model file. The file must exist, end with
.py, and must not callset_devicedirectly, since this function injects the correct call automatically.--no-server (bool, optional) – If given, generates the WASM/HTML output without starting the local preview web server. Internally sets the environment variable
BRIAN2WASM_NO_SERVER=1.--skip-install (bool, optional) – If given, skips EMSDK installation and activation checks. Use this flag when you are certain EMSDK is already installed and properly configured in your environment.
- Raises:
FileNotFoundError – If the provided script path does not exist.
ValueError – If the provided file is not a Python
.pyscript.RuntimeError – If execution of the modified script fails for any reason.
SystemExit – If errors occur during validation or script execution, the process exits with status code
1.
- Returns:
This function is intended as a CLI entry point and does not return a value.
- Return type:
None