From 3f477fb62b20a5a930986a79d4e3baad97ddb0a0 Mon Sep 17 00:00:00 2001 From: Wiktor Zykubek Date: Mon, 10 Jul 2023 01:29:19 +0200 Subject: [PATCH] Update prebuild.py --- prebuild.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/prebuild.py b/prebuild.py index 78064a4..24c73c2 100644 --- a/prebuild.py +++ b/prebuild.py @@ -1,5 +1,29 @@ # This Python file uses the following encoding: utf-8 +import sys import os +from shutil import which -os.system("pyside6-uic form.ui -o openfm_qt/ui_form.py") +UI_DIR = "ui" + + +class UICNotFound(Exception): + pass + + +if sys.platform == "linux": + exe = "pyside6-uic" + exe_alt = "/usr/lib/qt6/uic" +elif sys.platform == "win32": + exe = "pyside6-uic.exe" + exe_alt = None + +if not which(exe) and not which(exe_alt): + raise UICNotFound("User Interface Compiler binary not found.") +elif not which(exe) and which(exe_alt): + exe = exe_alt + +for f in os.listdir(UI_DIR): + if exe == "/usr/lib/qt6/uic": + __flags = "--generator python" + os.system(f"{exe} {UI_DIR}/{f} -o openfm_qt/ui_{f[:-3]}.py {__flags}")