Replies: 1 comment 4 replies
-
Nice one, thanks for sharing and the extra detail and the efforts required. It really can be hit and miss which libraries port trivially, and which ones are harder than expected. It's hard to know / estimate how much effort it'll be until you're in the deep end! I recommend submitting your link to https://awesome-micropython.com/ if you haven't already, and/or a PR to micropython-lib if it's pretty much stable already :-D |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Ever wanted to read or write .zip archive files in MicroPython? Now there is a module for that: https://github.com/jonnor/micropython-zipfile
It supports the most common subsets of ZIP archives, including DEFLATE compression (when available in the MicroPython firmware build). I ported this from CPython 3.12, and used their quite comprehensive test suite (around 160 test-cases) to guide the development. I removed/skipped out some of the more niche tests though, to focus on core functionality relevant for a MicroPython usecase.
It is the first time I ported non-trivial (but reasonably stand-alone) CPython code to MicroPython, and it was interesting to see what kind of incompatibilities that exist. Many are rather minor, but it all adds up, taking several hours to address them all. Those considering to port other Python code to MicroPython (while still being runnable under CPython), might find some of the strategies interesting. See especially the top of
zipfile.py
, where I try to handle all the differences.I initially created this because I wanted to support Numpy .npz files (which are ZIP archives). This format is popular for Data Science / Digital Signal Processing / Machine Learning / etc. And I needed it for https://github.com/emlearn/emlearn-micropython/ - a MicroPython library for Machine Learning.
But zip files are used for many purposes, so I hope this can be useful for someone else :)
Beta Was this translation helpful? Give feedback.
All reactions