[Python-ideas] Summer of Code Project Idea: Python Apps in the Browser

David Glick dglick at gmail.com
Fri Aug 26 04:42:12 CEST 2011


On 8/25/11 3:45 PM, Raymond Hettinger wrote:
> The http://gumbyapp.com/ <http://t.co/mPKzyp1> project succeeded in 
> getting Python to run in the browser but it can't import pure python 
> modules (because there is no filesystem in the browser).
>
> I think it would be wonderful to beef-up this project by bundling-in 
> the rest of the standard library.  Gumby was built by compiling 
> CPython to LLVM and then generating Javascript.  ISTM it would be 
> possible to write a script to transform pure python standard library 
> modules into C strings that could also be part of the final build. 
>  The import-statement would have to be hooked to search for the C 
> string instead of a physical file.
>
> If that technique works, it may not be hard to extend it so that user 
> defined python modules could also be incorporated.  If so, it would 
> become possible to create standalone Python apps that run in the 
> browser.   The process is likely to be inefficient, but the gumbyapp 
> site shows that it might be good enough for some purposes.
Mostly as a joke for this past April Fool's day, Matthew Wilkes and I 
cobbled together an import-over-AJAX mechanism [1] for the Python 
interpreter produced by Emscripten [2] (which similarly translates LLVM 
into Javascript).

[1] http://davisagli.com/blog/the-making-of-zodb.ws
[2] https://github.com/kripken/emscripten/wiki

Our goal was getting ZODB running in the browser, with storage in HTML5 
localstorage, as demonstrated at http://zodb.ws -- so we focused only on 
the pieces of the stdlib necessary to get that running; the emscripten 
interpreter was missing a lot and we didn't have time to learn the 
emscripten toolchain so we resorted to various hacks (e.g. a simple 
incrementer in place of time.time()) and borrowing pure-Python 
implementations from pypy.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110825/71c231a0/attachment.html>


More information about the Python-ideas mailing list