errors getting python up-and-running

lkcl luke.leighton at
Sat Nov 27 07:53:10 CET 2010

Adam Lackorzynski wrote:
>> is that... basically it? then include the file e.g. as a module?
>> there must be a "good" way to do this, surely.
> Well, never tried it. When you add the file in modules.list it
> will appear as rom/ in python. Can you load it?

well, luckily i'm a python expert :)

*adds to modules.list*
*builds a qemu iso*
*fires up qemu*
*watches python go "splat" on importing*
*goes "hmmmm"...*

>>> import site
ImportError: module site not found
>>> import sys
>>> dir(sys)
{usual stuff}
>>> print sys.path
['', '']

ah ha!  clue!

>>> sys.path.append('rom')
>>> import sys
ImportError: module os not found

so, yaay!  yes it's possible to add python modules directly to modules.list,
and as long as sys.path is modified to look in 'rom' as one of the
subdirectories (that'll need hard-coding into the python source code) it
should all be hunky-dory.

now, here's the thing that would help enormously.  python's import mechanism
doesn't _just_ have to be a filesystem.  you _can_ create overrides of
__import__.  i've done this before to actually override to load modules from
a SQL database! (don't ask...) - of course that first "bootstrap" module has
to be on a filesystem, or otherwise you have to write it in c and hard-code
its existence into the python binary, which i believe is completely
unnecessary in this case.

one example to follow is ".egg" files.  .egg files are zip'd archives which
can be inserted into the sys.path and python will then look for the modules
*inside* that sys.path.

basically what i'm saying is that, and pretty much everything
under-the-sun in the standard python libs could be dumped into a zip'd
archive - a single file - out of which the python binary could extract
whatever it requires.  the only down-side of that is that a) it's a single
file b) looking for a particular module and then uncompressing it is going
to involve CPU cycles.

but it would be bloody sight easier than having to add everything to

there _must_ be a convenient way to add a ROM-based filesystem to L4,
surely.  or any kind of filesystem.


View this message in context:
Sent from the L4 mailing list archive at

More information about the l4-hackers mailing list