Page 1 of 1

minipip -- tool for installing both upip and pip compatible packages

Posted: Mon May 17, 2021 3:40 pm
by aivarannamaa
So far Thonny has been using micropip.py by pythoncoder for installing upip-compatible packages to local disk before uploading them to the device.

The fact that micropip.py supports only upip-compatible packages, has caused confusion among users, though, as several micropython packages (eg. `micropython-oled`) are not compatible with upip.

Therefore I created a new tool, inspired by micropip.py, which installs upip-compatible packages quite like micropip.py, but delegates pip-compatible packages to "pip install --target temp_dir ...".

I haven't published it as separate project yet, as hoped to get your feedback first. The code (single module) is currently available at https://raw.githubusercontent.com/thonn ... minipip.py. It should be compatible with Python 3.6+ and the basic usage doesn't require anything besides stdlib (uploading via serial requires rshell)

Example usages:

* minipip.py install --target /media/user/circuitpy adafruit-circuitpython-ssd1306
* minipip.py install --port /dev/ttyACM0 --target /lib micropython-logging

Here are the full instructions:

Code: Select all

usage: minipip.py [-h] [-r [REQUIREMENT_FILE [REQUIREMENT_FILE ...]]] [-p [PORT]] -t TARGET_DIR [-i INDEX_URL] [-v] [-q] {install} package_spec [package_spec ...]

Meant for installing both upip and pip compatible distribution packages from PyPI and micropython.org/pi to a local directory, USB volume or directly to MicroPython filesystem over
serial connection (requires rshell).

positional arguments:
  {install}             Currently the only supported command is 'install'
  package_spec          Package specification, eg. 'micropython-logging' or 'micropython-logging>=0.6'

optional arguments:
  -h, --help            show this help message and exit
  -r [REQUIREMENT_FILE [REQUIREMENT_FILE ...]], --requirement [REQUIREMENT_FILE [REQUIREMENT_FILE ...]]
                        Install from the given requirements file.
  -p [PORT], --port [PORT]
                        Serial port of the device
  -t TARGET_DIR, --target TARGET_DIR
                        Target directory (on device, if port is given, otherwise local)
  -i INDEX_URL, --index-url INDEX_URL
                        Custom index URL
  -v, --verbose         Show more details about the process
  -q, --quiet           Don't show non-error output

Re: minipip -- tool for installing both upip and pip compatible packages

Posted: Tue May 18, 2021 12:23 pm
by pythoncoder
That sounds like a great enhancement, especially the ability to install directly to a device. The scope of micropip is limited to replicating the functionality of upip under CPython (on Linux, Windows and OSX).

Re: minipip -- tool for installing both upip and pip compatible packages

Posted: Tue May 18, 2021 12:51 pm
by stijn
Do you plan adding support for installing from local sources (e.g. a local clone of micropython-lib)?

Re: minipip -- tool for installing both upip and pip compatible packages

Posted: Tue May 18, 2021 1:50 pm
by aivarannamaa
stijn wrote:
Tue May 18, 2021 12:51 pm
Do you plan adding support for installing from local sources (e.g. a local clone of micropython-lib)?
At the moment this use case doesn't feel important enough to me, so it's rather no.

I now published the tool on GitHub (https://github.com/aivarannamaa/minipip) and PyPI (pip install minipip).