Skip to content

Commit

Permalink
Add circuitpython-mpy-cross
Browse files Browse the repository at this point in the history
This wraps the process of building or downloading mpy-cross for a specified
version, then running it with specified arguments.

e.g.,
```
$ circuitpython-mpy-cross --circuitpython-version 9.x -- --version
CircuitPython 9.0.0-alpha.2 on 2023-10-27; mpy-cross emitting mpy v6.1
```
  • Loading branch information
jepler committed Jun 16, 2024
1 parent 8fe3db1 commit 9524f77
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions circuitpython_build_tools/scripts/circuitpython_mpy_cross.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import subprocess

import click

from ..target_versions import VERSIONS
from ..build import mpy_cross

@click.command(context_settings={"ignore_unknown_options": True})
@click.option("--circuitpython-version", type=click.Choice([version["name"] for version in VERSIONS]))
@click.option("--quiet/--no-quiet", "quiet", type=bool, default=True)
@click.argument("mpy-cross-args", nargs=-1, required=True)
def main(circuitpython_version, quiet, mpy_cross_args):
version_info, = [v for v in VERSIONS if v["name"] == circuitpython_version]
mpy_cross_exe = str(mpy_cross(version_info, quiet))
try:
subprocess.check_call([mpy_cross_exe, *mpy_cross_args])
except subprocess.CalledProcessError as e:
raise SystemExit(e.returncode)

if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@
entry_points='''
[console_scripts]
circuitpython-build-bundles=circuitpython_build_tools.scripts.build_bundles:build_bundles
circuitpython-mpy-cross=circuitpython_build_tools.scripts.circuitpython_mpy_cross:main
'''
)

0 comments on commit 9524f77

Please sign in to comment.