From 44bacd4900b990eb1affeec27908e12d85d55bff Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Wed, 5 Jul 2023 13:20:02 -0700 Subject: [PATCH] Support executing Python files --- .spin/cmds.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.spin/cmds.py b/.spin/cmds.py index 208316a8593b..6addf86d83c4 100644 --- a/.spin/cmds.py +++ b/.spin/cmds.py @@ -142,7 +142,7 @@ def test(ctx, pytest_args, markexpr, n_jobs, tests, verbose): @click.command() -@click.option('--code', '-c', help='Python pogram passed in as a string') +@click.option('--code', '-c', help='Python program passed in as a string') @click.argument('gdb_args', nargs=-1) def gdb(code, gdb_args): """👾 Execute a Python snippet with GDB @@ -157,10 +157,18 @@ def gdb(code, gdb_args): spin gdb ls spin gdb -- --args ls -al + + You can also run Python progreams: + + spin gdb my_tests.py + spin gdb -- my_tests.py --mytest-flag """ meson._set_pythonpath() gdb_args = list(gdb_args) + if gdb_args and gdb_args[0].endswith('.py'): + gdb_args = ['--args', sys.executable] + gdb_args + if sys.version_info[:2] >= (3, 11): PYTHON_FLAGS = ['-P'] code_prefix = ''