From 06c72143d2058ad5a856d4743edcf1f54d932598 Mon Sep 17 00:00:00 2001 From: Jarrett Johnson Date: Fri, 16 Aug 2024 18:03:15 -0400 Subject: [PATCH] add pyside2-uic to possible uic exec candidate --- modules/pymol/Qt/utils.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/pymol/Qt/utils.py b/modules/pymol/Qt/utils.py index 0f22a58db..0201f1da5 100644 --- a/modules/pymol/Qt/utils.py +++ b/modules/pymol/Qt/utils.py @@ -1,5 +1,7 @@ from pymol.Qt import * +import shutil +import subprocess class UpdateLock: """ @@ -286,11 +288,18 @@ def loadUi(uifile, widget): else: import pysideuic + def find_valid_uic_exe(execs): + for exe in execs: + if shutil.which(exe): + return exe + if pysideuic is None: - import subprocess - p = subprocess.Popen(['uic', '-g', 'python', uifile], + uic_exec = find_valid_uic_exe(('uic', 'pyside2-uic')) + if uic_exec is None: + raise RuntimeError('uic not found') + p = subprocess.Popen([uic_exec, '-g', 'python', uifile], stdout=subprocess.PIPE) - source = p.communicate()[0] + source, _ = p.communicate() # workaround for empty retranslateUi bug source += b'\n' + b' ' * 8 + b'pass' else: