[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Python init



Rick Thomas wrote:
Hmmm... Now, that's a problem! During the early part of the boot process the root filesystem is read-only until it's been fsck'ed. There's no safe place to put the compiled modules.

Not really. It cannot be compiled during the initial run if the filesystem is RO. However that does not prevent Python from utilizing the script and having the possibility of it being compiled later on.

    hello.py prints hello world, run.py just imports hello.py

{grey@teleute:~/t2} python run.py
hello world
{grey@teleute:~/t2} ls -l
total 12
-rw-r--r-- 1 grey shared  20 2007-08-21 18:58 hello.py
-rw-r--r-- 1 grey shared 123 2007-08-21 18:58 hello.pyc
-rw-r--r-- 1 grey shared  13 2007-08-21 18:58 run.py
{grey@teleute:~/t2} rm hello.pyc
{grey@teleute:~/t2} chmod 555 .
{grey@teleute:~/t2} python run.py
hello world
{grey@teleute:~/t2} ls -l
total 8
-rw-r--r-- 1 grey shared 20 2007-08-21 18:58 hello.py
-rw-r--r-- 1 grey shared 13 2007-08-21 18:58 run.py
{grey@teleute:~/t2}

Not to mention that moving 10 MB of Python from /usr/bin and /usr/lib to /bin and /lib would increase the size of the root filesystem by 10%-20% on embedded systems -- where the size of things that must be in flash is a critical resource.

Not that all of the libraries need to be moved into the root partition for it to function as a stable init platform. Outside of sys (which is compiled in), os, re, shutil, time and datetime I can't think of anything that is needed for scripts running at init time. Certainly not many of the extended Python libraries like a minimal web server, a whole suite for handling email and MIME, TK/TCL bindings and so on. A very rough check and I think 2.5Mb would be sufficient to serve as an init platform and natively cover more than 80-90% of any operation an init script would need. So that increase of 10-20% at 10Mb is more like 3-5%, if that.



Reply to: