CPython in the web browser under Native Client

I have been doing some work to extend Google's Native Client [1] to support dynamic linking [2]. For those who haven't heard of it, Native Client is a sandboxing system for running a subset of x86 code. It is proposed as a way of running native code inside web apps.
One of my aims has been to get CPython working in the web browser under Native Client without having to modify CPython.
I recently got to the point where modules from the Python standard library are importable under Native Client, including (as a demonstration) the Sqlite extension module. Sqlite also requires no modification - it builds straight from the Debian package.
I've written a simple REPL to demonstrate Python running in the browser. There are some screenshots on my blog [3]. I haven't implemented accessing the DOM from Python yet - that's another project for later. :-)
Mark
[1] http://code.google.com/p/nativeclient/ [2] http://plash.beasts.org/wiki/NativeClient [3] http://lackingrhoticity.blogspot.com/2009/06/python-standard-library-in-nati...

Wow. I'm impressed.
On Sun, Jun 14, 2009 at 9:09 AM, Mark Seabornmrs@mythic-beasts.com wrote:
I have been doing some work to extend Google's Native Client [1] to support dynamic linking [2]. For those who haven't heard of it, Native Client is a sandboxing system for running a subset of x86 code. It is proposed as a way of running native code inside web apps.
One of my aims has been to get CPython working in the web browser under Native Client without having to modify CPython.
I recently got to the point where modules from the Python standard library are importable under Native Client, including (as a demonstration) the Sqlite extension module. Sqlite also requires no modification - it builds straight from the Debian package.
I've written a simple REPL to demonstrate Python running in the browser. There are some screenshots on my blog [3]. I haven't implemented accessing the DOM from Python yet - that's another project for later. :-)
Mark
[1] http://code.google.com/p/nativeclient/ [2] http://plash.beasts.org/wiki/NativeClient [3] http://lackingrhoticity.blogspot.com/2009/06/python-standard-library-in-nati... _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/guido%40python.org

Mark Seaborn wrote:
[3] http://lackingrhoticity.blogspot.com/2009/06/python-standard-library-in-nati...
Very cool!
Cheers, Nick.

Hey Mark,
http://lackingrhoticity.blogspot.com/2009/06/python-standard-library-in-nati...
Really glad to see that you carried on with this -- great work!!
I guess the elders will simply say that it's history repeating itself, but Grails 2.0 is looking promising! We can finally give that upstart Javascript a run for its money (despite ES5 looking nice...) -- not to mention Google Wave/Opera Unite/etc.
Now, the real blocker is accessing the DOM from Python. I haven't looked into the source code deeply, but perhaps Kroll could be of help:
* http://github.com/jhaynie/kroll/tree/master
I was able to do the following with Titanium Desktop (which uses it) to access the DOM from Python:
<script type="text/python"> def hello(s): document.getElementById('foo').innerHTML = s </script> <div> Hello <div id="foo">World</div></div> <script>hello("tav")</script>
More relevant links:
* http://www.appcelerator.com/ * http://github.com/appcelerator/
Anyways, I'm sure others might have a better idea of integrating Python and the DOM.
Well done again!
participants (4)
-
Guido van Rossum
-
Mark Seaborn
-
Nick Coghlan
-
tav