Ship a microcontroller only what can run on one - #46
Merged
Merged
Conversation
mip.install("pydevices") wrote 51 files to a board, about twenty of them
desktop, browser or Android backends: windisplay, wasmdisplay, pgdisplay,
sdldisplay, jndisplay, psdisplay, androidsdl, win_audio, pygame_audio,
sdl2_audio, wasm_audio, web_audio, android_audio, win32, sdl2, threading, wasm,
librt and two desktop helpers (#30). Minutes over WiFi and flash spent
on modules that cannot execute.
synchronize_mip_package.py now reads mip-split.toml from the source repository,
which names those modules per package, and routes them into pydevices-desktop,
which already require()s pydevices. The device package names its files one by
one -- package("displaydev", files=(...)) -- so the install list is the
manifest and nothing else decides it.
Measured through mip's own tools/build.py, which is what the index serves:
pydevices 51 -> 31 files
pydevices-desktop 58 -> 58, the identical set
Two guards, both shown failing: a name in mip-split.toml that no longer exists
fails the sync ("names modules that no longer exist: gonedisplay"), and so does
an MCU-side module that imports a host-only one at module scope
("busdisplay.py:21 imports the host-only module 'sdldisplay' at module scope").
Exit 1 in both cases, 0 on the real tree. A new backend nobody classifies ships
to the device, so forgetting costs a board one file, never a host an import.
The guard was re-proved after the rewrite: the planted module-scope import still fails the sync with exit 1, the real tree still exits 0, and the device package is still 31 files.
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.
The publisher half of pydevices#30. The declaration half is already on
pydevicesmainasmip-split.toml(e2bce5c), inert until this merges.The dry install listing, before and after
Through mip's own
tools/build.py, which is what the index serves — not a count of files on disk:The 20 the device stops carrying:
Nothing is added anywhere, and nothing is lost: the union of the two packages is the same 58 files it was. A desktop, browser or Android host installs
pydevices-desktopexactly as before and gets exactly what it got, because that package alreadyrequire()spydevicesandbuild.pymaterialises the requirement.Why this is safe
auto.pystays on the device in every case. Every host branch indisplaydev/auto.py,audiodev/auto.pyandmultimer/auto.pyimports inside the function, so importing the module on a board is fine — and callingAutoDisplay()there was never the intent ("board configs stay MCU-shaped wiring only",displaydev/auto.py:9). Checked before writing any of this: no MCU-side module imports a host-only one at module scope, which is the one way the split could break an import.The guards, both shown failing
A split declared in one file and enforced nowhere rots the first time somebody renames a module.
The asymmetry is deliberate: a new backend that nobody classifies ships to the device. So the cost of forgetting is one extra file on a board, never a missing import on a host.
What this does not do
It does not create new packages, new PyPI distributions or new install commands —
pydevicesandpydevices-desktopare the same two names, and the board bring-up path (mip.install pydevices, then the board package) is unchanged. The issue listed per-platform packages and an extras split as the other options; this is the third, and the cheapest to undo.