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

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
aivarannamaa
Posts: 171
Joined: Fri Sep 22, 2017 3:19 pm
Location: Estonia
Contact:

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

Post by aivarannamaa » Mon May 17, 2021 3:40 pm

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
Aivar Annamaa
https://thonny.org

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

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

Post by pythoncoder » Tue May 18, 2021 12:23 pm

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).
Peter Hinch
Index to my micropython libraries.

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

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

Post by stijn » 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)?

User avatar
aivarannamaa
Posts: 171
Joined: Fri Sep 22, 2017 3:19 pm
Location: Estonia
Contact:

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

Post by aivarannamaa » Tue May 18, 2021 1:50 pm

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).
Aivar Annamaa
https://thonny.org

Post Reply