Minimize python distribution size

The obstacle we have to send to 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.

+7
python size minimize
source share
3 answers

If you want to get the smallest subset you need (instead of creating an exe that would limit you on Windows systems), use the standard modulefinder library module to list all the modules your program requires (you will get all the 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 this zipfile as your sys.path (plus the directory for all .pyd or .so dynamic libraries with internal code that you may need - those who need to work directly on the file system so that the OS loads them as needed cannot be loaded directly from the zipfile in the way that Python byte codes can be used, unfortunately )

+7
source share

Have you looked at py2exe ? It provides a way to submit Python programs without installing Python.

+2
source share

Like Hank Gay and Alex Martelli, you can use py2exe. In addition, I would suggest exploring the use of IronPython . Depending on your application, you may use libraries built into the .NET platform (or MONO, if for Linux). This reduces the size of your delivery, but adds minimal requirements to your program.

Also, if you use functions from the library, you can use from module import x instead of doing a wildcard. It also reduces the size of your ship, but maybe not too much.

Hope this helps

0
source share

All Articles