Is it possible to write C/C++ extensions to micropython that can be loaded dynamically at runtime (specifically by the Linux port)? I have found documentation that shows me how to write extensions and compile them directly into the interpreter, but I would like to distribute my (cross compiled) extension package separately from the micropython interpreter baked onto my embedded Linux target. Does upip support this?
Thank you.
--wpd
Dynamic C/C++ extensions to micropython
Re: Dynamic C/C++ extensions to micropython
For linux the answer is yes. You can use FFI. There are examples of calling the C runtime library through FFI in micropython-lib.
I'd recommend that you download a copy of micropython-lib and search through for the string ffi
Having said that, the stuff in the C code will need to be independent of micropython (i.e. it won't be able to make any calls into micropython).
I'd recommend that you download a copy of micropython-lib and search through for the string ffi
Having said that, the stuff in the C code will need to be independent of micropython (i.e. it won't be able to make any calls into micropython).
Re: Dynamic C/C++ extensions to micropython
https://github.com/micropython/micropython/pull/1627
As such dynamic modules don't exist except as a proof of concept, upip obviously doesn't support them.Does upip support this?
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/
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/
Re: Dynamic C/C++ extensions to micropython
https://github.com/stinos/micropython/c ... indows-pyd possibly in combination with https://github.com/stinos/micropython-wrap might do what you want on linux, i.e. compile and link a 'foo.so' then load it dynamically (using dlopen and the likes) upon 'import foo'. Has some disadvantages: completely different implementation from the one pfalcon mentions, not in the offical fork, apart from the Travis build it has not been used extensively on unix (but I do make very heavy use of it on windows without problems), last time I tried I couldn't get FATFS to link properly with -rdynamic.
-
- Posts: 288
- Joined: Sun May 04, 2014 8:54 am
Re: Dynamic C/C++ extensions to micropython
Ist there a roadmap or general idea what has to happen to finish this up?pfalcon wrote: ↑Fri Jan 26, 2018 6:39 pmhttps://github.com/micropython/micropython/pull/1627
As such dynamic modules don't exist except as a proof of concept, upip obviously doesn't support them.Does upip support this?