Skip to content

Commit c5366f7

Browse files
Document and handle --skip-install flag in CLI
1 parent 1bd6d7d commit c5366f7

2 files changed

Lines changed: 16 additions & 7 deletions

File tree

.github/workflows/test-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ jobs:
4444
- name: Run example and verify output files
4545
run: |
4646
cd examples
47-
python -m brian2wasm brunel_hakim1999.py --no-server --skip-install
47+
python -m brian2wasm brunel_hakim1999.py --no-server
4848
ls brunel_hakim1999/{brian.js,index.html,wasm_module.{js,wasm},worker.js}
4949
shell: pixi run bash -e {0}

brian2wasm/__main__.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def main():
1111
1212
Usage
1313
-----
14-
``python -m brian2wasm <script.py> [--no-server]``
14+
``python -m brian2wasm <script.py> [--no-server] [--skip-install]``
1515
1616
Parameters
1717
----------
@@ -24,6 +24,10 @@ def main():
2424
Generate the WASM/HTML output without starting the local preview
2525
web-server (sets the ``BRIAN2WASM_NO_SERVER`` environment
2626
variable for the subprocess).
27+
--skip-install : flag, optional
28+
Run Brian2WASM without checking or installing EMSDK. Use this if
29+
you are sure EMSDK is already installed and configured in your
30+
environment.
2731
2832
Behaviour
2933
---------
@@ -32,18 +36,20 @@ def main():
3236
* If found, passes the HTML file to ``set_device`` so the custom
3337
template is used.
3438
* Otherwise falls back to the default template.
35-
3. Prepends the required ``set_device('wasm_standalone', …)`` call to
39+
3. Unless *--skip-install* is given, verifies EMSDK installation
40+
(Pixi/Conda/CONDA_EMSDK_DIR) and attempts to activate it.
41+
4. Prepends the required ``set_device('wasm_standalone', …)`` call to
3642
the script source in-memory.
37-
4. Executes the modified script with its own directory as working
43+
5. Executes the modified script with its own directory as working
3844
directory, so any relative paths inside the model behave as
3945
expected.
4046
4147
Exit status
4248
-----------
4349
* ``0`` – build finished successfully (and server started unless
4450
*--no-server* was given).
45-
* ``1`` – any error (missing file, not a ``.py`` file, exception
46-
during model execution, etc.).
51+
* ``1`` – any error (missing file, not a ``.py`` file, EMSDK not found
52+
or not activated, exception during model execution, etc.).
4753
"""
4854

4955
parser = argparse.ArgumentParser(
@@ -58,7 +64,10 @@ def main():
5864
action="store_true",
5965
help="Generate files without starting the web server"
6066
)
61-
parser.add_argument("--skip-install", action="store_true", help="Run Brian2WASM without installing/activating EMSDK")
67+
parser.add_argument("--skip-install",
68+
action="store_true",
69+
help="Run Brian2WASM without installing/activating EMSDK"
70+
)
6271

6372
args = parser.parse_args()
6473

0 commit comments

Comments
 (0)