Skip to content

Conversation

@stek29
Copy link

@stek29 stek29 commented Jan 22, 2026

Summary

Adds a new sub-command for mpremote mip: mpremote mip download, inspired by pip download, which accept same packages and uses same logic as mip install, but downloads files to local filesystem instead of remote micropython board.
Fixes #18711.

A use case: run mip download for all the dependencies, and add ./lib to python.analysis.extraPaths or whatever your ide/setup uses -- and now you have a proper code completion and go to definition working with same code obtained by same command as the code running on the board.

An issue on Raspberry Pi forums by someone else on this with more details: https://forums.raspberrypi.com/viewtopic.php?t=377948

Testing

  • tested that mip install maintains old behaviour with no changes.
  • tested that mip download works without a connected device, but also works with connected devices when --mpy is set to download mpy files.

@stek29
Copy link
Author

stek29 commented Jan 22, 2026

the build failures seem to be unrelated to this PR and are failing on github internal errors while cloning git dependencies.

@codecov
Copy link

codecov bot commented Jan 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (f1363d8) to head (01ce305).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #18712   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files         171      171           
  Lines       22298    22298           
=======================================
  Hits        21937    21937           
  Misses        361      361           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Jan 22, 2026

Code size report:

Reference:  github: Install Python 3.11 for Windows CI runs. [f1363d8]
Comparison: tools/mpremote/tests: Add test for mip download command. [merge of 01ce305]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@Josverl
Copy link
Contributor

Josverl commented Jan 22, 2026

I think this is a useful feature, Thanks for the contribution.

Would it be possible to add a test for this to the mpremote tests?
Even if the source is a local path (to avoid network issues) that would help ensure stability.

I'll review in more detail in the next few days.

@stek29
Copy link
Author

stek29 commented Jan 24, 2026

@Josverl I've added a test. I'm still not sure whether running the python files with host python3 instead of running diff would've been better, so if you'd prefer that approach please tell me and I'll change the test.

upd: force pushed with rebase on top of latest master, fixed signoff.

Add local filesystem download mode for mip with shared install logic,
add --mpy-version and per-command defaults for --mpy/--target, and
avoid probing inside _install_package to allow download without device.

Fixes micropython#18711.

Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
@Josverl Josverl added the tools Relates to tools/ directory in source, or other tooling label Jan 24, 2026
@Josverl
Copy link
Contributor

Josverl commented Jan 26, 2026

Also I have been ponderign on the cmdline options.

to me the most obvious thing would be to use mip install for both local and remote install, and use the --path prefix (':') to differentiate where the module gets installed to, with the default being the MCU.

MCU default install:
mpremote mip install requests

MCU specific install:
mpremote mip install --target :/mylib requests

host local install:
mpremote mip install --no-mpy --target typings requests
or
mpremote mip install --no-mpy --target ./typings requests

@Josverl
Copy link
Contributor

Josverl commented Jan 26, 2026

I think the docs should clarify that --mpy, --no-mpy flags are only valid for the micropython index , or a warning should be given, when I request .mpy and the source only holds .py files.

for example :
mpremote mip download --mpy --target typings2 requests github:josverl/mp_wcwidth
will download partial .mpy , and partial .py

@stek29
Copy link
Author

stek29 commented Jan 26, 2026

Also I have been ponderign on the cmdline options.

to me the most obvious thing would be to use mip install for both local and remote install, and use the --path prefix (':') to differentiate where the module gets installed to, with the default being the MCU.

MCU default install: mpremote mip install requests

MCU specific install: mpremote mip install --target :/mylib requests

host local install: mpremote mip install --no-mpy --target typings requests or mpremote mip install --no-mpy --target ./typings requests

I thought about it, but that would break backwards compatibility for the target, and it won't be obvious because it would just create the directories on local fs.

@Josverl
Copy link
Contributor

Josverl commented Jan 26, 2026

Then that is something to mention in the PRs
"Trade-offs and Alternatives" section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tools Relates to tools/ directory in source, or other tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow mpremote mip to download libraries as local files

2 participants