Search code examples
pythonoptimizationwxpythonpy2app

Slim down Python wxPython OS X app built with py2app?


I have just made a small little app of a Python wxPython script with py2app. Everything worked as advertised, but the app is pretty big in size. Is there any way to optimize py2app to make the app smaller in size?


Solution

  • This is a workaround.

    It will depend on which OS you want to target. Python and wxPython are bundled with every Mac OS X installation (at least starting with Leopard, if I recall correctly)

    What you might try, is to add the --alias compilation option. According to the py2app doc:

    Alias mode (the -A or --alias option) instructs py2app to build an application bundle that uses your source and data files in-place.

    So that the app will try to use the Mac OS X version of wxPython.

    CAREFUL
    The alias option is called development mode.

    If you use another library that is not bundled with Mac OS X, it won't work.
    If you want to port your application to Windows or Linux, it won't work.

    I've had some successful use with this method but in the end, went back to zipping a 30/40MB file. Which in the end is not that big.