Skip to content

mip

mip

Portable mip for hosts that lack MicroPython's built-in package installer.

Ported from tools/mpremote/mpremote/mip.py (itself from on-device mip), with mpremote transport/CLI removed and local filesystem writes. For:

  • CPython (desktop)
  • CircuitPython (when urllib, urequests, or requests is available)
  • Pyodide / PyScript (pyodide.http.open_url when urllib is unavailable)

MicroPython ships mip in firmware. Use import lib.path for sys.path (do not hardcode add_ons ahead of .frozen) — lib.path keeps .frozen before add_ons so this file is never imported when frozen mip exists. PyScript gallery loaders call this module on Pyodide via ps_loader.py.

API (compatible subset of on-device mip)::

import mip
mip.install("palettes", index="https://…/mip/PyDevices")
mip.install("github:org/repo/path/package.json", target="add_ons")
mip.install("http://example.com/pkg.py")

mpy defaults to False on CPython, CircuitPython, and Pyodide (they use the index py channel or urls entries, not device .mpy bytecode).

Functions:

install

install(package, index=None, target=None, version=None, mpy=None, url_base=None)

Install a package the way MicroPython mip.install does.

package Index short name, github: / gitlab: / codeberg: URL, http(s): URL, or a local package.json / .py path. index Package index base (default https://micropython.org/pi/v2). target Destination directory (default: first …/lib on sys.path, else lib). version Index version or VCS branch/tag for github: etc. mpy Prefer .mpy from the index when True. Defaults to False on CPython, CircuitPython, and Pyodide. url_base When set, relative urls entries in a manifest resolve against this base instead of the manifest JSON URL (gallery ./src/… paths).