2

I have a couple of general questions regarding Python and packaging scripts into installable applications. I have written a script that uses matplotlib, numpy, and scipy, the sizes of which near 160 MB altogether. The script is relatively simple, and uses few features from any of the three libraries. Yet, when packaging the script into an installable application using py2app, the file size of the generated application is around 250 MB (including frameworks which also are unused by the application).

To reduce the size of the file, I've gone into the package contents of the application (on a Mac) and manually removed modules from the libraries as well as unused frameworks that I guessed were not used by the application. This brought the file size down to around 90 MB without any loss of functionality.

With this in mind, here are a couple questions:

  1. Is there any way to identify which specific files from which modules are actually being used by the Python script?
  2. Is there any way to identify which frameworks are being used the generated application file?
  3. Is there an elegant solution to automatically remove all unused files and frameworks (as identified with the answers to questions to 1 and 2) from the application's package contents so as to dramatically reduce file size without the loss of functionality?

Thank you.

Nick C
  • 73
  • 1
  • 8
  • Why is the size a problem? – cdarke Aug 01 '16 at 21:48
  • All files are saved to a local server with limited space, so if there's any way I can minimize my footprint (the entire company uses this server), that would be ideal. – Nick C Aug 01 '16 at 21:50
  • The simple way to do this is to use a `virtualenv` to install only the specific packages you need during the development phase, but you can't then cherry pick specific parts of those packages as far as I'm aware. – jonrsharpe Aug 01 '16 at 21:52

0 Answers0