Simple, repeatable deployments in a MicroPython environment
Have you ever suffered from "It works on my machine"?
Most of us have, as users (well, it doesn't work on mine!") or as developers ("what have I done wrong this time?".
The cause is almost always down to something that's on the developer's machine that they have forgotten about, but make use of. That something doesn't get included in the installation process, so users may not have it installed.
There's a great way to avoid that.
Testing an installation process if you have an OS
If the software you're developing runs under an Operating System, run the installation in a freshly-created virtual machine. That will ensure that you start without somethings installed. You'll only have the software that's specified in your installation process.
If that works, you're in good shape.
What about installing MicroPython software on devices like the Raspberry Pi Pico?
Testing an installation process for MicroPython projects
A comparable deployment process has three stages. You need to
- Wipe the MicroPython file system completely
- Install a known version of MicroPython
- Install the application code
Installing the application code
Use mpremote to install MicroPython files
mpremote cp secrets.py :secrets.py
mpremote cp network_connection.py :network_connection.py
mpremote cp -r mp/ :
mpremote cp -r pi_finder/ :
A repeatable, reliable process
You'll find that running mpremote in a script is a great way to install all the files your application needs.
If you first run mp-installer.py with the nuke option, you'll have a repeatable automated installation process.
That way you'll be confident that your users will get all the software they need to run your application.