mirror of
https://github.com/Nuitka/Nuitka.git
synced 2026-12-05 22:14:28 +01:00
* Moved framework bundle handling to "nuitka.freezer.MacOSFrameworkBundles", and added Mach-O checks for framework version directories, and fixed helper executable rpaths and version symlinks. * Added the PyQt6 Qt library and translation target paths, framework detection, and WebEngine process path handling. * Removed the macOS PyQt6 unsupported check, filtered non-DLL Qt plugin files they include in their wheels, and added the PyQt6 framework requirements for newer Qt versions. * Converted the PyQt6 tests to app distribution mode, removed the macOS skip, and added a Qt WebEngine frameworks regression test.
118 lines
2.9 KiB
Python
118 lines
2.9 KiB
Python
# Copyright 2026, Kay Hayen, mailto:kay.hayen@gmail.com find license text at end of file
|
|
|
|
|
|
"""Regression test for macOS PyQt6 Qt WebEngine framework inclusion."""
|
|
|
|
# nuitka-project: --enable-plugin=pyqt6
|
|
# nuitka-project: --mode=app
|
|
# nuitka-project: --macos-app-icon=none
|
|
|
|
# nuitka-skip-unless-expression: sys.platform == "darwin"
|
|
# nuitka-skip-unless-imports: PyQt6.QtWebEngineCore
|
|
|
|
from __future__ import print_function
|
|
|
|
import os
|
|
import sys
|
|
|
|
from PyQt6.QtCore import QTimer, QUrl
|
|
from PyQt6.QtGui import QGuiApplication
|
|
from PyQt6.QtWebEngineCore import QWebEnginePage
|
|
|
|
os.environ.setdefault("QTWEBENGINE_DISABLE_SANDBOX", "1")
|
|
|
|
|
|
# The macOS builder is headless, so avoid requiring a visible WebEngine widget.
|
|
app = QGuiApplication(sys.argv[:1] + ["-platform", "offscreen"])
|
|
page = QWebEnginePage()
|
|
|
|
html = """\
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>qtwe4168</title>
|
|
<script>
|
|
function getAnswer() {
|
|
return document.getElementById("answer").textContent;
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<h1 id="answer">4168</h1>
|
|
</body>
|
|
</html>
|
|
"""
|
|
|
|
state = {"error": None, "timed_out": False}
|
|
|
|
|
|
def onFailure(message):
|
|
state["error"] = message
|
|
print("failure=%s" % message)
|
|
sys.stdout.flush()
|
|
app.quit()
|
|
|
|
|
|
def onJavaScriptDone(result):
|
|
print("js-result=%s" % result)
|
|
|
|
if result != "4168":
|
|
onFailure("Unexpected JavaScript result '%s'" % result)
|
|
return
|
|
|
|
sys.stdout.flush()
|
|
app.quit()
|
|
|
|
|
|
def onLoadFinished(ok):
|
|
print("loaded=%s" % ok)
|
|
|
|
if not ok:
|
|
onFailure("WebEngine failed to load inline HTML")
|
|
return
|
|
|
|
title = page.title()
|
|
print("title=%s" % title)
|
|
|
|
if title != "qtwe4168":
|
|
onFailure("Unexpected page title '%s'" % title)
|
|
return
|
|
|
|
page.runJavaScript("getAnswer()", onJavaScriptDone)
|
|
|
|
|
|
def onTimeout():
|
|
state["timed_out"] = True
|
|
print("timeout")
|
|
sys.stdout.flush()
|
|
app.quit()
|
|
|
|
|
|
page.loadFinished.connect(onLoadFinished)
|
|
QTimer.singleShot(15000, onTimeout)
|
|
page.setHtml(html, QUrl("file:///qtwe4168.html"))
|
|
app.exec()
|
|
|
|
if state["error"] is not None:
|
|
raise AssertionError(state["error"])
|
|
|
|
if state["timed_out"]:
|
|
raise AssertionError("WebEngine timed out")
|
|
|
|
# Python test originally created or extracted from other peoples work. The
|
|
# parts from me are licensed as below. It is at least Free Software where
|
|
# it's copied from other people. In these cases, that will normally be
|
|
# indicated.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|