mip: Better support for natmod installations#1140
Open
jonnor wants to merge 1 commit into
Open
Conversation
jonnor
force-pushed
the
mip-natmod-install
branch
from
July 16, 2026 14:22
ce8ef66 to
5d4e25d
Compare
Allows to use a single URL to specify a native module package, and mip will then lookup the correct hardware architecture and MicroPython ABI version. Signed-off-by: Jon Nordby <jononor@gmail.com>
jonnor
force-pushed
the
mip-natmod-install
branch
from
July 16, 2026 14:30
5d4e25d to
c3cee68
Compare
Contributor
|
I see the need for a solution to this problem, and i like the simplicity of the solution. To me the MPY_ARCH and MPY_VERSION placeholders are a bit magical. Apart from some bikeshedding on the prefix , MP / MPY , Possibly that can also be solved by a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
It is possible to install .mpy files using mip, including those that have native code (native modules). But currently one must specify the exact file URL for such files - which for native modules means knowing the correct ABI version and architecture version - something users rarely know offhand. This makes it difficult to document how to install a natmod, and makes it difficult to have scripts that automatically install the correct version.
This change allows using a single URL to specify a native module package - regardless of the ABI/architecture. mip will then lookup the correct hardware architecture and MicroPython ABI version, and substitute this into the URL before doing the download/install.
The use of variables that are substituted allows some flexibility wrt different locations/layouts for .mpy files. This is useful because there is currently no standard (to my knowledge) for how to lay out. So this should be immediately useful to existing distributions of mpy natmods.
Note: for
import footo work the .mpy file, the file itself must be namedfoo.mpy. Thus the MPY_ARCH and MPY_VERSION markers can only meaningfully be in directory part of a path.Testing
Tested on RP2 port using a Pico W. Example code follows.
Installs from https://github.com/emlearn/emlearn-micropython project - should work on any hardware supported by emlearn-micropython. By removing the network part, should also work on Unix port.
Trade-offs and Alternatives
Small increase in code size of the mip package.
It adds nothing to the core runtime of MicroPython. An alternative implementation that would do versioned/architecture handling at import time would likely increase size of the code.
Generative AI
I did not use generative AI tools when creating this PR.