| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This micropython-lib fork builds an installable package index containing both precompiled .mpy bytecode and raw .py source at:
https://PyDevices.github.io/mip
This repository documents the package manager itself. Product repositories document which product or board package to choose.
import mip
mip.install("package-name", index="https://PyDevices.github.io/mip")mip installs into the interpreter's default library destination unless target is supplied. Use mpy=False to request portable .py source instead of MicroPython bytecode.
mip.install(
"package-name",
index="https://PyDevices.github.io/mip",
target="lib",
mpy=False,
)Hosted MicroPython ports can run the package manager as a module:
micropython -m mip install \
--index https://PyDevices.github.io/mip \
package-nameUse --target lib for an explicit workspace destination and --no-mpy for a source-only tree.
mpremote connect /dev/ttyUSB0 mip install \
--index https://PyDevices.github.io/mip \
package-namempremote mip resolves and transfers the package from the host, so the board does not need its own network connection.
mip also accepts GitHub files and directories. Pass the index when a raw package has named dependencies that should resolve here:
mip.install(
"github:OWNER/REPOSITORY/path/to/package",
index="https://PyDevices.github.io/mip",
)The live index intentionally exposes only each package's current latest manifest. Releases replace the current entry rather than accumulating a public history of versioned manifests.
To install standard, upstream micropython-lib standard library or ecosystem packages, there are four main options. For more information see the Package management documentation documentation.
As of MicroPython v1.20 (and nightly builds since October 2022), boards with WiFi and Ethernet support include the mip package manager.
>>> import mip
>>> mip.install("package-name")mpremote is the officially-supported tool for interacting with a MicroPython device and, since v0.4.0, support for installing micropython-lib packages is provided by using the mip command.
$ mpremote connect /dev/ttyUSB0 mip install package-nameSee the mpremote documentation.
If you are building your own firmware, all packages in this repository include a manifest.py that can be included into your board manifest via the require() command. See Manifest files for more information.
Many micropython-lib packages are just single-file modules, and you can quickly get started by copying the relevant Python file to your device. For example, to add the base64 library, you can directly copy python-stdlib/base64/base64.py to the lib directory on your device.
This can be done using mpremote, for example:
$ mpremote connect /dev/ttyUSB0 cp python-stdlib/base64/base64.py :/libFor packages that are implemented as a package directory, you'll need to copy the directory instead. For example, to add collections.defaultdict, copy collections/collections/__init__.py and collections-defaultdict/collections/defaultdict.py to a directory named lib/collections on your device.
Note that unlike the other three approaches based on mip or manifest.py, you will need to manually resolve dependencies. You can inspect the relevant manifest.py file to view the list of dependencies for a given package.
We use GitHub Discussions as our forum, and Discord for chat. These are great places to ask questions and advice from the community or to discuss your MicroPython-based projects.
The MicroPython Wiki is also used for micropython-lib.
For bugs and feature requests, please raise an issue.
We welcome pull requests to add new packages, fix bugs, or add features. Please be sure to follow the Contributor's Guidelines & Code Conventions. Note that MicroPython is licensed under the MIT license and all contributions should follow this license.
The terms library, package, and module are overloaded and lead to some confusion. The interpretation used in by the MicroPython project is that:
A library is a collection of installable packages, e.g. The Python Standard Library, or micropython-lib.
A package can refer to two things. The first meaning, "library package", is something that can be installed from a library, e.g. via mip (or pip in CPython/PyPI). Packages provide modules that can be imported. The ambiguity here is that the module provided by the package does not necessarily have to have the same name, e.g. the pyjwt package provides the jwt module. In CPython, the pyserial package providing the serial module is another common example.
A module is something that can be imported. For example, "the os module".
A module can be implemented either as a single file, typically also called a module or "single-file module", or as a package (the second meaning), which in this context means a directory containing multiple .py files (usually at least an __init__.py).
In micropython-lib, we also have the concept of an extension package which is a library package that extends the functionality of another package, by adding additional files to the same package directory. These packages have hyphenated names. For example, the collections-defaultdict package extends the collections package to add the defaultdict class to the collections module.
| Back | FazBrowse Home | New Git URL |