-
Notifications
You must be signed in to change notification settings - Fork 1k
micropython/mip: Add a new mip
library for on-device installation.
#542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
I've written a small demo of what writing a "self-hosted" (on GitHub) package will look like, including how to specify dependencies: https://github.com/jimmo/micropython-mlx90640 This can be installed by
Of course I'd prefer for a driver like this one to end up in micropython-lib and therefore get all the benefits of being bytecode compiled etc, but this third-party publishing (to github or other web server) is still very much a use case we want to support. |
Another artifact of the build is a top-level |
I checked the frozen version of this new upip, compared to the old one (compiled with mpy-cross v6 using -O0, ie no optimisations). This is to see how the new one compares to the old one in terms of flash size. Note that the new upip relies on urequests, so the total size of the new upip needs to include the size of urequests. Old upip size:
New upip+urequests combined size:
So the new upip combined with urequests is about 500 bytes smaller (around 10% smaller) than the old upip. Even bigger savings are made when urequests already exists for other reasons. In that case upip on its own is just 2464 bytes frozen (on rp2). Furthermore the dependencies on built-in C modules are reduced with the new upip. The dependencies are:
So gc, errno, zlib and uctypes are no longer required by the new upip, compared to the old one. |
I've pushed an updated version that adds two features requested via private feedback:
|
What about the ability to do, on the unix port, Edit: maybe we can have a separate |
5ae5fdd
to
1094a03
Compare
Addressed comments above.
Yep, I want to do this like the change we made for |
This populates https://micropython.org/pi/v2 with compiled packages, suitable for use by `mip` and `mpremote`. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Riffing on "pip", "mip installs packages". This is a replacement for the previous `upip` tool for on-device installation of packages. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
upip
library for on-device installation.mip
library for on-device installation.
mip
library for on-device installation.mip
library for on-device installation.
As discussed, renamed |
Thank you, this is awesome! |
Are there any ideas on how to support platforms like Pico that aren't network-enabled? |
|
And micropython/micropython#9463 included a significant overhaul of https://docs.micropython.org/en/latest/reference/packages.html (which hasn't gone live yet, but will hopefully update soon). |
This PR adds:
mip
) that can be frozen (or manually installed) on network-capable boards for on-device installation of packages from micropython-lib (or other similar package indices).tools/build.py
) to deploy micropython-lib to a static web server suitable for access frommip
(ormpremote
when similar functionality is added).The structure of the static web server output is explained in the comments at the top of deploy.py.
mip.install()
supports the following use cases:mip.install("foo")
-- this will download the latest version of the foo package (and dependencies) from micropython-lib.mip.install("foo", version="x.y")
-- install foo version x.y, including dependencies at the version when foo x.y was publishedmip.install("foo", target="path/to/lib")
-- install foo and dependencies in specified path (otherwise defaults to the first "lib" directory in sys.path)mip.install("foo", index="https://example.com/")
-- install foo from example.com's indexmip.install("http://example.com/x/y/foo.py")
-- download foo.py directly from the URLmip.install("http://example.com/x/y/foo.json")
-- download a package, including dependencies, described by foo.json (see below)mip.install("http://example.com/x/y")
-- implicitly http://example.com/x/y/package.jsonmip.install("github:org/user/path/foo.py")
-- shortcut for github-hosted content (fetches user/path/foo.py from the default branch)mip.install("github:org/user/path/mypackage.json")
-- as abovemip.install("github:org/user")
-- this will hopefully be the common case for "self-hosted" packages.mip.install("github:org/user", version="devel")
-- as above, but using the "devel" branchMajor differences in
mip
compared toupip
:urequests
rather than having its own HTTP client. (Most boards that freezemip
also freeze urequests anyway)The package.json looks like
The "hashes" are for referencing .mpy files directly from micropython-lib. This is used by micropython-lib packages, but shouldn't be used for self-hosted ones. The "urls" allows arbritrary URLs to be fetched, and "deps" allows recursive dependencies, e.g. a self-hosted package might want to provide some urls to their own files, and then depend on some micropython-lib packages (or a package json in another github repo).
Note: deploy.py requires micropython/micropython#9437
This work was funded through GitHub Sponsors.