Re: Porting Pyro to micropython

Irmen de Jong <[email protected]> Mon, 17 Feb 2014 22:07:33 +0100
Newsgroups gmane.comp.python.pyro
Message-ID <[email protected]>
On 17-2-2014 20:25, Richard van Bemmelen wrote:
> Well, isn't Pyro a full Python solution? Therefore it should run on other platforms that
> support Python as well.
> For instance, it worked out of the box on my Raspberry Pi, an ARM processor...
> 
> 

Mmhhh you're right, Pyro is 100% pure Python but it depends on a fair amount of standard
library modules such as os, socket, threading, select. This is the main issue here, read
below.

> 
> 2014-02-17 12:59 GMT+01:00 Frédéric <[email protected] <mailto:[email protected]>>:
> 
>     So, why not porting Pyro to micropython? This would be great to be able to
>     write low-level code on the pyboard, which has limited ressources, and is
>     more I/O oriented, and then have a higher-level code running on a
>     desktop-like computer. Mostly what we did to drive our intruments ;o)
> 
>     The question is: can Pyro run on micropython? I don't think it is possible
>     to port the complete server code, but having some basic Pyro core running
>     should be great, even if we don't maintain compatibility with official
>     Pyro project ; some fork would be OK too.

It is a very interesting idea and I like it!

So I've compiled micropython (on OSX) and while it does start it has some deal breaking
problems. The most important one being that it has no standard library modules
whatsoever. It does seem to include a minimalistic socket module (microsocket) but
almost all of the rest is missing including the fundamental ones such as os.
Also all serialization modules are missing (pickle, json, marshal) and Pyro cannot run
without at least one of them. You can try to get the Serpent serializer running but that
one needs the ast standard library module to deserialize stuff, and that is not present
either :-)  (maybe you can hack something together using eval?)


It does claim to parse 100% of the python3 syntax, so that is a big plus. Unfortunately
it crashes when parsing a long literal such as 4L, but that should be a simple bug to fix.

I have no idea if and how correctly its package/module import mechanism works. Unless
you can somehow cram all of Pyro in a single module this is a requirement as well.


>     What do you think? I already have a non-official board running micropython
>     (STM32F4-Discovery), so I can start making some tests. Where should I
>     start? Which part of the code should I dig into?

Try to get a Pyro client running (a proxy), before trying the server part.
However as noted above, you will have to somehow build a suitable subset of the python
standard library for micropython first. This sounds like a fun little project but I'm
not sure how far you can take this with the very limited number of connections to the
external world that micropython appears to provide at this time.

> 
>     Thanks for you help,
> 
>     ¹ http://www.ill.eu
>     ² http://www.micropython.org
> 
>     PS: as micropython implements python3 language, I guess it is better to
>     use Pyro4.

Yes, if at all possible use pyro4. Pyro3 has been unmaintained for quite some time.


Bottom line: I think a lot of work needs to be put in Micropython first before you can
attempt to run Pyro on it. You might get away with a lot of stubs but there's some
essential modules missing that are absolutely necessary for Pyro to run.


Irmen de Jong


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk