summaryrefslogtreecommitdiffstats
path: root/scripts/packagetesting
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-01-30 13:07:18 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-02-05 12:20:51 +0100
commit975a80fc1f322d3374495db3f3c375af9d0b70de (patch)
tree697bf0b6dbd17e13bcc67ce1e94d2c46083c39cd /scripts/packagetesting
parentb649184ecdf694e612fd7acac9c914bf1afe711c (diff)
testwheel.py: Add a test for pyinstaller
Bundle up the tetrix example and run it. Change-Id: I6601cddfadd829354bc2a4ee0b7060c76a9289b4 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'scripts/packagetesting')
-rw-r--r--scripts/packagetesting/testwheel.py58
1 files changed, 52 insertions, 6 deletions
diff --git a/scripts/packagetesting/testwheel.py b/scripts/packagetesting/testwheel.py
index a34b02a8..6af76f6b 100644
--- a/scripts/packagetesting/testwheel.py
+++ b/scripts/packagetesting/testwheel.py
@@ -31,12 +31,14 @@
import os
import subprocess
import sys
+import tempfile
"""
Qt Package testing script for testing Qt for Python wheels
"""
+PYINSTALLER_EXAMPLE = 'widgets/widgets/tetrix.py'
def examples():
"""Compile a list of examples to be tested"""
@@ -56,14 +58,20 @@ def execute(args):
if exit_code != 0:
raise RuntimeError('FAIL({}): {}'.format(exit_code, log_string))
-
-def run_process_output(args):
- """Execute a command and capture output"""
+def run_process(args):
+ """Execute a command and return a tuple of exit code/stdout"""
popen = subprocess.Popen(args, universal_newlines=1,
stdout=subprocess.PIPE)
- print(popen.stdout.readlines())
+ lines = popen.stdout.readlines()
popen.wait()
- return popen.returncode
+ return (popen.returncode, lines)
+
+
+def run_process_output(args):
+ """Execute a command and print output"""
+ result = run_process(args)
+ print(result[1])
+ return result[0]
def run_example(root, path):
@@ -72,8 +80,41 @@ def run_example(root, path):
print('{} returned {}\n\n'.format(path, exit_code))
+def has_pyinstaller():
+ """Checks for PyInstaller"""
+ process_result = run_process(["pip", "list"])
+ for line in process_result[1]:
+ if line.startswith("PyInstaller"):
+ return True
+ return False
+
+
+def test_pyinstaller(example):
+ name = os.path.basename(example)[:-3]
+ print('Running PyInstaller test of {}'.format(name))
+ current_dir = os.getcwd()
+ result = False
+ with tempfile.TemporaryDirectory() as tmpdirname:
+ try:
+ os.chdir(tmpdirname)
+ cmd = ['pyinstaller', '--name={}'.format(name),
+ '--log-level=WARN', example]
+ execute(cmd)
+ if sys.platform != 'darwin':
+ binary = os.path.join(tmpdirname, 'dist', name, name)
+ if sys.platform == "win32":
+ binary += '.exe'
+ execute([binary])
+ result = True
+ except RuntimeError as e:
+ print(str(e))
+ finally:
+ os.chdir(current_dir)
+ return result
+
+
if __name__ == "__main__":
- if sys.version_info[0] < 3:
+ if sys.version_info[0] < 3: # Note: PyInstaller no longer supports Python 2
raise Exception('This script requires Python 3')
root = None
for p in sys.path:
@@ -86,3 +127,8 @@ if __name__ == "__main__":
print('Detected PySide2 at {}.'.format(root))
for e in examples():
run_example(root, e)
+
+ if has_pyinstaller():
+ test_pyinstaller(os.path.join(root, PYINSTALLER_EXAMPLE))
+ else:
+ print('PyInstaller not found, skipping test')