Installing Lightweight Python

Nima Mohammadi nima.irt at gmail.com
Mon May 17 15:08:02 EDT 2010


Thanks Geremy :)

The majority of installed files (56MB of data) reside in /lib/
python2.6/. So far, I took these steps to make it as compact as
possible:
1. I deleted /lib/python2.6/test directory. This reduced the size by
20MB.
2. I deleted .py files (cause the corresponding pyc ones are there).
This reduced the size by 9MB.
3. I deleted the /lib/libpython2.6.a which was 6MB.
* By far the python runs flawlessly.

4. I zip up the /lib/python2.6/ as python26.zip and place it in the /
lib/ directory.
Then I delete the /lib/python2.6/ directory. By running python, I get
this output, though /lib/python26.zip is in the sys.path variable.

nima at nima-desktop:~/py$ ./bin/python
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; use -v for traceback
Python 2.6.5 (r265:79063, May 17 2010, 18:36:54)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/home/nima/py/lib/python26.zip', '/home/nima/py/lib/python2.6/',
'/home/nima/py/lib/python2.6/plat-linux2', '/home/nima/py/lib/
python2.6/lib-tk', '/home/nima/py/lib/python2.6/lib-old', '/home/nima/
py/lib/lib-dynload']



On May 17, 9:00 pm, geremy condra <debat... at gmail.com> wrote:
> I'm not an expert, but there are probably a large-ish number of modules
> you could remove without much sacrifice on your part. Looking at the
> module list and just picking the platform-dependent ones:
>
> * _winreg
> * aepack
> * aetools
> * aetypes
> * AL
> * al
> * applesingle
> * autoGIL
> * buildtools
> * Carbon
> * cd
> * cfmfile
> * chunk
> * colorpicker
> * etc
> * etc
> * etc
>
> You could also probably remove things like 2to3, tabnanny, etc,
> and I doubt tkinter is doing you much good.
>
> I also recall someone at pycon talking about importing modules
> from a .zip archive. I'm not sure how easy/hard that is, but you
> may want to look at PEP 302.
>
> Geremy Condra

Yours sincerely,
Nima Mohammadi



More information about the Python-list mailing list