Update micropip docs.

main
Peter Hinch 2021-04-16 13:29:45 +01:00
rodzic c87587d426
commit a1173b50a8
1 zmienionych plików z 30 dodań i 57 usunięć

Wyświetl plik

@ -1,71 +1,44 @@
# 0. Installing MicroPython library modules # Contents
Paul Sokolovsky, the author of most of the micropython library and major 1. [Installing MicroPython library modules](./README.md#1-installing-micropython-library-modules)
contributor to MicroPython, has forked the MicroPython project. This is the 2. [micropip](./README.md#2-micropip) Runs on a PC
[pycopy fork](https://github.com/pfalcon/pycopy). 3. [Overriding built in library modules](./README.md#3-overriding-built-in-library-modules)
Official firmware may be found on [micropython.org](https://micropython.org/). # 1. Installing MicroPython library modules
Each firmware build has its own library. Some modules in the Pycopy library are
incompatible with the official firmware.
Libraries may be installed by copying files from the appropriate library Paul Sokolovsky has forked the MicroPython project. This is the
repository to the target device. However this requires some attention to detail [pycopy fork](https://github.com/pfalcon/pycopy). The library for the `pycopy`
where there are dependencies or where modules are organised as Python packages. fork may be found [here](https://github.com/pfalcon/micropython-lib).
Each version has a tool known as `upip` for installing library and user This guide is for users of official MicroPython firmware as found on
contributed modules modelled on Python's `pip`. This handles dependencies and [micropython.org](https://micropython.org/). The library at
builds the correct directory structure on the target. [micropython-lib](https://github.com/micropython/micropython-lib) is compatible
with the official firmware. Users of pycopy should consult that project's
documentation.
Note that `pip` and `pip3` cannot be used for MicroPython modules. This is Libraries on [PyPi](https://pypi.org/) may or may not be compatible with
because the file format is nonstandard. The file format was chosen to enable official firmware. This is resolved by official `upip` (and its `micropip`
the installer to run on targets with minimal resources. derivative): it first searches the official library. Only if no match is found
does it install from PyPi. For this and other reasons, `pip` and `pip3` should
# 1. Contents not be used to install MicroPython libraries. Use of `upip` is detailed in the
0. [Installing MicroPython library modules](./README.md#0-installing-micropython-library-modules)
1. [Contents](./README.md#1-contents)
2. [Users of Pycopy firmware](./README.md#2-users-of-pycopy-firmware)
3. [Users of official MicroPython](./README.md#3-users-of-official-micropython)
3.1 [micropip](./README.md#31-micropip) Runs on a PC
4. [Overriding built in library modules](./README.md#4-overriding-built-in-library-modules)
###### [Main README](../README.md)
# 2. Users of Pycopy firmware
The library for the `pycopy` fork may be found [here](https://github.com/pfalcon/micropython-lib).
Library modules located on [PyPi](https://pypi.org/) are correct for the
`pycopy` firmware.
The `upip` tool may be found in the `tools` directory of `pycopy`. This version
should be used as it installs exclusively from PyPi.
For hardware which is not network enabled, `upip` may be run under the Unix
build of MicroPython to install to an arbitrary directory on a PC. The
resultant directory structure is then copied to the target using a utility such
as [rshell](https://github.com/dhylands/rshell).
Usage of `upip` is documented in the
[official docs](http://docs.micropython.org/en/latest/reference/packages.html). [official docs](http://docs.micropython.org/en/latest/reference/packages.html).
# 3. Users of official MicroPython
The library at [micropython-lib](https://github.com/micropython/micropython-lib)
is compatible with the official firmware. As of version 1.11 the included
version of `upip` will install the correct library module for use with this
firmware, searching for modules in the official library before searching
[PyPi](https://pypi.org/).
Users of non-networked hardware such as the Pyboard 1.x can use `upip` with the Users of non-networked hardware such as the Pyboard 1.x can use `upip` with the
Unix build of MicroPython to install a library module to an arbitrary directory Unix build of MicroPython to install a library module to an arbitrary directory
on a PC, from where the files and directories can be copied to the target on a PC, from where the files and directories can be copied to the target
hardware. This approach has the drawback of requiring the Unix build, which has hardware. `upip` and its dependency `upip_utarfile` may be found in the `tools`
to be built from source. directory of the source tree. This approach has the drawback of requiring the
Unix build, which has to be built from source. Alternatively `micropip.py` in
this repo may be employed, which runs under CPython.
For those unable or unwilling to do this, `micropip.py` in this repo may be Alternatively libraries may be installed by copying files from the MicroPython
employed. library repository to the target device. However this requires some attention
to detail where there are dependencies. Where modules are organised as Python
packages the directory structure must be maintained.
## 3.1 micropip ###### [Main README](../README.md)
## 2. micropip
This runs under Python 3.2 or above. Library and user modules are installed to This runs under Python 3.2 or above. Library and user modules are installed to
the PC for transfer to the target. It is cross-platform and has been tested the PC for transfer to the target. It is cross-platform and has been tested
@ -88,7 +61,7 @@ $ micropip.py install -p ~/rats micropython-uasyncio
###### [Contents](./README.md#1-contents) ###### [Contents](./README.md#1-contents)
# 4. Overriding built in library modules # 3. Overriding built in library modules
Some firmware builds include library modules as frozen bytecode. On occasion it Some firmware builds include library modules as frozen bytecode. On occasion it
may be necessary to replace such a module with an updated or modified may be necessary to replace such a module with an updated or modified