Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimize python distribution size

The hindrance we have to ship python is the large size of the standard library. Is there a minimal python distribution or an easy way to pick and choose what we want from the standard library? The platform is linux.

like image 727
user282368 Avatar asked Feb 26 '10 20:02

user282368


2 Answers

If all you want is to get the minimum subset you need (rather than build an exe which would constrain you to Windows systems), use the standard library module modulefinder to list all modules your program requires (you'll get all dependencies, direct and indirect). Then you can zip all the relevant .pyo or .pyc files (depending on whether you run Python with or without the -O flag) and just use that zipfile as your sys.path (plus a directory for all the .pyd or .so native-code dynamic libraries you may need -- those need to live directly in the filesystem to let the OS load them in as needed, can't be loaded directly from a zipfile the way Python bytecode modules can, unfortunately).

like image 197
Alex Martelli Avatar answered Sep 17 '22 16:09

Alex Martelli


Have you looked at py2exe? It provides a way to ship Python programs without requiring a Python installation.

like image 33
Hank Gay Avatar answered Sep 18 '22 16:09

Hank Gay