From 9898d80625318532e14009bfc4cbb5bf6fb1984b Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 17 May 2017 11:31:14 +0200 Subject: [PATCH] Remove legacy cx_Freeze code This also removes frozen tests for now. They should be readded at some point... --- .appveyor.yml | 2 - CONTRIBUTING.asciidoc | 2 +- misc/requirements/requirements-cxfreeze.txt | 3 - .../requirements-cxfreeze.txt-raw | 5 - qutebrowser/qutebrowser.py | 8 +- qutebrowser/utils/utils.py | 3 +- scripts/dev/ci/appveyor_install.py | 34 ---- scripts/dev/cleanup.py | 2 +- scripts/dev/freeze.py | 145 ------------------ scripts/dev/freeze_tests.py | 87 ----------- scripts/dev/recompile_requirements.py | 6 +- scripts/dev/run_frozen_tests.py | 40 ----- tox.ini | 24 --- 13 files changed, 6 insertions(+), 355 deletions(-) delete mode 100644 misc/requirements/requirements-cxfreeze.txt delete mode 100644 misc/requirements/requirements-cxfreeze.txt-raw delete mode 100755 scripts/dev/freeze.py delete mode 100755 scripts/dev/freeze_tests.py delete mode 100644 scripts/dev/run_frozen_tests.py diff --git a/.appveyor.yml b/.appveyor.yml index d3a790aaa..ed7197fcb 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -6,10 +6,8 @@ build: off environment: PYTHONUNBUFFERED: 1 matrix: - - TESTENV: py34 - TESTENV: py36-pyqt58 PYTHON: C:\Python36\python.exe - - TESTENV: unittests-frozen - TESTENV: pylint install: diff --git a/CONTRIBUTING.asciidoc b/CONTRIBUTING.asciidoc index 25a7a8a13..f5196143a 100644 --- a/CONTRIBUTING.asciidoc +++ b/CONTRIBUTING.asciidoc @@ -220,7 +220,7 @@ Documentation of used Python libraries: * http://pygments.org/docs/[pygments] * http://fdik.org/pyPEG/index.html[pyPEG2] * http://pythonhosted.org/setuptools/[setuptools] -* http://cx-freeze.readthedocs.org/en/latest/overview.html[cx_Freeze] +* http://www.pyinstaller.org/[PyInstaller] * https://pypi.python.org/pypi/colorama[colorama] Related RFCs and standards: diff --git a/misc/requirements/requirements-cxfreeze.txt b/misc/requirements/requirements-cxfreeze.txt deleted file mode 100644 index 58f14266e..000000000 --- a/misc/requirements/requirements-cxfreeze.txt +++ /dev/null @@ -1,3 +0,0 @@ -# This file is automatically generated by scripts/dev/recompile_requirements.py - -cx-Freeze==4.3.4 # rq.filter: < 5.0.0 diff --git a/misc/requirements/requirements-cxfreeze.txt-raw b/misc/requirements/requirements-cxfreeze.txt-raw deleted file mode 100644 index 2ae8920ca..000000000 --- a/misc/requirements/requirements-cxfreeze.txt-raw +++ /dev/null @@ -1,5 +0,0 @@ -cx-Freeze < 5.0.0 - -# We'll probably switch to PyInstaller soon, and 5.x doesn't install without a -# compiler? -#@ filter: cx-Freeze < 5.0.0 diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index b4673ecff..700ebe383 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -162,13 +162,7 @@ def debug_flag_error(flag): def main(): parser = get_argparser() - if sys.platform == 'darwin' and getattr(sys, 'frozen', False): - # Ignore Mac OS X' idiotic -psn_* argument... - # http://stackoverflow.com/questions/19661298/ - # http://sourceforge.net/p/cx-freeze/mailman/message/31041783/ - argv = [arg for arg in sys.argv[1:] if not arg.startswith('-psn_0_')] - else: - argv = sys.argv[1:] + argv = sys.argv[1:] args = parser.parse_args(argv) if args.json_args is not None: # Restoring after a restart. diff --git a/qutebrowser/utils/utils.py b/qutebrowser/utils/utils.py index d2de174a8..3c052f939 100644 --- a/qutebrowser/utils/utils.py +++ b/qutebrowser/utils/utils.py @@ -134,7 +134,8 @@ def read_file(filename, binary=False): The file contents as string. """ if hasattr(sys, 'frozen'): - # cx_Freeze doesn't support pkg_resources :( + # PyInstaller doesn't support pkg_resources :( + # https://github.com/pyinstaller/pyinstaller/wiki/FAQ#misc fn = os.path.join(os.path.dirname(sys.executable), filename) if binary: with open(fn, 'rb') as f: diff --git a/scripts/dev/ci/appveyor_install.py b/scripts/dev/ci/appveyor_install.py index 60c07bad6..2c509cd79 100644 --- a/scripts/dev/ci/appveyor_install.py +++ b/scripts/dev/ci/appveyor_install.py @@ -28,16 +28,7 @@ CI machines. from __future__ import print_function -import os -import time import subprocess -import urllib - - -def check_setup(executable): - subprocess.check_call([executable, '-c', 'import PyQt5']) - subprocess.check_call([executable, '-c', 'import sip']) - subprocess.check_call([executable, '--version']) def pip_install(pkg): @@ -48,28 +39,3 @@ def pip_install(pkg): print("Installing tox") pip_install('pip') pip_install(r'-rmisc\requirements\requirements-tox.txt') - -print("Linking Python...") -with open(r'C:\Windows\system32\python3.bat', 'w') as f: - f.write(r'@C:\Python34\python %*') - - -if '-pyqt' not in os.environ['TESTENV']: - print("Getting PyQt5...") - qt_version = '5.5.1' - pyqt_version = '5.5.1' - pyqt_url = ('https://www.qutebrowser.org/pyqt/' - 'PyQt5-{}-gpl-Py3.4-Qt{}-x32.exe'.format( - pyqt_version, qt_version)) - - try: - urllib.urlretrieve(pyqt_url, r'C:\install-PyQt5.exe') - except (OSError, IOError): - print("Downloading PyQt failed, trying again in 10 seconds...") - time.sleep(10) - urllib.urlretrieve(pyqt_url, r'C:\install-PyQt5.exe') - - print("Installing PyQt5...") - subprocess.check_call([r'C:\install-PyQt5.exe', '/S']) - - check_setup(r'C:\Python34\python') diff --git a/scripts/dev/cleanup.py b/scripts/dev/cleanup.py index 49832eb3d..297b876c0 100755 --- a/scripts/dev/cleanup.py +++ b/scripts/dev/cleanup.py @@ -18,7 +18,7 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . -"""Script to clean up the mess made by Python/setuptools/cx_Freeze.""" +"""Script to clean up the mess made by Python/setuptools/PyInstaller.""" import os import os.path diff --git a/scripts/dev/freeze.py b/scripts/dev/freeze.py deleted file mode 100755 index 8f99d2d35..000000000 --- a/scripts/dev/freeze.py +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env python3 -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: - -# Copyright 2014-2017 Florian Bruhin (The Compiler) -# -# This file is part of qutebrowser. -# -# qutebrowser is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# qutebrowser is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with qutebrowser. If not, see . - -"""cx_Freeze script for qutebrowser. - -Builds a standalone executable. -""" - - -import os -import os.path -import sys -import distutils - -import cx_Freeze as cx # pylint: disable=import-error,useless-suppression -# cx_Freeze is hard to install (needs C extensions) so we don't check for it. - -sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, - os.pardir)) -from scripts import setupcommon - - -BASEDIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), - os.path.pardir, os.path.pardir) - - -def get_egl_path(): - """Get the path for PyQt5's libEGL.dll.""" - if not sys.platform.startswith('win'): - return None - return os.path.join(distutils.sysconfig.get_python_lib(), - r'PyQt5\libEGL.dll') - - -def get_plugin_folders(): - """Get the plugin folders to copy to the output.""" - if not sys.platform.startswith('win'): - return [] - plugin_dir = os.path.join(distutils.sysconfig.get_python_lib(), - 'PyQt5', 'plugins') - folders = ['audio', 'iconengines', 'mediaservice', 'printsupport'] - return [os.path.join(plugin_dir, folder) for folder in folders] - - -def get_build_exe_options(skip_html=False): - """Get the options passed as build_exe_options to cx_Freeze. - - If either skip_html or --qute-skip-html as argument is given, doesn't - freeze the documentation. - """ - if '--qute-skip-html' in sys.argv: - skip_html = True - sys.argv.remove('--qute-skip-html') - - include_files = [ - ('qutebrowser/javascript', 'javascript'), - ('qutebrowser/img', 'img'), - ('qutebrowser/git-commit-id', 'git-commit-id'), - ('qutebrowser/utils/testfile', 'utils/testfile'), - ('qutebrowser/html', 'html'), - ] - - if os.path.exists(os.path.join('qutebrowser', '3rdparty', 'pdfjs')): - include_files.append(('qutebrowser/3rdparty/pdfjs', '3rdparty/pdfjs')) - else: - print("Warning: excluding pdfjs as it's not present!") - - if not skip_html: - include_files += [ - ('qutebrowser/html/doc', 'html/doc'), - ] - - egl_path = get_egl_path() - if egl_path is not None: - include_files.append((egl_path, 'libEGL.dll')) - - include_files += get_plugin_folders() - - return { - 'include_files': include_files, - 'include_msvcr': True, - 'includes': [], - 'excludes': ['tkinter'], - 'packages': ['pygments'], - } - - -def get_exe(base, target_name): - """Get the qutebrowser cx.Executable to build.""" - return cx.Executable('qutebrowser/__main__.py', base=base, - targetName=target_name, shortcutName='qutebrowser', - shortcutDir='ProgramMenuFolder', - icon=os.path.join(BASEDIR, 'icons', - 'qutebrowser.ico')) - - -def main(): - if sys.platform.startswith('win'): - base = 'Win32GUI' - target_name = 'qutebrowser.exe' - else: - base = None - target_name = 'qutebrowser' - - bdist_msi_options = { - # random GUID generated by uuid.uuid4() - 'upgrade_code': '{a7119e75-4eb7-466c-ae0d-3c0eccb45196}', - 'add_to_path': False, - } - - try: - setupcommon.write_git_file() - cx.setup( - executables=[get_exe(base, target_name)], - options={ - 'build_exe': get_build_exe_options(), - 'bdist_msi': bdist_msi_options, - }, - **setupcommon.setupdata - ) - finally: - path = os.path.join(BASEDIR, 'qutebrowser', 'git-commit-id') - if os.path.exists(path): - os.remove(path) - - -if __name__ == '__main__': - main() diff --git a/scripts/dev/freeze_tests.py b/scripts/dev/freeze_tests.py deleted file mode 100755 index 97405b446..000000000 --- a/scripts/dev/freeze_tests.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/env python3 -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: - -# Copyright 2015-2017 Florian Bruhin (The Compiler) -# -# This file is part of qutebrowser. -# -# qutebrowser is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# qutebrowser is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with qutebrowser. If not, see . - -"""cx_Freeze script to freeze qutebrowser and its tests.""" - - -import os -import os.path -import sys -import contextlib - -import cx_Freeze as cx # pylint: disable=import-error,useless-suppression -# cx_Freeze is hard to install (needs C extensions) so we don't check for it. -import pytest - -import httpbin - -sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir, - os.pardir)) -from scripts import setupcommon -from scripts.dev import freeze - - -@contextlib.contextmanager -def temp_git_commit_file(): - """Context manager to temporarily create a fake git-commit-id file.""" - basedir = os.path.join(os.path.dirname(os.path.realpath(__file__)), - os.path.pardir, os.pardir) - path = os.path.join(basedir, 'qutebrowser', 'git-commit-id') - with open(path, 'wb') as f: - f.write(b'fake-frozen-git-commit') - yield - os.remove(path) - - -def get_build_exe_options(): - """Get build_exe options with additional includes.""" - opts = freeze.get_build_exe_options(skip_html=True) - opts['includes'] += pytest.freeze_includes() - opts['includes'] += ['unittest.mock', 'PyQt5.QtTest', 'hypothesis', 'bs4', - 'httpbin', 'jinja2.ext', 'cheroot', 'pstats', 'queue'] - - httpbin_dir = os.path.dirname(httpbin.__file__) - opts['include_files'] += [ - ('tests/end2end/data', 'end2end/data'), - (os.path.join(httpbin_dir, 'templates'), 'end2end/templates'), - ] - - opts['packages'].append('qutebrowser') - return opts - - -def main(): - base = 'Win32GUI' if sys.platform.startswith('win') else None - with temp_git_commit_file(): - cx.setup( - executables=[ - cx.Executable('scripts/dev/run_frozen_tests.py', - targetName='run-frozen-tests'), - cx.Executable('tests/end2end/fixtures/webserver_sub.py', - targetName='webserver_sub'), - freeze.get_exe(base, target_name='qutebrowser') - ], - options={'build_exe': get_build_exe_options()}, - **setupcommon.setupdata - ) - - -if __name__ == '__main__': - main() diff --git a/scripts/dev/recompile_requirements.py b/scripts/dev/recompile_requirements.py index 44c56202a..52351de56 100644 --- a/scripts/dev/recompile_requirements.py +++ b/scripts/dev/recompile_requirements.py @@ -112,11 +112,7 @@ def get_all_names(): """Get all requirement names based on filenames.""" for filename in glob.glob(os.path.join(REQ_DIR, 'requirements-*.txt-raw')): basename = os.path.basename(filename) - name = basename[len('requirements-'):-len('.txt-raw')] - if name == 'cxfreeze' and sys.hexversion >= 0x030600: - print("Warning: Skipping cxfreeze") - else: - yield name + yield basename[len('requirements-'):-len('.txt-raw')] yield 'pip' diff --git a/scripts/dev/run_frozen_tests.py b/scripts/dev/run_frozen_tests.py deleted file mode 100644 index 1684884a3..000000000 --- a/scripts/dev/run_frozen_tests.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python3 -# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: - -# Copyright 2015-2017 Florian Bruhin (The Compiler) -# -# This file is part of qutebrowser. -# -# qutebrowser is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# qutebrowser is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with qutebrowser. If not, see . - -"""cx_Freeze script to run qutebrowser tests on the frozen executable.""" - -import sys - -import pytest -import pytestqt.plugin -import pytest_mock -import pytest_catchlog -import pytest_instafail -import pytest_faulthandler -import pytest_xvfb -import pytest_rerunfailures -import pytest_warnings -import pytest_benchmark.plugin - -sys.exit(pytest.main(plugins=[pytestqt.plugin, pytest_mock, - pytest_catchlog, pytest_instafail, - pytest_faulthandler, pytest_xvfb, - pytest_rerunfailures, pytest_warnings, - pytest_benchmark.plugin])) diff --git a/tox.ini b/tox.ini index fb292e853..8a52e217b 100644 --- a/tox.ini +++ b/tox.ini @@ -158,18 +158,6 @@ deps = -r{toxinidir}/requirements.txt -r{toxinidir}/misc/requirements/requirements-pyqt.txt -[testenv:unittests-frozen] -# cx_Freeze doesn't support Python 3.5 yet -basepython = python3.4 -passenv = {[testenv]passenv} -deps = - {[testenv]deps} - -r{toxinidir}/misc/requirements/requirements-cxfreeze.txt -commands = - {envpython} scripts/link_pyqt.py --tox {envdir} - {envpython} scripts/dev/freeze_tests.py build_exe -b {envdir}/build - {envdir}/build/run-frozen-tests {posargs} - [testenv:misc] ignore_errors = true basepython = python3 @@ -251,18 +239,6 @@ commands = {envpython} scripts/dev/check_doc_changes.py {posargs} {envpython} scripts/asciidoc2html.py {posargs} -[testenv:cxfreeze-windows] -# PYTHON is actually required when using this env, but the entire tox.ini would -# fail if we didn't have a fallback defined. -basepython = {env:PYTHON:}/python.exe -deps = - -r{toxinidir}/requirements.txt - -r{toxinidir}/misc/requirements/requirements-cxfreeze.txt -commands = - {envpython} -m pip install -U setuptools - {envpython} scripts/link_pyqt.py --tox {envdir} - {envpython} scripts/dev/freeze.py {posargs} - [testenv:pyinstaller] # WORKAROUND for https://github.com/tox-dev/tox/issues/503 install_command = pip install --exists-action w {opts} {packages}