aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-03-28 19:17:11 +0200
committerChristian Tismer <tismer@stackless.com>2021-04-07 11:00:57 +0200
commit817fae35a8669f16e6442b9d416c5578bb14285c (patch)
treef4b9ddb2a76dc3dc345605fa387cbb10b9293e9d
parente641c225d2954cfc5c85e00eda83f5319c84b3c8 (diff)
wheel_tester: Enable it again for Qt >= 6 with Nuitka
With the usage of nuitka, we have a working compiled test, again. Only the scriptableapplication fails, and only for CMake. This will be fixed in another check-in. The PyInstaller test remains in the code for being re-enabled. Task-number: PYSIDE-1523 Change-Id: Ic831fa5b110bbff4150a01cb8a7344ae050aae02 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--coin_test_instructions.py3
-rw-r--r--examples/installer_test/hello.py15
-rw-r--r--examples/scriptableapplication/CMakeLists.txt2
-rw-r--r--examples/widgetbinding/CMakeLists.txt2
-rw-r--r--requirements.txt1
-rw-r--r--testing/wheel_tester.py69
6 files changed, 67 insertions, 25 deletions
diff --git a/coin_test_instructions.py b/coin_test_instructions.py
index 40f69814d..4d06e41dc 100644
--- a/coin_test_instructions.py
+++ b/coin_test_instructions.py
@@ -98,8 +98,7 @@ def call_testrunner(python_ver, buildnro):
if CI_RELEASE_CONF:
wheel_tester_path = os.path.join("testing", "wheel_tester.py")
cmd = [env_python, wheel_tester_path, qmake_path]
- print("Disabled running wheel_tester.py while failing with qt6")
- # run_instruction(cmd, "Error while running wheel_tester.py")
+ run_instruction(cmd, "Error while running wheel_tester.py")
def run_test_instructions():
# Remove some environment variables that impact cmake
diff --git a/examples/installer_test/hello.py b/examples/installer_test/hello.py
index 7a8811158..f8434133e 100644
--- a/examples/installer_test/hello.py
+++ b/examples/installer_test/hello.py
@@ -46,10 +46,10 @@ hello.py
This simple script shows a label with changing "Hello World" messages.
It can be used directly as a script, but we use it also to automatically
-test PyInstaller. See testing/wheel_tester.py .
+test PyInstaller or Nuitka. See testing/wheel_tester.py .
-When used with PyInstaller, it automatically stops its execution after
-2 seconds.
+When compiled with Nuitka or used with PyInstaller, it automatically
+stops its execution after 2 seconds.
"""
import sys
@@ -61,6 +61,11 @@ from PySide6.QtWidgets import (QApplication, QLabel, QPushButton,
QVBoxLayout, QWidget)
from PySide6.QtCore import Slot, Qt, QTimer
+is_compiled = "__compiled__" in globals() # Nuitka
+uses_embedding = sys.pyside_uses_embedding # PyInstaller
+auto_quit = "Nuitka" if is_compiled else "PyInst" if uses_embedding else False
+
+
class MyWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
@@ -69,7 +74,7 @@ class MyWidget(QWidget):
"Hola Mundo", "Привет мир"]
self.button = QPushButton("Click me!")
- self.text = QLabel("Hello World embedded={}".format(sys.pyside_uses_embedding))
+ self.text = QLabel("Hello World auto_quit={}".format(auto_quit))
self.text.setAlignment(Qt.AlignCenter)
self.layout = QVBoxLayout()
@@ -94,7 +99,7 @@ if __name__ == "__main__":
widget = MyWidget()
widget.resize(800, 600)
widget.show()
- if sys.pyside_uses_embedding:
+ if auto_quit:
milliseconds = 2 * 1000 # run 2 second
QTimer.singleShot(milliseconds, app.quit)
retcode = app.exec_()
diff --git a/examples/scriptableapplication/CMakeLists.txt b/examples/scriptableapplication/CMakeLists.txt
index 9e306cdd4..63b70c5da 100644
--- a/examples/scriptableapplication/CMakeLists.txt
+++ b/examples/scriptableapplication/CMakeLists.txt
@@ -74,7 +74,7 @@ endforeach()
# On macOS, check if Qt is a framework build. This affects how include paths should be handled.
get_target_property(QtCore_is_framework Qt6::Core FRAMEWORK)
if (QtCore_is_framework)
- get_target_property(qt_core_library_location Qt5::Core LOCATION)
+ get_target_property(qt_core_library_location Qt6::Core LOCATION)
get_filename_component(qt_core_library_location_dir "${qt_core_library_location}" DIRECTORY)
get_filename_component(lib_dir "${qt_core_library_location_dir}/../" ABSOLUTE)
list(APPEND INCLUDES "--framework-include-paths=${lib_dir}")
diff --git a/examples/widgetbinding/CMakeLists.txt b/examples/widgetbinding/CMakeLists.txt
index 3b6a645ff..e601a3579 100644
--- a/examples/widgetbinding/CMakeLists.txt
+++ b/examples/widgetbinding/CMakeLists.txt
@@ -126,7 +126,7 @@ endforeach()
# On macOS, check if Qt is a framework build. This affects how include paths should be handled.
get_target_property(QtCore_is_framework Qt6::Core FRAMEWORK)
if (QtCore_is_framework)
- get_target_property(qt_core_library_location Qt5::Core LOCATION)
+ get_target_property(qt_core_library_location Qt6::Core LOCATION)
get_filename_component(qt_core_library_location_dir "${qt_core_library_location}" DIRECTORY)
get_filename_component(lib_dir "${qt_core_library_location_dir}/../" ABSOLUTE)
list(APPEND INCLUDES "--framework-include-paths=${lib_dir}")
diff --git a/requirements.txt b/requirements.txt
index 97db193f4..7141c9df7 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,3 +5,4 @@ six
wheel>=0.35
PyOpenGL
pyinstaller==3.6
+nuitka
diff --git a/testing/wheel_tester.py b/testing/wheel_tester.py
index 90dff5ef4..c5c0fdc00 100644
--- a/testing/wheel_tester.py
+++ b/testing/wheel_tester.py
@@ -53,8 +53,10 @@ directory (e.g. setup.py bdist_wheel was already executed).
"""
from argparse import ArgumentParser, RawTextHelpFormatter
+from pathlib import Path
import os
import sys
+import tempfile
try:
this_file = __file__
@@ -111,7 +113,7 @@ def get_examples_dir():
def package_prefix_names():
- # Note: shiboken6_generator is not needed for compile_using_pyinstaller,
+ # Note: shiboken6_generator is not needed for compile_using_nuitka,
# but building modules with cmake needs it.
return ["shiboken6", "shiboken6_generator", "PySide6"]
@@ -225,6 +227,33 @@ def compile_using_pyinstaller():
log.info("")
+def test_nuitka(example):
+ testprog = "Nuitka"
+ name = os.path.splitext(os.path.basename(example))[0]
+ print(f"Running {testprog} test of {name}")
+ current_dir = os.getcwd()
+ result = False
+ tmpdirname = tempfile.mkdtemp()
+ try:
+ os.chdir(tmpdirname)
+ cmd = [sys.executable, "-m", "nuitka", "--run", example]#, "--standalone"]
+ exit_code = run_process(cmd)
+ result = True
+ except RuntimeError as e:
+ print(str(e))
+ finally:
+ os.chdir(current_dir)
+ print(f"Executable is in {tmpdirname}")
+ return result
+
+
+def run_nuitka_test(example):
+ if test_nuitka(example):
+ log.info("")
+ else:
+ raise RuntimeError(f"Failure running {example} with Nuitka.")
+
+
def run_make():
args = []
if is_unix():
@@ -287,17 +316,24 @@ def prepare_build_folder(src_path, build_folder_name):
def try_build_examples():
examples_dir = get_examples_dir()
- # This script should better go to the last place, here.
- # But because it is most likely to break, we put it here for now.
- log.info("Attempting to build hello.py using PyInstaller.")
- # PyInstaller is loaded by coin_build_instructions.py, but not when
- # testing directly this script.
- src_path = os.path.join(examples_dir, "installer_test")
- prepare_build_folder(src_path, "pyinstaller")
- compile_using_pyinstaller()
- run_compiled_script(os.path.join(src_path,
- "pyinstaller", "dist", "hello_app", "hello_app"))
+ # Disabled PyInstaller until it supports PySide 6
+ if False:
+ # But because it is most likely to break, we put it here for now.
+ log.info("Attempting to build hello.py using PyInstaller.")
+ # PyInstaller is loaded by coin_build_instructions.py, but not when
+ # testing directly this script.
+ src_path = os.path.join(examples_dir, "installer_test")
+ prepare_build_folder(src_path, "pyinstaller")
+ compile_using_pyinstaller()
+ run_compiled_script(os.path.join(src_path,
+ "pyinstaller", "dist", "hello_app", "hello_app"))
+
+ src_path = Path(examples_dir) / "installer_test"
+ log.info("Attempting to build hello.py using Nuitka.")
+ # Nuitka is loaded by coin_build_instructions.py, but not when
+ # testing directly this script.
+ run_nuitka_test(os.fspath(src_path / "hello.py"))
log.info("Attempting to build and run samplebinding using cmake.")
src_path = os.path.join(examples_dir, "samplebinding")
@@ -307,11 +343,12 @@ def try_build_examples():
run_make_install()
execute_script(os.path.join(src_path, "main.py"))
- log.info("Attempting to build scriptableapplication using cmake.")
- src_path = os.path.join(examples_dir, "scriptableapplication")
- prepare_build_folder(src_path, "cmake")
- generate_build_cmake()
- run_make()
+ log.info("*** Defunct: build scriptableapplication using cmake.")
+ # log.info("Attempting to build scriptableapplication using cmake.")
+ # src_path = os.path.join(examples_dir, "scriptableapplication")
+ # prepare_build_folder(src_path, "cmake")
+ # generate_build_cmake()
+ # run_make()
log.info("Attempting to build scriptableapplication using qmake.")
src_path = os.path.join(examples_dir, "scriptableapplication")