MpyDeploy
MpyDeploy is a CLI tool that collects, compiles, caches and deploys MicroPython project files to one or more connected MicroPython devices.
Installed CLI command: mpy
Features
- Automatic COM port detection — scans connected serial ports and identifies MicroPython devices, or use a manually specified port
- File upload — deploys your project's own source folder(s) and any installed MicroPython packages in your
.venv - ️ Cross-compilation — compiles
.pyfiles to.mpyviampy-cross, with automatic architecture detection - Cached deploys — an SHA-256 based file cache skips files that haven't changed since the last upload
- Device wipe — optionally erase all files on the device before deploying
- ️ Project build and deploy — package your project into a
.zipfor distribution, or deploy an existing Project to a device - Reboot and live output — soft-reboots the device after deployment and streams its serial output until the REPL prompt is ready
- Config via
pyproject.toml— all settings can be set project-wide under[tool.mpy_deploy] - mip package installation — automatically installs configured
mippackages after upload
Installation
MpyDeploy requires Python 3.14+. Since it is a standalone tool rather than a project dependency, it's not recommended to install it in your project's virtual environment.
it is Recommended to use uv, which creates an isolated environment with the required Python version for you:
uv tool install MpyDeploy
Alternatively, with pipx:
pipx install MpyDeploy
Or via pip, as long as the interpreter you install it with is Python 3.14+:
pip install MpyDeploy
After installation, the tool is available under the short command mpy.
Usage
Run mpy from your project's root directory — the directory that contains your pyproject.toml and
(by default) a src/ folder with your MicroPython code:
mpy
With no settings, this will:
- Auto-detect the connected MicroPython device's COM port
- Collect files from
./srcand any marked mpy packages in.venv - Compare against the local file cache and skip unchanged files
- Compile packages to
.mpy(sources are uploaded as.pyby default) - Upload everything to the device
- Reboot the device and stream its output until the REPL is ready
Some common examples:
mpy -p COM5 # use a specific COM port instead of auto-detecting
mpy -w # wipe the device before deploying
mpy -cc # clear the local file cache
mpy -cs # also compile sources, not just packages
mpy -dcp # skip packages, only deploy sources
mpy -nr # deploy without rebooting afterwards
mpy -zp # create a deployable zip using the default path
mpy -dp # deploy an existing project archive
Argument Table
| Flag | Long form | Default | Effect |
|---|---|---|---|
-p |
--port |
auto-detect | COM port of the connected MicroPython device |
-ca |
--compiling_architecture |
auto-detect | Target architecture for compilation (x86, x64, armv6, armv6m, armv7m, armv7em, armv7emsp, armv7emdp, xtensa, xtensawin, rv32imc, rv64imc, None) |
-zp |
--zip-project [PATH] |
(off) | Builds a zip archive of the collected project files. Optional PATH to set custom destination path. |
-dp |
--deploy-project [PATH] [PATH_PATH] |
(off) | Deploys an existing project archive. Optional PATH is the project source path and PATH_PATH is to specify the folder inside of the source path. |
-nc |
--no_cache |
(cache enabled) | Disables the file-hash cache for this run. |
-cc |
--clear-cache |
(off) | Deletes the file-hash cache before running. |
-dcp |
--dont_copy_packages |
(copy packages) | Skips copying packages. |
-dcs |
--dont_copy_sources |
(copy sources) | Skips copying sources. |
-ncp |
--no_compile_packages |
(compile packages) | Uploads packages as .py instead of compiling to .mpy. |
-cs |
--compile_sources |
(off) | Compile sources to .mpy. |
-w |
--wipe-files |
(off) | Deletes all files on the device before deploying. |
-nr |
--no_reboot |
(reboot enabled) | Skips the device reboot at the end. |
-npl |
--no_print_loop |
(print-loop enabled) | Skips streaming live device output after reboot. |
Flags with a boolean default of
Noneinherit their effective default frompyproject.toml/ the tool's internalSettings, shown in the "Default" column above.
Configuration via pyproject.toml
Beyond the CLI flags, project-wide defaults can be set under [tool.mpy_deploy] in your pyproject.toml.
[tool.mpy_deploy]
com_ports = ["COM5"] # list of COM ports; use multiple entries for multiple devices, e.g. ["COM5", "COM6"]
source_paths = [["src", ""]] # list of [source_path, device_dest] pairs
package_paths = [] # extra local package folders to include
mip_packages = ["some-mip-package"] # mip packages to install after upload
packages_search_path = ".venv/lib/python3.14/site-packages"
cache_folder_path = ".mpy_file_cache"
zip_dest_path = "build/Project.zip"
deploy_source_path = "build/Project.zip"
deploy_source_local_path = "" # path inside the source folder
compiling_architecture = "armv7emsp"
wipe_files = false
file_cache = true
clear_file_cache = false
copy_packages = true
copy_sources = true
compile_packages = true
compile_sources = false
zip_project = false
deploy_project = false
reboot = true
print_loop = true
CLI arguments always take precedence over values from pyproject.toml.
Compilation Feature
- Files are compiled from
.pyto.mpyusingmpy-cross. Packages are compiled by default main.pyandboot.pyare never compiled when placed at the device root, since MicroPython needs to run them as plain Python.- The target architecture is auto-detected unless overwritten with
-ca. - If compiling a file fails, MpyDeploy falls back to uploading the uncompiled
.pyversion and continues instead of aborting. - This does not apply to a
.ziparchive built with-zp— its contents are always stored uncompiled, regardless ofcompile_packages/compile_sources. See Zip Feature.
Copy Feature
MpyDeploy gathers files from two independent sources, both enabled by default:
- Sources — everything under your configured source path(s) (default:
./src), mirrored to the corresponding path on the device. - Packages — installed packages inside your virtualenv's
site-packagesthat opt in to being deployed. A folder is treated as a mpy package if its__init__.pystarts with the exact first line# mpy. These packages are uploaded underlib/on the device. The search path is auto-detected from.venv(Lib/site-packageson Windows,lib/python3.*/site-packageson POSIX), or can be overridden viapackages_search_path.
Both can be disabled individually with -dcp / -dcs.
File caching: every uploaded file is hashed (SHA-256) and stored in a local JSON cache (.mpy_file_cache/ by default).
On subsequent runs, only files whose hash changed are re-uploaded — significantly speeding up iterative development.
Use -nc to bypass the cache for one run, or -cc to clear it entirely (also happens automatically before a -w wipe).
After the main file transfer, any packages listed under mip_packages in pyproject.toml are installed on the device
via mpremote mip install.
Zip Feature
Instead of uploading directly to a device, MpyDeploy can work with a project .zip archive:
-zp/--zip-project [PATH]— bundles the collected files into a zip. With noPATH, the configuredzip_dest_pathis used (defaultbuild/Project.zip). The archive contents are always stored uncompiled. Useful for creating a distributable release without needing a device connected.mippackages cannot be included in a zip.-dp [PATH] [PATH_PATH]/--deploy-project [PATH] [PATH_PATH]— deploys the contents of an existing project to the connected device. ThePATHparameter defines the source of the project (folder_path, zipfile_path, zip_download_url) ThePATH_PATHparameter is used to specify a target directory inside the source folder. the contents are compiled according tocompile_packages/compile_sources.
--deploy-project Example with URL source:
mpy -dp https://great/repo/download path/inside/repo/to/mpy/project
When either project mode is used, the file cache is disabled for that run.
Using -zp alone skips connecting to a device and compiling entirely — no COM port or compiler architecture is required.
Reboot and Output
After a successful deployment (unless -nr is used), MpyDeploy soft-reboots the device by sending a keyboard-interrupt
followed by a soft-reset over the serial connection.
If the print loop is enabled (disable with -npl), MpyDeploy opens the serial connection for the fist device and
streams the device's console output live to your terminal until it detects the >>> REPL prompt,
indicating the device has finished and is idle. The loop can be stopped early with Ctrl+C.
Requirements
- Python 3.14+ to run MpyDeploy itself
Metadata
Release files for MpyDeploy 4.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mpydeploy-4.0.1.tar.gz | 16.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mpydeploy-4.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.2 kB
Release files / mpydeploy-4.0.1.tar.gz
| Download URL | mpydeploy-4.0.1.tar.gz |
|---|---|
| Size | 16.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
897fc6e8c0b447b4a0655e13bd3684bc98e96c5ec8e84d54a573a72433f1f3aa
|
|
BLAKE2b-256 checksum How to use checksums |
dec10b5cc19fa2b08368938331c030ffde820757848a2f88cdc1850b21b739d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / mpydeploy-4.0.1-py3-none-any.whl
| Download URL | mpydeploy-4.0.1-py3-none-any.whl |
|---|---|
| Size | 18.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fddeb1d5d3e997369aa20925ebf69c0aa635528ce7f4eb174ae0ebcad5cc3966
|
|
BLAKE2b-256 checksum How to use checksums |
988733855b1132824b47e9b9b028c305cbd6a3aad477b5b068a0dedd166ced9e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|