mpy-cross is the micropython cross compiler utility, used to pre-compile python files into bytecode (mpy files) suitable for running on your target.
For more details about mpy file / format see https://docs.micropython.org/en/latest/reference/mpyfiles.html
This project compiles mpy-cross for windows, linux and macos and distributes them in python wheels for easy installation on development pc’s:
pip install mpy-cross
Version
The release version of this package directly corresponds to the micropython release it’s built against.
If a wrapper update is needed for a particular release version, it will be updloaded with a .postN version
Weekly releases build against master should be available at: https://gitlab.com/alelec/mpy_cross/pipelines These will have version numbers that reflect the previous release and the current git hash built against.
Usage
mpy-cross package can be run in various different ways
As per normal mpy-cross app
mpy-cross my_app.py mpy-cross --help
From python command line
python -m mpy_cross <args> python -m mpy_cross --help
From python code
import mpy_cross mpy_cross.run(*args, **kwargs) import subprocess proc = mpy_cross.run('--version', stdout=subprocess.PIPE)
where *args are arguments passed to mpy-cross, **kwargs are arguments to pass to subprocess.Popen() internally
Standalone
# Print out path to actual mpy-cross binary python -c "import mpy_cross; print(mpy_cross.mpy_cross)" > /home/andrew/.local/share/virtualenvs/mpy_cross-gSGkki0d/lib/python3.5/site-packages/mpy_cross/mpy-cross /home/corona/.local/share/virtualenvs/mpy_cross-gSGkki0d/lib/python3.5/site-packages/mpy_cross/mpy-cross --version
Older Version Support
This package also supports running mpy-cross in compatibility mode to generage mpy files for older releases of micropython. Compatibility mode can be specified either by micropython version, eg.:
mpy-cross --compat 1.19 my_app.py
Or by specifying the bytecode version, eg:
mpy-cross --bytecode 6 my_app.py
mpy-cross options
usage: mpy-cross [<opts>] [-X <implopt>] [--] <input filename>
Options:
-c <version> : --compat <version> : Run mpy-cross in compatibility mode for given micropython version.
-b <version> : --bytecode <version> : Output specific bytecode version for use with older micropython versions.
--version : show version information
-o : output file for compiled bytecode (defaults to input filename with .mpy extension, or stdout if input is stdin)
-s : source filename to embed in the compiled bytecode (defaults to input file)
-v : verbose (trace various operations); can be multiple
-O[N] : apply bytecode optimizations of level N
Target specific options:
-msmall-int-bits=number : set the maximum bits used to encode a small-int
-march=<arch> : set architecture for native emitter;
x86, x64, armv6, armv6m, armv7m, armv7em, armv7emsp,
armv7emdp, xtensa, xtensawin, rv32imc, rv64imc, host, debug
-march-flags=<flags> : set architecture-specific flags (can be either a dec/hex/bin value or a comma-separated flags string)
supported flags for rv32imc: zba, zcmp
Implementation specific options:
emit={bytecode,native,viper} -- set the default code emitter
heapsize=<n> -- set the heap size for the GC (default 2097152)
source-lines -- include source line numbers (default)
no-source-lines -- exclude source line numbers
Release files for mpy-cross 1.29.0.post2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| mpy_cross-1.29.0.post2-py2.py3-none-win_amd64.whl | Python 3, Python 2 | none | Windows x86-64 | Details |
| mpy_cross-1.29.0.post2-py2.py3-none-win32.whl | Python 3, Python 2 | none | Windows x86-32 | Details |
| mpy_cross-1.29.0.post2-py2.py3-none-manylinux2014_armv7l.whl | Python 3, Python 2 | none | Linux glibc 2.17+ ARMv7l | Details |
| mpy_cross-1.29.0.post2-py2.py3-none-manylinux2014_aarch64.whl | Python 3, Python 2 | none | Linux glibc 2.17+ ARM64 | Details |
| mpy_cross-1.29.0.post2-py2.py3-none-manylinux1_x86_64.whl | Python 3, Python 2 | none | Linux glibc 2.5+ x86-64 | Details |
| mpy_cross-1.29.0.post2-py2.py3-none-manylinux1_i686.whl | Python 3, Python 2 | none | Linux glibc 2.5+ x86-32 | Details |
| mpy_cross-1.29.0.post2-py2.py3-none-macosx_11_0_universal2.whl | Python 3, Python 2 | none | macOS 11.0+ universal2 (ARM64, x86-64) | Details |
Total release size: 8.4 MB
Release files / mpy_cross-1.29.0.post2-py2.py3-none-win_amd64.whl
| Download URL | mpy_cross-1.29.0.post2-py2.py3-none-win_amd64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Python 2 Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3d598813b017d9c33b21e2bf523b78e4886fbf751748ca34d77aec2a2629fdc6
|
|
BLAKE2b-256 checksum How to use checksums |
e844e9c2000e8cc59dcfbfc143745865faf990051d4209dd84f6eed833383ed7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / mpy_cross-1.29.0.post2-py2.py3-none-win32.whl
| Download URL | mpy_cross-1.29.0.post2-py2.py3-none-win32.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Python 2 Python 3 Windows x86-32 |
|
SHA-256 checksum How to use checksums |
6a26e0a6f5b25984d0e1e45fc91598a30ada8c5daf9f60a937cdb4fd6e3f792f
|
|
BLAKE2b-256 checksum How to use checksums |
d44afea402be5a95a78e81d86c16dbb7522356a244c005d06348eb03a95fdf65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / mpy_cross-1.29.0.post2-py2.py3-none-manylinux2014_armv7l.whl
| Download URL | mpy_cross-1.29.0.post2-py2.py3-none-manylinux2014_armv7l.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Linux glibc 2.17+ ARMv7l Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6bc4bf36c4abdb542bf49e6427790b5184f1248118504f034db469e278456724
|
|
BLAKE2b-256 checksum How to use checksums |
8c853d48d8b42eb68829e654d0ad31c3ae2b125c1d1657495b89c05abfea96e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / mpy_cross-1.29.0.post2-py2.py3-none-manylinux2014_aarch64.whl
| Download URL | mpy_cross-1.29.0.post2-py2.py3-none-manylinux2014_aarch64.whl |
|---|---|
| Size | 1.2 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
688f9f9719a2626eccfd0e171b48541135b4cdd616f3674cd088dbd43a4c9b8f
|
|
BLAKE2b-256 checksum How to use checksums |
8747bb24093fd426f174155dc8c8c38699d2b798815bb001c193e0a7318908a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / mpy_cross-1.29.0.post2-py2.py3-none-manylinux1_x86_64.whl
| Download URL | mpy_cross-1.29.0.post2-py2.py3-none-manylinux1_x86_64.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Linux glibc 2.5+ x86-64 Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
026f088706e7a4b19817ede9c22a9086e0dd837d58ec27243cd0bd742b3b6bde
|
|
BLAKE2b-256 checksum How to use checksums |
9aaeeb2e0af4e3799a6243e219d6e4d3e7382710502cd910900c376567999152
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / mpy_cross-1.29.0.post2-py2.py3-none-manylinux1_i686.whl
| Download URL | mpy_cross-1.29.0.post2-py2.py3-none-manylinux1_i686.whl |
|---|---|
| Size | 1.1 MB |
| Tags | Linux glibc 2.5+ x86-32 Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
6dd33410ab748a721df9b1216beae13cd588a00d6ee88e24ed7364d94b3dba76
|
|
BLAKE2b-256 checksum How to use checksums |
ec4a7a2855405e2551b0f7ab0cf925def98c271200c77dfc1aab6e818b491058
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / mpy_cross-1.29.0.post2-py2.py3-none-macosx_11_0_universal2.whl
| Download URL | mpy_cross-1.29.0.post2-py2.py3-none-macosx_11_0_universal2.whl |
|---|---|
| Size | 1.8 MB |
| Tags | Python 2 Python 3 macOS 11.0+ universal2 (ARM64, x86-64) |
|
SHA-256 checksum How to use checksums |
bc050b78286ad81827b97e0081ca3b28159a3abfc417d2d6171a242e7ef34374
|
|
BLAKE2b-256 checksum How to use checksums |
3f58d2b3e9f50109ab3de675efb23c902b8c8bfa281b4795ca4755153d2dd4ef
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|