Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trimming Python Runtime

Tags:

python

We've got a (Windows) application, with which we distribute an entire Python installation (including several 3rd-party modules that we use), so we have consistency and so we don't need to install everything separately. This works pretty well, but the application is pretty huge.

Obviously, we don't use everything available in the runtime. I'd like to trim down the runtime to only include what we really need.

I plan on trying out py2exe, but I'd like to try and find another solution that will just help me remove the unneeded parts of the Python runtime.

like image 410
Dave Avatar asked Sep 11 '09 02:09

Dave


1 Answers

One trick I've learned while trimming down .py files to ship: Delete all the .pyc files in the standard library, then run your application throughly (that is, enough to be sure all the Python modules it needs will be loaded). If you examine the standard library directories, there will be .pyc files for all the modules that were actually used. .py files without .pyc are ones that you don't need.

like image 126
Ned Batchelder Avatar answered Sep 22 '22 04:09

Ned Batchelder