Looking for the howto use Micropython in docker #15413
-
I am looking to use a dockerized micropython in GHA / pytest to verify that the micropython type-stubs and typings modules do not interfere with micropython at runtime, and docker seems to be a simple way to do that by make use of work already done. a snippet from the test: cmd = f"docker run -u 1000 -v .:/code --rm micropython/unix:{mp_version} micropython {check_file}"
result = subprocess.run(cmd, shell=True, cwd=snip_path, text=True, capture_output=True)
error = [line for line in result.stdout.split("\n") if "Traceback" not in line]
assert result.returncode == 0, error all good, but its a bit of a black box , and I´d like to understand better how this is setup internally, and how to inject modules into the docker run -u 1000 -it --rm micropython/unix:latest
MicroPython v1.23.0 on 2024-06-13; linux [GCC 12.2.0] version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import sys;print(sys.path)
['', '.frozen', '//.micropython/lib', '/usr/lib/micropython'] Both folders cannot be located in the image, are they intended as placeholder that can optionally be mounted ? I tried looking at the docker image but could not figure out whether i need to look at configuration for my host(s), docker, or micropython. @mattytrentini , I think you may know ...
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Good to see the containers getting some love! :) In case it's not obvious, to create these containers I just build the default unix build - and those are the standard paths for the unix build... The > docker run -it --rm micropython/unix
MicroPython v1.23.0 on 2024-06-13; linux [GCC 12.2.0] version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> import sys; print(sys.path)
['', '.frozen', '/root/.micropython/lib', '/usr/lib/micropython']
>>> At a guess, I'd say that In any case, you can have multiple volume mounts and you can configure Does that help? |
Beta Was this translation helpful? Give feedback.
-
Indeed defining $HOME correctly sets the 3rd path :
and then I can mount my lib folder in that location, without a need to change the sys.path
|
Beta Was this translation helpful? Give feedback.
Good to see the containers getting some love! :)
In case it's not obvious, to create these containers I just build the default unix build - and those are the standard paths for the unix build...
The
//.micropython/lib
is the only interesting one - if I run as root (inside WSL) it looks different:At a guess, I'd say that
//.micropython/lib
is the home folder of the user that docker runs under - so perhaps your user doesn't have a home folder?In an…