FAQ
Hello all,

i've been trying to build an .exe with py2exe. After many tentatives,
it worked, but the total space used by the app goes to 30Mb. It is a
simple app, that uses wxpython, matplotlib and numpy. I checked the
library.zip file and notived that there is a pyQt-related file there:

Pyqt - QtGui.pyo - 8 Mb

I'm not using Qt at all, so I assume it would be safe to not have this
file, but I don't see how to do it.

my setup.py file follows.

many thanks

Carlos


#----------------------------------------------------------------------
from distutils.core import setup
import py2exe
from glob import glob

# Remove the build folder, a bit slower but ensures that build
contains the latest
import shutil
shutil.rmtree("build", ignore_errors=True)

# my setup.py is based on one generated with gui2exe, so data_files is
done a bit differently
data_files = [("Microsoft.VC90.CRT", glob(r'c:\dev\*.*'))]

includes = ['wx', 'os', 'sys', 'csv', 're', 'floatspin',
'scrolledpanel', 'customtreectrl',
'wx.lib.expando', 'wx.lib.pubsub', 'wx.lib.embeddedimage',
'wx.lib.wordwrap', 'types',
'matplotlib', 'matplotlib.pyplot', 'matplotlib.axes',
'matplotlib.figure',
'matplotlib.backends.backend_wxagg',
'mpl_toolkits.axes_grid.axislines', 'mpl_toolkits.axes_grid',
'matplotlib.patches', 'matplotlib.lines',
'matplotlib.text', 'matplotlib.mlab', 'matplotlib.nxutils',
'matplotlib.collections', 'matplotlib.font_manager',
'numpy', 'numpy.ma', 'numpy.linalg', 'math', 'scipy.interpolate'
]

excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'pywin.debugger',
'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
'Tkconstants', 'Tkinter', 'pydoc', 'doctest', 'test',
'sqlite3',
'bsddb', 'curses', 'email','_fltkagg', '_gtk',
'_gtkcairo',
'_agg2', '_cairo', '_cocoaagg',
'matplotlib.backends.backend_qt4agg','matplotlib.backends.backend_qt4'
]

packages = ['encodings','pytz','scipy']

dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll',
'tcl84.dll', 'tk84.dll',
'libgdk_pixbuf-2.0-0.dll', 'libgtk-win32-2.0-0.dll',
'libglib-2.0-0.dll',
'libcairo-2.dll', 'libpango-1.0-0.dll',
'libpangowin32-1.0-0.dll', 'libpangocairo-1.0-0.dll',
'libglade-2.0-0.dll', 'libgmodule-2.0-0.dll',
'libgthread-2.0-0.dll', 'QtGui4.dll', 'QtCore.dll',
'QtCore4.dll'
]

icon_resources = []
bitmap_resources = []
other_resources = []

# add the mpl mpl-data folder and rc file
import matplotlib as mpl
data_files += mpl.get_py2exe_datafiles()

setup(
windows=['OpenStereo.py'],
# compressed and optimize reduce the size
options = {"py2exe": {"compressed": 2,
"optimize": 2,
"includes": includes,
"excludes": excludes,
"packages": packages,
"dll_excludes": dll_excludes,
# using 2 to reduce number of files in dist
folder
# using 1 is not recommended as it often
does not work
"bundle_files": 2,
"dist_dir": 'dist',
"xref": False,
"skip_archive": False,
"ascii": False,
"custom_boot_script": '',
}
},

# using zipfile to reduce number of files in dist
zipfile = r'lib\library.zip',

data_files=data_files
)

