Skip to content

windows pydevices variant: run built-in module __init__ on import - #18

Merged
bdbarnett merged 1 commit into
mainfrom
windows-builtin-init
Sep 25, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
windows-builtin-init

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

For PyDevices/displayif#41.

With this, micropython.exe registers jpegio's LVGL decoder on import jpegio the way unix does. The windows port is at the core ROM level, where MICROPY_MODULE_BUILTIN_INIT is off, so jpegio's __init__ never ran there. The pydevices windows variant now turns it on. That's one line in variants/windows/pydevices/mpconfigvariant.h, and the vst3-engine variant is unchanged.

I built it with upstream's make, cross-compiled, into its own build directory (ports/windows/build-desk-jpegio, the kitchen-sink manifest, under the build lock), and ran the same script on each interpreter:

import lvgl as lv; lv.init(); import jpegio; print(jpegio.lvgl_decoders())
this build            win32  ('jpegio', 'LODEPNG', 'BIN')
bin/micropython.exe   win32  ('LODEPNG', 'BIN')
bin/micropython       linux  ('jpegio', 'LODEPNG', 'BIN')

displayif's tests/jpegio/test_jpegio_lvgl.py passes in full on this build: 3 exact digests, the file source, memory, and the deinit/init cycle. PyDevices/displayif#43 makes that test require import-time registration on win32. It fails on the current bin/micropython.exe, so it catches the missing hook.

After this merges, tools/build_interpreters.sh --only mp-windows in the anchor puts it in bin/micropython.exe. I didn't rebuild the shared binaries.

The windows port sits at the core ROM level, where
MICROPY_MODULE_BUILTIN_INIT is off, so micropython.exe never ran jpegio's
__init__ and `import jpegio` after lv.init() left LVGL without the jpegio
decoder (PyDevices/displayif#41). Unix gets it from the extra-features level;
the windows variant now sets it directly.
bdbarnett added a commit to PyDevices/displayif that referenced this pull request Sep 25, 2026
…41) (#43)

test_jpegio_lvgl.py now fails when `import jpegio` after lv.init() registers
nothing on linux, darwin or win32, naming MICROPY_MODULE_BUILTIN_INIT. The
windows half needs PyDevices/micropython-pydevices#18, which turns the hook on
in the PyDevices windows variant; the README says so and tells other windows
builds to call register_lvgl_decoder().
@bdbarnett
bdbarnett merged commit 6cc9959 into main Sep 25, 2026
@bdbarnett
bdbarnett deleted the windows-builtin-init branch September 25, 2026 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant