Skip to content

Commit

Permalink
Merge pull request #189 from mkhon/reduce-windows-installation-size
Browse files Browse the repository at this point in the history
Shrink installation size by 298,800 bytes

Thanks to Maxim Khon! This was work under contract.
  • Loading branch information
az0 committed Feb 2, 2017
2 parents f0728bf + 2300582 commit c2e3133
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions windows/setup_py2exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ def delete_unnecessary():
r'lib\gdk-pixbuf-2.0',
r'lib\glib-2.0',
r'lib\gtk-2.0\include',
r'lib\gtk-2.0\2.10.0\engines\libpixmap.dll',
r'lib\gtk-2.0\2.10.0\engines\libsvg.dll',
r'lib\gtk-2.0\modules\libgail.dll',
r'lib\pkgconfig',
r'perfmon.pyd',
r'select.pyd',
Expand Down Expand Up @@ -340,15 +343,8 @@ def clean_translations():
@count_size_improvement
def strip():
logger.info('Stripping executables')
strip_list = recursive_glob('dist', ['*.dll'])
strip_whitelist = [
'freetype6.dll',
'python27.dll',
'pythoncom27.dll',
'pywintypes27.dll',
'sqlite3.dll',
'zlib1.dll',
]
strip_list = recursive_glob('dist', ['*.dll', '*.pyd'])
strip_whitelist = []
strip_files_str = [f for f in strip_list if os.path.basename(
f) not in strip_whitelist]
cmd = 'strip.exe --strip-debug --discard-all --preserve-dates ' + \
Expand All @@ -366,17 +362,7 @@ def strip():
def upx():
logger.info('Compressing executables')
if os.path.exists(UPX_EXE):
upx_patterns = [
r'*.dll',
r'*.exe',
r'*.pyd',
r'lib\gtk-2.0\2.10.0\engines\*.dll',
r'lib\gtk-2.0\modules\*.dll',
]
upx_files = []
for pattern in upx_patterns:
pattern = r'dist\{}'.format(pattern)
upx_files.extend(glob.glob(pattern))
upx_files = recursive_glob('dist', ['*.exe', '*.dll', '*.pyd'])
cmd = '{} {} {}'.format(UPX_EXE, UPX_OPTS, ' '.join(upx_files))
run_cmd(cmd)
else:
Expand Down Expand Up @@ -437,6 +423,11 @@ def delete_linux_only():
file_size_old = os.path.getsize('dist\\library.zip')
os.remove('dist\\library.zip')

# clean unused modules from library.zip
delete_paths = ['distutils', 'email']
for p in delete_paths:
shutil.rmtree(os.path.join('dist', 'library', p))

# recompress library.zip
cmd = SZ_EXE + ' a {} ..\\library.zip'.format(SZ_OPTS)
logger.info(cmd)
Expand Down

0 comments on commit c2e3133

Please sign in to comment.