Mike Conley wrote:
Robin got me on the right track here.
comtypes\gen\_3050F1C5_98B5_11CF_BB82_00AA00BDCE0B_0_4_0.py
is a 60,000+ file. the .pyc is over 1.4Mbtrying to run a one liner that just imports that file through py2exe creates the problem. I suspect that letting it run long enough would eventually go to conclusion. Unfortunately we do our build on a relatively low power machine and probably can't change that any time soon (startups don't have much money).
Does anyone know if there is a technique to tell py2exe to "put this in your output, but don't bother to analyze it"? If so, I can manually include this file and any relevant dependencies.
Here Is an email I just sent the maintainer of py2exe Jimmy Retzlaff
Adding "skip_scan" option to py2exe
···
===================================
Refer To: py2exe version 0.6.9
Introduction
=============
I'm using py2exe for exe-ing a wxPython application. Recently I had to add
the embedded Internet Explorer module "wx.lib.iewin" to my application. This
module uses "comtypes" which is generating *very* big module that need to be
included in the distribution executable. Scanning this big module takes
about 15 minutes on my computer (Duo Core, 2G RAM). The idea is to tell
py2exe not to scan this module and add any required module manually through
the "includes" option.
Implementation
===============
I added a "skip_scan" option to py2exe, which is a list of modules names
(like: includes, excludes)
Changes in the code:
build_exe.py:
After line 162 in py2exe, insert:
("skip-scan=", None, "comma-separated list of modules not to scan for imported modules"),
Change line 342 in py2exe.create_modulefinder to:
return ModuleFinder(excludes=self.excludes, skip_scan=self.skip_scan)
mf.py:
Change line 87 definition of ModuleFinder.__init__ to:
def __init__(self, path=None, debug=0, excludes=, replace_paths=,
skip_scan=):
After line 96 in ModuleFinder.__init__ insert:
self.skip_scan = skip_scan
After line 404 in ModuleFinder.scan_code insert:
if m.__name__ in self.skip_scan: return
Usage
======
A strip down example:
setup (
windows = my_win_app,
options = {
'py2exe': {
'includes': ['my_module', <any module "my_module" needs>],
'skip_scan': ['my_module']
}
}
"my_module" will be included in the executable, but will not be scanned for
modules imported from it.
Risks
======
of course I introduced the risk of missing modules in the executable. The
developer will have to test the application, and make sure all the required
modules exists. In my case, it is a risk worth taking as it saves almost 15
minutes from the build process.
Thank you for developing py2exe, it is an excellent tool!
Erez Bibi
Consultant for blackwoodproductions.com
erezbibi AT frontiernet DOT net