MicroPython package (module!) manager ideas

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: MicroPython package (module!) manager ideas

Post by stijn » Thu May 01, 2014 6:49 pm

Building outside the tree is possible though: it's a matter of including the necessary headers and then linking against the main executable, the linker's happy with that. That's still a couple of steps away from loading the lib built like that, but eg if you want simple plugin-style external functionality without having to recompile uPy you could have all your external libs export a function init() or so, then add sunctionality in main() or in the core lib to dlopen/LoadLibrary, followed by dlsym/GetProcAddress to get the init() function and run it. Just tried this and it works.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: MicroPython package (module!) manager ideas

Post by pfalcon » Thu May 01, 2014 7:02 pm

That works, and trivial to do on Linux (or more exactly, with ELF binaries format), even using "ffi" module. I doubt that would work on Windows due to funky DLL import handling. So, one would need to define "API dispatch table" to get around binary file format differences. But hard problem is not that table, but what to put into it - more specifically, what constitutes uPy "public API". There's no such, or more exactly, all uPy API is currently public and unstable - so bin modules are not going to work unless freshly complied by yourself. And then, not to forget that uPy is bare-metal project first of all, so whoever wants to add dynamic module support to *uPy* (and not random port-specific hack), should think about bare-metal ports. Not too hard to deal with either - "just" learn how to build completely PIC code for all possible and impossible platforms and write converter from ELF to much more simple bin format. But as I told, nobody volunteered to work on all these "exciting" tasks.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

Post Reply