From 606b3f205d33bf6255e1fa38f691f9557351d0cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Tue, 23 May 2023 02:54:28 +0200 Subject: [PATCH] Added PySide6 support as firts option (due to arm64 support) --- client-py3/full/linux/installer.sh | 2 +- client-py3/full/linux/udsclient-appimage-x86_64.recipe | 1 + client-py3/full/src/UDSClientLauncher.py | 8 ++++++-- client-py3/full/src/UDSLauncherMac.py | 7 +++++-- client-py3/full/src/UDSResources_rc.py | 6 +++++- client-py3/full/src/UDSWindow.py | 7 +++++-- client-py3/full/src/uds/log.py | 9 +++++++++ 7 files changed, 32 insertions(+), 8 deletions(-) diff --git a/client-py3/full/linux/installer.sh b/client-py3/full/linux/installer.sh index 7cf443076..7d18e1ca5 100644 --- a/client-py3/full/linux/installer.sh +++ b/client-py3/full/linux/installer.sh @@ -7,7 +7,7 @@ update-desktop-database echo "Installation process done." echo "Remember that the following packages must be installed on system:" echo "* Python3 paramiko" -echo "* Python3 PyQt5" +echo "* Python3 PySide6 or PyQt5" echo "* Python3 six" echo "* Python3 requests" echo "* Python3 cryptography" diff --git a/client-py3/full/linux/udsclient-appimage-x86_64.recipe b/client-py3/full/linux/udsclient-appimage-x86_64.recipe index c0cabd1df..b13bb23ce 100644 --- a/client-py3/full/linux/udsclient-appimage-x86_64.recipe +++ b/client-py3/full/linux/udsclient-appimage-x86_64.recipe @@ -35,6 +35,7 @@ AppDir: include: - python3 - python3-pkg-resources + # In future, will be replaced with pyside6 (when available as debian package) - python3-pyqt5 - python3-paramiko - python3-cryptography diff --git a/client-py3/full/src/UDSClientLauncher.py b/client-py3/full/src/UDSClientLauncher.py index 146099d16..a622170aa 100644 --- a/client-py3/full/src/UDSClientLauncher.py +++ b/client-py3/full/src/UDSClientLauncher.py @@ -7,11 +7,15 @@ from uds.log import logger import UDSClient from UDSLauncherMac import Ui_MacLauncher -from PyQt5 import QtCore, QtWidgets, QtGui +# First, try to use PySide6 (has arm64, x86_64 support) +try: + from PySide6 import QtCore, QtWidgets, QtGui +except ImportError: # If not found, try to use PyQt5 (only x86_64) + from PyQt5 import QtCore, QtWidgets, QtGui # type: ignore SCRIPT_NAME = 'UDSClientLauncher' -class UdsApplication(QtWidgets.QApplication): +class UdsApplication(QtWidgets.QApplication): # type: ignore path: str tunnels: typing.List[subprocess.Popen] diff --git a/client-py3/full/src/UDSLauncherMac.py b/client-py3/full/src/UDSLauncherMac.py index f7bc90376..ff7ffb8ba 100644 --- a/client-py3/full/src/UDSLauncherMac.py +++ b/client-py3/full/src/UDSLauncherMac.py @@ -7,8 +7,11 @@ # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. - -from PyQt5 import QtCore, QtGui, QtWidgets +# Note: This file is generated by pyuic5, but it is modified to use PySide6 instead of PyQt5 if possible +try: + from PySide6 import QtCore, QtGui, QtWidgets +except ImportError: + from PyQt5 import QtCore, QtGui, QtWidgets # type: ignore class Ui_MacLauncher(object): diff --git a/client-py3/full/src/UDSResources_rc.py b/client-py3/full/src/UDSResources_rc.py index cfd021e53..e75b4ab9b 100644 --- a/client-py3/full/src/UDSResources_rc.py +++ b/client-py3/full/src/UDSResources_rc.py @@ -6,7 +6,11 @@ # # WARNING! All changes made in this file will be lost! -from PyQt5 import QtCore +# Note: This file is generated by pyuic5, but it is modified to use PySide6 instead of PyQt5 if possible +try: + from PySide6 import QtCore +except ImportError: + from PyQt5 import QtCore # type: ignore qt_resource_data = b"\ \x00\x00\x08\xed\ diff --git a/client-py3/full/src/UDSWindow.py b/client-py3/full/src/UDSWindow.py index c6704072a..332ae0e12 100644 --- a/client-py3/full/src/UDSWindow.py +++ b/client-py3/full/src/UDSWindow.py @@ -7,8 +7,11 @@ # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. - -from PyQt5 import QtCore, QtGui, QtWidgets +# Note: This file is generated by pyuic5, but it is modified to use PySide6 instead of PyQt5 if possible +try: + from PySide6 import QtCore, QtGui, QtWidgets +except ImportError: + from PyQt5 import QtCore, QtGui, QtWidgets # type: ignore class Ui_MainWindow(object): diff --git a/client-py3/full/src/uds/log.py b/client-py3/full/src/uds/log.py index fbb318fa4..4bd66340a 100644 --- a/client-py3/full/src/uds/log.py +++ b/client-py3/full/src/uds/log.py @@ -36,6 +36,14 @@ import platform import sys import tempfile +# First, try to use PySide6, available on arm64, x86_64, i386, ... +try: + from PySide6 import QtCore # Just to test if it's available + QT='PySide6' +except ImportError: # If not found, it is using PyQt5 + QT='PyQt5' + + LOGLEVEL = logging.INFO DEBUG = False @@ -79,6 +87,7 @@ if DEBUG: logger.debug(' Python compiler: %s', platform.python_compiler()) logger.debug(' Python build: %s', platform.python_build()) # Also environment variables and any useful info + logger.debug('Qt framework: %s', QT) logger.debug('Log level set to DEBUG') logger.debug('Environment variables:') for k, v in os.environ.items():