From 894ec7d66a0a2f91612a7cc1f9e487d0ed879863 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Fri, 19 Jun 2015 07:45:37 +0200 Subject: [PATCH] Use a function for build_exe_options in freeze.py. --- scripts/freeze.py | 37 +++++++++++++++++++++++-------------- scripts/freeze_tests.py | 16 ++-------------- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/scripts/freeze.py b/scripts/freeze.py index 888127d5b..750ab94e8 100755 --- a/scripts/freeze.py +++ b/scripts/freeze.py @@ -47,22 +47,31 @@ def get_egl_path(): return os.path.join(distutils.sysconfig.get_python_lib(), r'PyQt5\libEGL.dll') -build_exe_options = { - 'include_files': [ - ('qutebrowser/html', 'html'), - ('qutebrowser/html/doc', 'html/doc'), + +def get_build_exe_options(skip_html=False): + include_files = [ ('qutebrowser/javascript', 'javascript'), ('qutebrowser/git-commit-id', 'git-commit-id'), - ], - 'include_msvcr': True, - 'includes': [], - 'excludes': ['tkinter'], - 'packages': ['pygments'], -} + ] + + if not skip_html: + include_files += [ + ('qutebrowser/html', 'html'), + ('qutebrowser/html/doc', 'html/doc'), + ] + + egl_path = get_egl_path() + if egl_path is not None: + include_files.append((egl_path, 'libEGL.dll')) + + return { + 'include_files': include_files, + 'include_msvcr': True, + 'includes': [], + 'excludes': ['tkinter'], + 'packages': ['pygments'], + } -egl_path = get_egl_path() -if egl_path is not None: - build_exe_options['include_files'].append((egl_path, 'libEGL.dll')) bdist_msi_options = { # random GUID generated by uuid.uuid4() @@ -101,7 +110,7 @@ if __name__ == '__main__': cx.setup( executables=[executable], options={ - 'build_exe': build_exe_options, + 'build_exe': get_build_exe_options(), 'bdist_msi': bdist_msi_options, 'bdist_mac': bdist_mac_options, 'bdist_dmg': bdist_dmg_options, diff --git a/scripts/freeze_tests.py b/scripts/freeze_tests.py index b87e26a65..7cd7022a9 100755 --- a/scripts/freeze_tests.py +++ b/scripts/freeze_tests.py @@ -31,8 +31,7 @@ import cx_Freeze as cx # pylint: disable=import-error import pytest sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir)) -from scripts import setupcommon -from scripts.freeze import build_exe_options as normal_build_exe_options +from scripts import setupcommon, freeze @contextlib.contextmanager @@ -49,21 +48,10 @@ def temp_git_commit_file(): def get_build_exe_options(): """Get build_exe options with additional includes.""" - opts = dict(normal_build_exe_options) - # Remove documentation from include_files. - skipped_include_files = [ - os.path.join('qutebrowser', 'html'), - os.path.join('qutebrowser', 'html', 'doc') - ] - include_files = [e for e in normal_build_exe_options['include_files'] - if e[0] not in skipped_include_files] - opts['include_files'] = include_files - + opts = freeze.get_build_exe_options(skip_html=True) opts['includes'] += pytest.freeze_includes() # pylint: disable=no-member opts['includes'] += ['unittest.mock', 'PyQt5.QtTest'] - opts['packages'].append('qutebrowser') - return opts