diff options
author | Florian Bruhin <me@the-compiler.org> | 2023-07-22 12:36:31 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2023-07-22 12:36:31 +0200 |
commit | 273230eb07eb848e67abc8c1e6fc95cfe4c46b6f (patch) | |
tree | a198f4b32f439f3602c25a4942b9a0aabe511b87 /scripts | |
parent | 1387b0598b90501dfa1dc8e4cbe5e1d0d05cd048 (diff) | |
parent | ed70741587d0d7f5cc90b2f510c38474a7ad9375 (diff) | |
download | qutebrowser-273230eb07eb848e67abc8c1e6fc95cfe4c46b6f.tar.gz qutebrowser-273230eb07eb848e67abc8c1e6fc95cfe4c46b6f.zip |
Merge remote-tracking branch 'origin/pr/7789'
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/dev/build_release.py | 62 | ||||
-rw-r--r-- | scripts/dev/misc_checks.py | 47 | ||||
-rwxr-xr-x | scripts/dev/run_vulture.py | 1 | ||||
-rw-r--r-- | scripts/dev/standardpaths_tester.py | 2 | ||||
-rw-r--r-- | scripts/keytester.py | 3 | ||||
-rw-r--r-- | scripts/link_pyqt.py | 2 | ||||
-rwxr-xr-x | scripts/mkvenv.py | 10 | ||||
-rw-r--r-- | scripts/opengl_info.py | 6 |
8 files changed, 64 insertions, 69 deletions
diff --git a/scripts/dev/build_release.py b/scripts/dev/build_release.py index 996487693..d8f9693e7 100755 --- a/scripts/dev/build_release.py +++ b/scripts/dev/build_release.py @@ -136,7 +136,7 @@ def _smoke_test_run( return subprocess.run(argv, check=True, capture_output=True) -def smoke_test(executable: pathlib.Path, debug: bool, qt6: bool) -> None: +def smoke_test(executable: pathlib.Path, debug: bool, qt5: bool) -> None: """Try starting the given qutebrowser executable.""" stdout_whitelist = [] stderr_whitelist = [ @@ -176,7 +176,7 @@ def smoke_test(executable: pathlib.Path, debug: bool, qt6: bool) -> None: r'ContextResult::kTransientFailure: Failed to send ' r'.*CreateCommandBuffer\.'), ]) - if qt6: + if not qt5: stderr_whitelist.extend([ # FIXME:qt6 Qt 6.3 on macOS r'[0-9:]* WARNING: Incompatible version of OpenSSL', @@ -257,10 +257,10 @@ def verify_windows_exe(exe_path: pathlib.Path) -> None: assert pe.verify_checksum() -def patch_mac_app(qt6: bool) -> None: +def patch_mac_app(qt5: bool) -> None: """Patch .app to save some space and make it signable.""" dist_path = pathlib.Path('dist') - ver = '6' if qt6 else '5' + ver = '5' if qt5 else '6' app_path = dist_path / 'qutebrowser.app' contents_path = app_path / 'Contents' @@ -280,7 +280,7 @@ def patch_mac_app(qt6: bool) -> None: file_path.unlink() file_path.symlink_to(target) - if qt6: + if not qt5: # Symlinking QtWebEngineCore.framework does not seem to work with Qt 6. # Also, the symlinking/moving before signing doesn't seem to be required. return @@ -333,7 +333,7 @@ def _mac_bin_path(base: pathlib.Path) -> pathlib.Path: def build_mac( *, gh_token: Optional[str], - qt6: bool, + qt5: bool, skip_packaging: bool, debug: bool, ) -> List[Artifact]: @@ -348,20 +348,20 @@ def build_mac( shutil.rmtree(d, ignore_errors=True) utils.print_title("Updating 3rdparty content") - update_3rdparty.run(ace=False, pdfjs=True, legacy_pdfjs=not qt6, fancy_dmg=False, + update_3rdparty.run(ace=False, pdfjs=True, legacy_pdfjs=qt5, fancy_dmg=False, gh_token=gh_token) utils.print_title("Building .app via pyinstaller") - call_tox(f'pyinstaller-64bit{"-qt6" if qt6 else ""}', '-r', debug=debug) + call_tox(f'pyinstaller-64bit{"-qt5" if qt5 else ""}', '-r', debug=debug) utils.print_title("Patching .app") - patch_mac_app(qt6=qt6) + patch_mac_app(qt5=qt5) utils.print_title("Re-signing .app") sign_mac_app() dist_path = pathlib.Path("dist") utils.print_title("Running pre-dmg smoke test") - smoke_test(_mac_bin_path(dist_path), debug=debug, qt6=qt6) + smoke_test(_mac_bin_path(dist_path), debug=debug, qt5=qt5) if skip_packaging: return [] @@ -371,7 +371,7 @@ def build_mac( subprocess.run(['make', '-f', dmg_makefile_path], check=True) suffix = "-debug" if debug else "" - suffix += "-qt6" if qt6 else "" + suffix += "-qt5" if qt5 else "" dmg_path = dist_path / f'qutebrowser-{qutebrowser.__version__}{suffix}.dmg' pathlib.Path('qutebrowser.dmg').rename(dmg_path) @@ -383,7 +383,7 @@ def build_mac( subprocess.run(['hdiutil', 'attach', dmg_path, '-mountpoint', tmp_path], check=True) try: - smoke_test(_mac_bin_path(tmp_path), debug=debug, qt6=qt6) + smoke_test(_mac_bin_path(tmp_path), debug=debug, qt5=qt5) finally: print("Waiting 10s for dmg to be detachable...") time.sleep(10) @@ -422,7 +422,7 @@ def _get_windows_python_path(x64: bool) -> pathlib.Path: def _build_windows_single( *, x64: bool, - qt6: bool, + qt5: bool, skip_packaging: bool, debug: bool, ) -> List[Artifact]: @@ -437,9 +437,9 @@ def _build_windows_single( python = _get_windows_python_path(x64=x64) suffix = "64bit" if x64 else "32bit" - if qt6: + if qt5: # FIXME:qt6 does this regress 391623d5ec983ecfc4512c7305c4b7a293ac3872? - suffix += "-qt6" + suffix += "-qt5" call_tox(f'pyinstaller-{suffix}', '-r', python=python, debug=debug) out_pyinstaller = dist_path / "qutebrowser" @@ -450,7 +450,7 @@ def _build_windows_single( verify_windows_exe(exe_path) utils.print_title(f"Running {human_arch} smoke test") - smoke_test(exe_path, debug=debug, qt6=qt6) + smoke_test(exe_path, debug=debug, qt5=qt5) if skip_packaging: return [] @@ -463,7 +463,7 @@ def _build_windows_single( desc_arch=human_arch, desc_suffix='' if x64 else ' (only for 32-bit Windows!)', debug=debug, - qt6=qt6, + qt5=qt5, ) @@ -472,12 +472,12 @@ def build_windows( skip_packaging: bool, only_32bit: bool, only_64bit: bool, - qt6: bool, + qt5: bool, debug: bool, ) -> List[Artifact]: """Build windows executables/setups.""" utils.print_title("Updating 3rdparty content") - update_3rdparty.run(nsis=True, ace=False, pdfjs=True, legacy_pdfjs=not qt6, + update_3rdparty.run(nsis=True, ace=False, pdfjs=True, legacy_pdfjs=qt5, fancy_dmg=False, gh_token=gh_token) utils.print_title("Building Windows binaries") @@ -493,14 +493,14 @@ def build_windows( x64=True, skip_packaging=skip_packaging, debug=debug, - qt6=qt6, + qt5=qt5, ) - if not only_64bit and not qt6: + if not only_64bit and not qt5: artifacts += _build_windows_single( x64=False, skip_packaging=skip_packaging, debug=debug, - qt6=qt6, + qt5=qt5, ) return artifacts @@ -514,7 +514,7 @@ def _package_windows_single( desc_suffix: str, filename_arch: str, debug: bool, - qt6: bool, + qt5: bool, ) -> List[Artifact]: """Build the given installer/zip for windows.""" artifacts = [] @@ -532,8 +532,8 @@ def _package_windows_single( ] if debug: name_parts.append('debug') - if qt6: - name_parts.append('qt6') + if qt5: + name_parts.append('qt5') name = '-'.join(name_parts) + '.exe' artifacts.append(Artifact( @@ -552,8 +552,8 @@ def _package_windows_single( ] if debug: zip_name_parts.append('debug') - if qt6: - zip_name_parts.append('qt6') + if qt5: + zip_name_parts.append('qt5') zip_name = '-'.join(zip_name_parts) + '.zip' zip_path = dist_path / zip_name @@ -738,8 +738,8 @@ def main() -> None: help="Skip Windows 32 bit build.", dest='only_64bit') parser.add_argument('--debug', action='store_true', required=False, help="Build a debug build.") - parser.add_argument('--qt6', action='store_true', required=False, - help="Build against PyQt6") + parser.add_argument('--qt5', action='store_true', required=False, + help="Build against PyQt5") args = parser.parse_args() utils.change_cwd() @@ -768,14 +768,14 @@ def main() -> None: skip_packaging=args.skip_packaging, only_32bit=args.only_32bit, only_64bit=args.only_64bit, - qt6=args.qt6, + qt5=args.qt5, debug=args.debug, ) elif IS_MACOS: artifacts = build_mac( gh_token=gh_token, skip_packaging=args.skip_packaging, - qt6=args.qt6, + qt5=args.qt5, debug=args.debug, ) else: diff --git a/scripts/dev/misc_checks.py b/scripts/dev/misc_checks.py index 240b5e6f1..215a1cfa0 100644 --- a/scripts/dev/misc_checks.py +++ b/scripts/dev/misc_checks.py @@ -27,7 +27,7 @@ import subprocess import tokenize import traceback import pathlib -from typing import List, Iterator, Optional +from typing import List, Iterator, Optional, Tuple REPO_ROOT = pathlib.Path(__file__).resolve().parents[2] sys.path.insert(0, str(REPO_ROOT)) @@ -152,6 +152,24 @@ def _check_spelling_file(path, fobj, patterns): return ok +def _check_spelling_all( + args: argparse.Namespace, + ignored: List[pathlib.Path], + patterns: List[Tuple[re.Pattern, str]], +) -> Optional[bool]: + try: + ok = True + for path in _get_files(verbose=args.verbose, ignored=ignored): + with tokenize.open(str(path)) as f: + if not _check_spelling_file(path, f, patterns): + ok = False + print() + return ok + except Exception: + traceback.print_exc() + return None + + def check_spelling(args: argparse.Namespace) -> Optional[bool]: """Check commonly misspelled words.""" # Words which I often misspell @@ -273,25 +291,13 @@ def check_spelling(args: argparse.Namespace) -> Optional[bool]: hint_data / 'ace' / 'ace.js', hint_data / 'bootstrap' / 'bootstrap.css', ] - - try: - ok = True - for path in _get_files(verbose=args.verbose, ignored=ignored): - with tokenize.open(path) as f: - if not _check_spelling_file(path, f, patterns): - ok = False - print() - return ok - except Exception: - traceback.print_exc() - return None + return _check_spelling_all(args=args, ignored=ignored, patterns=patterns) def check_pyqt_imports(args: argparse.Namespace) -> Optional[bool]: """Check for direct PyQt imports.""" ignored = [ pathlib.Path("qutebrowser", "qt"), - # FIXME:qt6 fix those too? pathlib.Path("misc", "userscripts"), pathlib.Path("scripts"), ] @@ -305,18 +311,7 @@ def check_pyqt_imports(args: argparse.Namespace) -> Optional[bool]: "Use 'import qutebrowser.qt.MODULE' instead", ) ] - # FIXME:qt6 unify this with check_spelling somehow? - try: - ok = True - for path in _get_files(verbose=args.verbose, ignored=ignored): - with tokenize.open(str(path)) as f: - if not _check_spelling_file(path, f, patterns): - ok = False - print() - return ok - except Exception: - traceback.print_exc() - return None + return _check_spelling_all(args=args, ignored=ignored, patterns=patterns) def check_vcs_conflict(args: argparse.Namespace) -> Optional[bool]: diff --git a/scripts/dev/run_vulture.py b/scripts/dev/run_vulture.py index 960b5a514..1e7ed0f61 100755 --- a/scripts/dev/run_vulture.py +++ b/scripts/dev/run_vulture.py @@ -60,7 +60,6 @@ def whitelist_generator(): # noqa: C901 yield 'qutebrowser.misc.sql.SqliteErrorCode.CONSTRAINT' yield 'qutebrowser.misc.throttle.Throttle.set_delay' yield 'qutebrowser.misc.guiprocess.GUIProcess.stderr' - yield 'qutebrowser.qt.machinery._autoselect_wrapper' # FIXME:qt6 # Qt attributes yield 'PyQt5.QtWebKit.QWebPage.ErrorPageExtensionReturn().baseUrl' diff --git a/scripts/dev/standardpaths_tester.py b/scripts/dev/standardpaths_tester.py index ff85b2a4c..bbd0a39fb 100644 --- a/scripts/dev/standardpaths_tester.py +++ b/scripts/dev/standardpaths_tester.py @@ -21,7 +21,7 @@ import os import sys -from PyQt5.QtCore import (QT_VERSION_STR, PYQT_VERSION_STR, qVersion, +from PyQt6.QtCore import (QT_VERSION_STR, PYQT_VERSION_STR, qVersion, QStandardPaths, QCoreApplication) diff --git a/scripts/keytester.py b/scripts/keytester.py index 6d994114d..861133c06 100644 --- a/scripts/keytester.py +++ b/scripts/keytester.py @@ -21,8 +21,7 @@ Use python3 -m scripts.keytester to launch it. """ -from PyQt5.QtWidgets import QApplication - +from qutebrowser.qt.widgets import QApplication from qutebrowser.misc import miscwidgets app = QApplication([]) diff --git a/scripts/link_pyqt.py b/scripts/link_pyqt.py index 4581bef41..63bdde959 100644 --- a/scripts/link_pyqt.py +++ b/scripts/link_pyqt.py @@ -125,7 +125,7 @@ def get_lib_path(executable, name, required=True): raise ValueError("Unexpected output: {!r}".format(output)) -def link_pyqt(executable, venv_path, *, version='5'): +def link_pyqt(executable, venv_path, *, version): """Symlink the systemwide PyQt/sip into the venv. Args: diff --git a/scripts/mkvenv.py b/scripts/mkvenv.py index 625cedd1a..9e9c1f4a2 100755 --- a/scripts/mkvenv.py +++ b/scripts/mkvenv.py @@ -134,8 +134,7 @@ def pyqt_versions() -> List[str]: def _is_qt6_version(version: str) -> bool: """Check if the given version is Qt 6.""" - # FIXME:qt6 Adjust once auto = Qt 6 - return version == "6" or version.startswith("6.") + return version in ["auto", "6"] or version.startswith("6.") def run_venv( @@ -228,7 +227,7 @@ def requirements_file(name: str) -> pathlib.Path: def pyqt_requirements_file(version: str) -> pathlib.Path: """Get the filename of the requirements file for the given PyQt version.""" - name = 'pyqt' if version == 'auto' else 'pyqt-{}'.format(version) + name = 'pyqt-6' if version == 'auto' else f'pyqt-{version}' return requirements_file(name) @@ -439,7 +438,7 @@ def run_qt_smoke_test_single( def run_qt_smoke_test(venv_dir: pathlib.Path, *, pyqt_version: str) -> None: """Make sure the Qt installation works.""" # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-104415 - no_debug = pyqt_version in ("6.3", "6") and sys.platform == "darwin" + no_debug = pyqt_version == "6.3" and sys.platform == "darwin" if no_debug: try: run_qt_smoke_test_single(venv_dir, debug=False, pyqt_version=pyqt_version) @@ -505,6 +504,9 @@ def install_pyqt(venv_dir, args): install_pyqt_binary(venv_dir, args.pyqt_version) if args.pyqt_snapshot: install_pyqt_shapshot(venv_dir, args.pyqt_snapshot.split(',')) + # Workaround until pyqt 6.5.2 is released on pypi + elif args.pyqt_version in ("6.5", "6", "auto"): + install_pyqt_shapshot(venv_dir, ["PyQt6-Qt6", "PyQt6-WebEngine-Qt6"]) elif args.pyqt_type == 'source': install_pyqt_source(venv_dir, args.pyqt_version) elif args.pyqt_type == 'link': diff --git a/scripts/opengl_info.py b/scripts/opengl_info.py index 5dc8f81c6..7c5ede6e7 100644 --- a/scripts/opengl_info.py +++ b/scripts/opengl_info.py @@ -18,8 +18,8 @@ """Show information about the OpenGL setup.""" -from PyQt5.QtGui import (QOpenGLContext, QOpenGLVersionProfile, - QOffscreenSurface, QGuiApplication) +from PyQt6.QtGui import QOpenGLContext, QOffscreenSurface, QGuiApplication +from PyQt6.QtOpenGL import QOpenGLVersionProfile, QOpenGLVersionFunctionsFactory app = QGuiApplication([]) @@ -38,7 +38,7 @@ print(f"GLES: {ctx.isOpenGLES()}") vp = QOpenGLVersionProfile() vp.setVersion(2, 0) -vf = ctx.versionFunctions(vp) +vf = QOpenGLVersionFunctionsFactory.get(vp, ctx) print(f"Vendor: {vf.glGetString(vf.GL_VENDOR)}") print(f"Renderer: {vf.glGetString(vf.GL_RENDERER)}") print(f"Version: {vf.glGetString(vf.GL_VERSION)}") |