Search Discussions

  • Almar Klein at Sep 14, 2010 at 12:21 pm
    Hi,

    Have you tried adding "PyQt4", "PyQt4.QtGui" and "PyQt4.QtCore" to your list
    of excludes?
    (Maybe only "PyQt4.QtGui" is sufficient.)

    Almar

    On 14 September 2010 13:02, Carlos Grohmann wrote:

    Hello all,

    i've been trying to build an .exe with py2exe. After many tentatives,
    it worked, but the total space used by the app goes to 30Mb. It is a
    simple app, that uses wxpython, matplotlib and numpy. I checked the
    library.zip file and notived that there is a pyQt-related file there:

    Pyqt - QtGui.pyo - 8 Mb

    I'm not using Qt at all, so I assume it would be safe to not have this
    file, but I don't see how to do it.

    my setup.py file follows.

    many thanks

    Carlos


    #----------------------------------------------------------------------
    from distutils.core import setup
    import py2exe
    from glob import glob

    # Remove the build folder, a bit slower but ensures that build
    contains the latest
    import shutil
    shutil.rmtree("build", ignore_errors=True)

    # my setup.py is based on one generated with gui2exe, so data_files is
    done a bit differently
    data_files = [("Microsoft.VC90.CRT", glob(r'c:\dev\*.*'))]

    includes = ['wx', 'os', 'sys', 'csv', 're', 'floatspin',
    'scrolledpanel', 'customtreectrl',
    'wx.lib.expando', 'wx.lib.pubsub', 'wx.lib.embeddedimage',
    'wx.lib.wordwrap', 'types',
    'matplotlib', 'matplotlib.pyplot', 'matplotlib.axes',
    'matplotlib.figure',
    'matplotlib.backends.backend_wxagg',
    'mpl_toolkits.axes_grid.axislines', 'mpl_toolkits.axes_grid',
    'matplotlib.patches', 'matplotlib.lines',
    'matplotlib.text', 'matplotlib.mlab', 'matplotlib.nxutils',
    'matplotlib.collections', 'matplotlib.font_manager',
    'numpy', 'numpy.ma', 'numpy.linalg', 'math', 'scipy.interpolate'
    ]

    excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'pywin.debugger',
    'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
    'Tkconstants', 'Tkinter', 'pydoc', 'doctest', 'test',
    'sqlite3',
    'bsddb', 'curses', 'email','_fltkagg', '_gtk',
    '_gtkcairo',
    '_agg2', '_cairo', '_cocoaagg',
    'matplotlib.backends.backend_qt4agg','matplotlib.backends.backend_qt4'
    ]

    packages = ['encodings','pytz','scipy']

    dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll',
    'tcl84.dll', 'tk84.dll',
    'libgdk_pixbuf-2.0-0.dll', 'libgtk-win32-2.0-0.dll',
    'libglib-2.0-0.dll',
    'libcairo-2.dll', 'libpango-1.0-0.dll',
    'libpangowin32-1.0-0.dll', 'libpangocairo-1.0-0.dll',
    'libglade-2.0-0.dll', 'libgmodule-2.0-0.dll',
    'libgthread-2.0-0.dll', 'QtGui4.dll', 'QtCore.dll',
    'QtCore4.dll'
    ]

    icon_resources = []
    bitmap_resources = []
    other_resources = []

    # add the mpl mpl-data folder and rc file
    import matplotlib as mpl
    data_files += mpl.get_py2exe_datafiles()

    setup(
    windows=['OpenStereo.py'],
    # compressed and optimize reduce the size
    options = {"py2exe": {"compressed": 2,
    "optimize": 2,
    "includes": includes,
    "excludes": excludes,
    "packages": packages,
    "dll_excludes": dll_excludes,
    # using 2 to reduce number of files in dist
    folder
    # using 1 is not recommended as it often
    does not work
    "bundle_files": 2,
    "dist_dir": 'dist',
    "xref": False,
    "skip_archive": False,
    "ascii": False,
    "custom_boot_script": '',
    }
    },

    # using zipfile to reduce number of files in dist
    zipfile = r'lib\library.zip',

    data_files=data_files
    )
    --
    http://mail.python.org/mailman/listinfo/python-list
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20100914/7e932f78/attachment.html>
  • Carlos Grohmann at Sep 14, 2010 at 3:45 pm
    many thanks Almar.

    No more pyqt stuff in my dist.

    cheers

    carlos
    On Tue, Sep 14, 2010 at 09:21, Almar Klein wrote:
    Hi,

    Have you tried adding "PyQt4", "PyQt4.QtGui" and "PyQt4.QtCore" to your list
    of excludes?
    (Maybe only "PyQt4.QtGui" is sufficient.)

    ? Almar

    On 14 September 2010 13:02, Carlos Grohmann wrote:

    Hello all,

    i've been trying to build an .exe with py2exe. After many tentatives,
    it worked, but the total space used by the app goes to 30Mb. It is a
    simple app, that uses wxpython, matplotlib and numpy. I checked the
    library.zip file and notived that there is a pyQt-related file there:

    Pyqt - QtGui.pyo - 8 Mb

    I'm not using Qt at all, so I assume it would be safe to not have this
    file, but I don't see how to do it.

    my setup.py file follows.

    many thanks

    Carlos


    #----------------------------------------------------------------------
    from distutils.core import setup
    import py2exe
    from glob import glob

    # Remove the build folder, a bit slower but ensures that build
    contains the latest
    import shutil
    shutil.rmtree("build", ignore_errors=True)

    # my setup.py is based on one generated with gui2exe, so data_files is
    done a bit differently
    data_files = [("Microsoft.VC90.CRT", glob(r'c:\dev\*.*'))]

    includes = ['wx', 'os', 'sys', 'csv', 're', 'floatspin',
    'scrolledpanel', 'customtreectrl',
    ? ? ? ? ? ?'wx.lib.expando', 'wx.lib.pubsub', 'wx.lib.embeddedimage',
    'wx.lib.wordwrap', 'types',
    ? ? ? ? ? ?'matplotlib', 'matplotlib.pyplot', 'matplotlib.axes',
    'matplotlib.figure',
    ? ? ? ? ? ?'matplotlib.backends.backend_wxagg',
    'mpl_toolkits.axes_grid.axislines', 'mpl_toolkits.axes_grid',
    ? ? ? ? ? ?'matplotlib.patches', 'matplotlib.lines',
    'matplotlib.text', 'matplotlib.mlab', 'matplotlib.nxutils',
    ? ? ? ? ? ?'matplotlib.collections', 'matplotlib.font_manager',
    'numpy', 'numpy.ma', 'numpy.linalg', 'math', 'scipy.interpolate'
    ? ? ? ? ? ?]

    excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'pywin.debugger',
    ? ? ? ? ? ?'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
    ? ? ? ? ? ?'Tkconstants', 'Tkinter', 'pydoc', 'doctest', 'test',
    'sqlite3',
    ? ? ? ? ? ?'bsddb', 'curses', 'email','_fltkagg', '_gtk',
    '_gtkcairo',
    ? ? ? ? ? ?'_agg2', '_cairo', '_cocoaagg',
    'matplotlib.backends.backend_qt4agg','matplotlib.backends.backend_qt4'
    ? ? ? ? ? ?]

    packages = ['encodings','pytz','scipy']

    dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll',
    'tcl84.dll', 'tk84.dll',
    ? ? ? ? ? ? ? ?'libgdk_pixbuf-2.0-0.dll', 'libgtk-win32-2.0-0.dll',
    'libglib-2.0-0.dll',
    ? ? ? ? ? ? ? ?'libcairo-2.dll', 'libpango-1.0-0.dll',
    'libpangowin32-1.0-0.dll', 'libpangocairo-1.0-0.dll',
    ? ? ? ? ? ? ? ?'libglade-2.0-0.dll', 'libgmodule-2.0-0.dll',
    'libgthread-2.0-0.dll', 'QtGui4.dll', 'QtCore.dll',
    ? ? ? ? ? ? ? ?'QtCore4.dll'
    ? ? ? ? ? ? ? ?]

    icon_resources = []
    bitmap_resources = []
    other_resources = []

    # add the mpl mpl-data folder and rc file
    import matplotlib as mpl
    data_files += mpl.get_py2exe_datafiles()

    setup(
    ? ?windows=['OpenStereo.py'],
    ? ? ? ? ? ? ? ? ? ? ? ? ?# compressed and optimize reduce the size
    ? ?options = {"py2exe": {"compressed": 2,
    ? ? ? ? ? ? ? ? ? ? ? ? ?"optimize": 2,
    ? ? ? ? ? ? ? ? ? ? ? ? ?"includes": includes,
    ? ? ? ? ? ? ? ? ? ? ? ? ?"excludes": excludes,
    ? ? ? ? ? ? ? ? ? ? ? ? ?"packages": packages,
    ? ? ? ? ? ? ? ? ? ? ? ? ?"dll_excludes": dll_excludes,
    ? ? ? ? ? ? ? ? ? ? ? ? ?# using 2 to reduce number of files in dist
    folder
    ? ? ? ? ? ? ? ? ? ? ? ? ?# using 1 is not recommended as it often
    does not work
    ? ? ? ? ? ? ? ? ? ? ? ? ?"bundle_files": 2,
    ? ? ? ? ? ? ? ? ? ? ? ? ?"dist_dir": 'dist',
    ? ? ? ? ? ? ? ? ? ? ? ? ?"xref": False,
    ? ? ? ? ? ? ? ? ? ? ? ? ?"skip_archive": False,
    ? ? ? ? ? ? ? ? ? ? ? ? ?"ascii": False,
    ? ? ? ? ? ? ? ? ? ? ? ? ?"custom_boot_script": '',
    ? ? ? ? ? ? ? ? ? ? ? ? }
    ? ? ? ? ? ? ?},

    ? ?# using zipfile to reduce number of files in dist
    ? ?zipfile = r'lib\library.zip',

    ? ?data_files=data_files
    )
    --
    http://mail.python.org/mailman/listinfo/python-list


    --
    Prof. Carlos Henrique Grohmann - Geologist D.Sc.
    Institute of Geosciences - Univ. of S?o Paulo, Brazil
    http://www.igc.usp.br/pessoais/guano
    http://lattes.cnpq.br/5846052449613692
    Linux User #89721
    ________________
    Can?t stop the signal.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedSep 14, '10 at 11:02a
activeSep 14, '10 at 3:45p
posts3
users2
websitepython.org

2 users in discussion

Carlos Grohmann: 2 posts Almar Klein: 1 post

People

Translate

site design / logo © 2022 Grokbase