Ok, I ‘ve been off for a little time right now. The main reason, is that I spend some time hacking my new Wireless access point: WRT54GS.
I spend a lot of time tweaking the config to use this in client mode with dhcp thought the WAN port and other nuts. I spend some time on http://www.brest-wireless.org too. But this is the mean reason of this post :)
Some people would think I’m a crazy boy but this is perhaps true. I managed to cross-compile python for the WRT. If you ask me why, I would simply answer that there is a lot of network stuff on a WRT that can be writen in a couple of python lines: dhcpd, dns cache, http server, dynamic pages rendering, dynamic firewall rules (check out last posts ..), diagnostics tools .. That’s it, now we need to figure out if this is do-able :)
WRT use a broadcom misp processor, so we need:
- to install a cross-compile environnement: Not to hard.
- tweak the python Makefile to use this, a little more funny but it works.
- first tests..
As you can imagine, this doesn’t work at all :) The main issue is that current python use g++ (2.3), and the WRT only came with uClib, not the uClib++. After this wrong experience, I decided to take a old python: 1.5.2 . This one only needs gcc fine ! Ok, let’s see the result:
telnet host50 Trying 192.168.1.50... Connected to host50.soif.fr. Escape character is '^]'. BusyBox v1.00 (2004.11.20-09:17+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands. @OpenWrt:/# /tmp/python Could not find platform independent libraries <prefix> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] 'import exceptions' failed; use -v for traceback Warning! Falling back to string-based exceptions 'import site' failed; use -v for traceback Python 1.5.2 (#2, Nov 21 2004, 05:52:09) [GCC 3.2.3 with Broadcom modifications] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> import sys >>> import os Traceback (innermost last): File "<stdin>", line 1, in ? ImportError: No module named os >>>
As you can see on this little capture, some parts of the interpreter works, but other don’t. The main issue is the build of modules. Something goes wrong at the link (ld), and I was unable to fully compile this.
Anyway this is not a big issue, because right now, I don’t think python 1.5.2 is a great challenger anyways. For people interested the python exec does 1.6Mo but a WRT54GS has 6Mo of free ROM.
I would really enjoy to hear your comments about your experience w/ ‘embeded python’. I guess that java has this kind of cross-compile issue too, but java is ready for cellphones, or other stuffs. Why not python ?