Fix wrong inport of PyQt5 version (#1324)

This commit is contained in:
Veronica Berglyd Olsen
2023-01-29 02:13:32 +01:00
parent e2f7e77ec2
commit 0c75a53e57
5 changed files with 14 additions and 27 deletions
+2 -2
View File
@@ -179,12 +179,12 @@ def main(sysArgs=None):
"At least Python 3.7 is required, found %s" % CONFIG.verPyString "At least Python 3.7 is required, found %s" % CONFIG.verPyString
) )
errorCode |= 0x04 errorCode |= 0x04
if CONFIG.verQtValue < 51000: if CONFIG.verQtValue < 0x050a00:
errorData.append( errorData.append(
"At least Qt5 version 5.10 is required, found %s" % CONFIG.verQtString "At least Qt5 version 5.10 is required, found %s" % CONFIG.verQtString
) )
errorCode |= 0x08 errorCode |= 0x08
if CONFIG.verPyQtValue < 51000: if CONFIG.verPyQtValue < 0x050a00:
errorData.append( errorData.append(
"At least PyQt5 version 5.10 is required, found %s" % CONFIG.verPyQtString "At least PyQt5 version 5.10 is required, found %s" % CONFIG.verPyQtString
) )
+6 -19
View File
@@ -30,14 +30,13 @@ import logging
from time import time from time import time
from pathlib import Path from pathlib import Path
from PyQt5.Qt import PYQT_VERSION_STR
from PyQt5.QtCore import ( from PyQt5.QtCore import (
QT_VERSION_STR, QStandardPaths, QSysInfo, QLocale, QLibraryInfo, QT_VERSION, QT_VERSION_STR, PYQT_VERSION, PYQT_VERSION_STR, QStandardPaths,
QTranslator QSysInfo, QLocale, QLibraryInfo, QTranslator
) )
from novelwriter.error import logException, formatException from novelwriter.error import logException, formatException
from novelwriter.common import checkPath, splitVersionNumber, formatTimeStamp, NWConfigParser from novelwriter.common import checkPath, formatTimeStamp, NWConfigParser
from novelwriter.constants import nwFiles, nwUnicode from novelwriter.constants import nwFiles, nwUnicode
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -190,25 +189,13 @@ class Config:
# ========================== # ==========================
# Check Qt5 Versions # Check Qt5 Versions
verQt = splitVersionNumber(QT_VERSION_STR) self.verQtString = QT_VERSION_STR
self.verQtString = QT_VERSION_STR self.verQtValue = QT_VERSION
self.verQtMajor = verQt[0]
self.verQtMinor = verQt[1]
self.verQtPatch = verQt[2]
self.verQtValue = verQt[3]
verQt = splitVersionNumber(PYQT_VERSION_STR)
self.verPyQtString = PYQT_VERSION_STR self.verPyQtString = PYQT_VERSION_STR
self.verPyQtMajor = verQt[0] self.verPyQtValue = PYQT_VERSION
self.verPyQtMinor = verQt[1]
self.verPyQtPatch = verQt[2]
self.verPyQtValue = verQt[3]
# Check Python Version # Check Python Version
self.verPyString = sys.version.split()[0] self.verPyString = sys.version.split()[0]
self.verPyMajor = sys.version_info[0]
self.verPyMinor = sys.version_info[1]
self.verPyPatch = sys.version_info[2]
self.verPyHexVal = sys.hexversion self.verPyHexVal = sys.hexversion
# Check OS Type # Check OS Type
+1 -1
View File
@@ -2512,7 +2512,7 @@ class GuiDocEditSearch(QFrame):
# Using the Unicode-capable QRegularExpression class was # Using the Unicode-capable QRegularExpression class was
# only added in Qt 5.13. Otherwise, 5.3 and up supports # only added in Qt 5.13. Otherwise, 5.3 and up supports
# only the QRegExp class. # only the QRegExp class.
if self.mainConf.verQtValue >= 51300: if self.mainConf.verQtValue >= 0x050d00:
rxOpt = QRegularExpression.UseUnicodePropertiesOption rxOpt = QRegularExpression.UseUnicodePropertiesOption
if not self.isCaseSense: if not self.isCaseSense:
rxOpt |= QRegularExpression.CaseInsensitiveOption rxOpt |= QRegularExpression.CaseInsensitiveOption
+3 -3
View File
@@ -87,9 +87,9 @@ class GuiMain(QMainWindow):
logger.info("OS: %s", self.mainConf.osType) logger.info("OS: %s", self.mainConf.osType)
logger.info("Kernel: %s", self.mainConf.kernelVer) logger.info("Kernel: %s", self.mainConf.kernelVer)
logger.info("Host: %s", self.mainConf.hostName) logger.info("Host: %s", self.mainConf.hostName)
logger.info("Qt5: %s (%d)", self.mainConf.verQtString, self.mainConf.verQtValue) logger.info("Qt5: %s (0x%06x)", self.mainConf.verQtString, self.mainConf.verQtValue)
logger.info("PyQt5: %s (%d)", self.mainConf.verPyQtString, self.mainConf.verPyQtValue) logger.info("PyQt5: %s (0x%06x)", self.mainConf.verPyQtString, self.mainConf.verPyQtValue)
logger.info("Python: %s (0x%x)", self.mainConf.verPyString, self.mainConf.verPyHexVal) logger.info("Python: %s (0x%08x)", self.mainConf.verPyString, self.mainConf.verPyHexVal)
logger.info("GUI Language: %s", self.mainConf.guiLocale) logger.info("GUI Language: %s", self.mainConf.guiLocale)
# Core Classes # Core Classes
+2 -2
View File
@@ -155,8 +155,8 @@ def testBaseInit_Imports(caplog, monkeypatch, tmpPath):
monkeypatch.setattr("PyQt5.QtWidgets.QErrorMessage.showMessage", lambda *a: None) monkeypatch.setattr("PyQt5.QtWidgets.QErrorMessage.showMessage", lambda *a: None)
monkeypatch.setitem(sys.modules, "lxml", None) monkeypatch.setitem(sys.modules, "lxml", None)
monkeypatch.setattr("sys.hexversion", 0x0) monkeypatch.setattr("sys.hexversion", 0x0)
monkeypatch.setattr("novelwriter.CONFIG.verQtValue", 50000) monkeypatch.setattr("novelwriter.CONFIG.verQtValue", 0x050000)
monkeypatch.setattr("novelwriter.CONFIG.verPyQtValue", 50000) monkeypatch.setattr("novelwriter.CONFIG.verPyQtValue", 0x050000)
with pytest.raises(SystemExit) as ex: with pytest.raises(SystemExit) as ex:
_ = novelwriter.main( _ = novelwriter.main(