Loading mpy files at runtime?

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
cduran
Posts: 80
Joined: Thu Mar 17, 2016 4:52 pm

Loading mpy files at runtime?

Post by cduran » Wed Jun 15, 2022 8:11 pm

I would like to know where to put the mpy files so that I can create libraries without needing to rebuild mp? I'm currently trying to do this with the Minimal build. Are there any changes I need to make to mpconfigport?

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Loading mpy files at runtime?

Post by jimmo » Mon Jun 20, 2022 5:10 am

cduran wrote:
Wed Jun 15, 2022 8:11 pm
I would like to know where to put the mpy files so that I can create libraries without needing to rebuild mp? I'm currently trying to do this with the Minimal build. Are there any changes I need to make to mpconfigport?
Normally they would be imported from the filesystem. `import foo` will first try foo.py, then foo.mpy.

Note that the minimal port has no filesystem. It only supports loading frozen code (but without the full manifest support).

cduran
Posts: 80
Joined: Thu Mar 17, 2016 4:52 pm

Re: Loading mpy files at runtime?

Post by cduran » Tue Jun 21, 2022 2:36 pm

jimmo wrote:
Mon Jun 20, 2022 5:10 am
cduran wrote:
Wed Jun 15, 2022 8:11 pm
I would like to know where to put the mpy files so that I can create libraries without needing to rebuild mp? I'm currently trying to do this with the Minimal build. Are there any changes I need to make to mpconfigport?
Normally they would be imported from the filesystem. `import foo` will first try foo.py, then foo.mpy.

Note that the minimal port has no filesystem. It only supports loading frozen code (but without the full manifest support).
Thank you, that helped a lot. I decided to use the Unix build instead since the target is an embedded linux system with both a filesystem and plenty of memory resources.

Post Reply