Skip to main content

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)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mpy_cross-1.28.0.post2-py2.py3-none-win_amd64.whl (1.2 MB view details)

Uploaded Python 2Python 3Windows x86-64

mpy_cross-1.28.0.post2-py2.py3-none-win32.whl (1.1 MB view details)

Uploaded Python 2Python 3Windows x86

mpy_cross-1.28.0.post2-py2.py3-none-manylinux2014_armv7l.whl (1.1 MB view details)

Uploaded Python 2Python 3

mpy_cross-1.28.0.post2-py2.py3-none-manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded Python 2Python 3

mpy_cross-1.28.0.post2-py2.py3-none-manylinux1_x86_64.whl (1.1 MB view details)

Uploaded Python 2Python 3

mpy_cross-1.28.0.post2-py2.py3-none-manylinux1_i686.whl (1.0 MB view details)

Uploaded Python 2Python 3

mpy_cross-1.28.0.post2-py2.py3-none-macosx_11_0_universal2.whl (1.8 MB view details)

Uploaded Python 2Python 3macOS 11.0+ universal2 (ARM64, x86-64)

File details

Details for the file mpy_cross-1.28.0.post2-py2.py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for mpy_cross-1.28.0.post2-py2.py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 adeb7ed3c7e7bfe9c5047ba7dfd9e0373778cc306b98754d8a7e0c3c096ddbb5
MD5 341c41d7aea4448cf21b0bc08142a230
BLAKE2b-256 7117699cb4744d71c304f53078b0ff867abc7968866e46ac89f7a705785781e4

See more details on using hashes here.

File details

Details for the file mpy_cross-1.28.0.post2-py2.py3-none-win32.whl.

File metadata

File hashes

Hashes for mpy_cross-1.28.0.post2-py2.py3-none-win32.whl
Algorithm Hash digest
SHA256 8f0544862a34c58bdc85bc8a746f63d8d69d3f6b7393c161cef9c3919e820cec
MD5 580b00a60c9fb80ede8c80e7ce032815
BLAKE2b-256 806cb9793a022abee12329495ebd4ebb8c827c2d0dcefa8dc2d46da2c2c89bf5

See more details on using hashes here.

File details

Details for the file mpy_cross-1.28.0.post2-py2.py3-none-manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for mpy_cross-1.28.0.post2-py2.py3-none-manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 bfc59cf4d48e8f96430b14c73ea00e56b71b5352479c0c07a5578f5e71f3d894
MD5 f6fac47553ca35d3f2dae3b34c09e67c
BLAKE2b-256 78b56a9ea71393e18e121dd01317935c89ffc7d4659e20bb98254e4451ac2ebd

See more details on using hashes here.

File details

Details for the file mpy_cross-1.28.0.post2-py2.py3-none-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mpy_cross-1.28.0.post2-py2.py3-none-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 588011974fad5c7120950eb8e28d52f35f36f27699e0437e3edc0e34273010d3
MD5 c35f7cc67f9811c9800b0328178a803d
BLAKE2b-256 0d581de7bd0d57e14bdd78bda4c0d3957c5d0ff90cdf9a058f2bd04d333997dd

See more details on using hashes here.

File details

Details for the file mpy_cross-1.28.0.post2-py2.py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mpy_cross-1.28.0.post2-py2.py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2d3c85da0c214fb6794158c88c65a4a3ce34fed0f972dd5639e684d25107f151
MD5 a55455c64b6ef689ce7efd38b87865e6
BLAKE2b-256 c2f9968bf0271df37742308e6e2bc787cda00016f77644c57c0a628d18d3e1cb

See more details on using hashes here.

File details

Details for the file mpy_cross-1.28.0.post2-py2.py3-none-manylinux1_i686.whl.

File metadata

File hashes

Hashes for mpy_cross-1.28.0.post2-py2.py3-none-manylinux1_i686.whl
Algorithm Hash digest
SHA256 5c81919f1ad272a064149afe3feaee0ac9ee49a0ad45a6ee7d976abc2c845b3b
MD5 eecf0f2bb1fec60e508c1a4a3b39feac
BLAKE2b-256 bf96e1c1d0ff24360e00a17b31ad39f94c126b1b73916f09dcec02035e2b4a59

See more details on using hashes here.

File details

Details for the file mpy_cross-1.28.0.post2-py2.py3-none-macosx_11_0_universal2.whl.

File metadata

File hashes

Hashes for mpy_cross-1.28.0.post2-py2.py3-none-macosx_11_0_universal2.whl
Algorithm Hash digest
SHA256 b44e929ca3ddc1c47294f6f67e45c01e5b1711f92ec3a556823c453c3a6f80b2
MD5 819ec5fdb73972295f70ef294b9028b4
BLAKE2b-256 98da4bc32f45ac20f8e598a4bee815707cb30fe5470475783fb22e623f60f4cf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page