Skip to content

Commit

Permalink
Support executing Python files
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanv committed Jul 5, 2023
1 parent a752408 commit 44bacd4
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .spin/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = ''
Expand Down

0 comments on commit 44bacd4

Please sign in to comment.