From 35e3c9e4ffc1c5fbd92fa159aa9dfa504f14c495 Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Thu, 27 May 2021 16:53:02 +1000 Subject: [PATCH] python-ecosys: Move urequests to python-ecosys. Signed-off-by: Jim Mussared --- README.md | 29 +++++-------------- .../urequests/example_xively.py | 0 .../urequests/metadata.txt | 0 .../urequests/setup.py | 0 .../urequests/urequests.py | 0 python-stdlib/README.md | 10 +------ 6 files changed, 8 insertions(+), 31 deletions(-) rename {micropython => python-ecosys}/urequests/example_xively.py (100%) rename {micropython => python-ecosys}/urequests/metadata.txt (100%) rename {micropython => python-ecosys}/urequests/setup.py (100%) rename {micropython => python-ecosys}/urequests/urequests.py (100%) diff --git a/README.md b/README.md index a38a2266..b5d1b8a4 100644 --- a/README.md +++ b/README.md @@ -4,45 +4,30 @@ micropython-lib This is a repository of libraries designed to be useful for writing MicroPython applications. -The libraries here fall into roughly four categories: +The libraries here fall into four categories corresponding to the four top-level directories: - * 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). + * **python-stdlib**: Compatible versions of modules from the [Python Standard Library](https://docs.python.org/3/library/). These should be drop-in replacements for the Python libraries, although many have reduced functionality or missing methods or classes (which may not be an issue for many most 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. + * **python-ecosys**: Compatible, but reduced-functionality versions of modules from the larger Python ecosystem, for example that might be found in the [Python Package Index](https://pypi.org/). - * MicroPython-specific libraries. These include drivers and other libraries targeted at running Python on hardware or embedded systems. +* **micropython**: MicroPython-specific modules that do not have equivalents in other Python environments. These are typically hardware drivers or highly-optimised alternative implementations of functionality available in other Python modules. - * 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). + * **unix-ffi**: These modules are specifically for the MicroPython Unix port and provide access to operating-system and third-party libraries via FFI. 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` +`base64` library, you can directly copy `python-stdlib/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. +* Provide a replacement for the previous `upip` tool. diff --git a/micropython/urequests/example_xively.py b/python-ecosys/urequests/example_xively.py similarity index 100% rename from micropython/urequests/example_xively.py rename to python-ecosys/urequests/example_xively.py diff --git a/micropython/urequests/metadata.txt b/python-ecosys/urequests/metadata.txt similarity index 100% rename from micropython/urequests/metadata.txt rename to python-ecosys/urequests/metadata.txt diff --git a/micropython/urequests/setup.py b/python-ecosys/urequests/setup.py similarity index 100% rename from micropython/urequests/setup.py rename to python-ecosys/urequests/setup.py diff --git a/micropython/urequests/urequests.py b/python-ecosys/urequests/urequests.py similarity index 100% rename from micropython/urequests/urequests.py rename to python-ecosys/urequests/urequests.py diff --git a/python-stdlib/README.md b/python-stdlib/README.md index ed7d3473..604e66fe 100644 --- a/python-stdlib/README.md +++ b/python-stdlib/README.md @@ -5,14 +5,6 @@ The libraries in this directory aim to provide compatible implementations of standard libraries to allow existing Python code to run un-modified on MicroPython. -Compatibility ranges from: - - * Many commonly-used methods and classes are provided with identical runtime semantics. - * A subset of methods and classes, with identical semantics for most use cases. - * Additional constants not provided in the main firmware (to keep size down). - * Stub methods and classes required to make code load without error, but may lead to runtime errors. - - Implementation -------------- @@ -21,7 +13,7 @@ CPython implementation. (e.g. `collections.defaultdict`) Some libraries are based on or extend from the built-in "micro" modules in the MicroPython firmware, providing additional functionality that didn't need to -be written in C. (e.g. `socket`, `struct`) +be written in C (e.g. `collections`, `socket`, `struct`). Future plans (ideas for contributors):