Use a function for build_exe_options in freeze.py.

This commit is contained in:
Florian Bruhin 2015-06-19 07:45:37 +02:00
parent 42b5ee831e
commit 894ec7d66a
2 changed files with 25 additions and 28 deletions

View File

@ -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,

View File

@ -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