This is a repository of libraries designed to be useful for writing MicroPython applications.
 
 
Go to file
Jim Mussared af3e1aff9e all: Update READMEs. 2021-05-27 15:41:08 +10:00
micropython all: Update READMEs. 2021-05-27 15:41:08 +10:00
python-stdlib all: Update READMEs. 2021-05-27 15:41:08 +10:00
unix-ffi all: Update READMEs. 2021-05-27 15:41:08 +10:00
.gitignore .gitignore: Ignore local development files. 2014-05-31 15:18:48 +03:00
CONTRIBUTING.md CONTRIBUTING.md: Add file with a link to Contributor Guidelines. 2015-05-03 21:07:17 +03:00
LICENSE all: Update READMEs. 2021-05-27 15:41:08 +10:00
Makefile Makefile install: Add --no-run-if-empty to xargs. 2014-05-11 12:22:03 +03:00
README.md all: Update READMEs. 2021-05-27 15:41:08 +10:00
make_metadata.py make_metadata: Switch to use sdist_upip. 2018-02-02 20:30:05 +02:00
optimize_upip.py optimize_upip.py: Rework inclusion/exclusion logic. 2017-05-05 13:01:54 +03:00
sdist_upip.py sdist_upip: Don't treat files at the toplevel dir as resources. 2017-12-15 00:20:59 +02:00

README.md

micropython-lib

This is a repository of libraries designed to be useful for writing MicroPython applications.

The libraries here fall into roughly four categories:

  • Compatible ports of CPython standard libraries. These should be drop-in replacements for the CPython libraries, although many have reduced functionality or missing methods or classes (which may not be an issue for many use cases).

  • "Micro" versions of CPython standard libraries with limited compatibility. These can often provide the same functionality, but might require some code changes compared to the CPython version.

  • MicroPython-specific libraries. These include drivers and other libraries targeted at running Python on hardware or embedded systems.

  • MicroPython-on-Unix-specific libraries. These extend the functionality of the Unix port to allow access to operating-system level functionality (which allows more CPython compatibility).

Usage

Many libraries are self contained 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 base64/base64.py to the lib directory on your device.

Other libraries are packages, in which case 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.

For devices that have network connectivity (e.g. PYBD, ESP8266, ESP32), they will have the upip module installed.

>>> import upip
>>> upip.install('micropython-base64')
>>> upip.install('micropython-collections.defaultdict')
...
>>> import base64
>>> base64.b64decode('aGVsbG8sIG1pY3JvcHl0aG9u')
b'hello, micropython'
>>> from collections import defaultdict
>>> d = defaultdict(int)
>>> d[a] += 1

Future plans (and new contributor ideas)

  • Provide compiled .mpy distributions.
  • Develop a set of example programs using these libraries.
  • Develop more MicroPython libraries for common tasks.