--- a/scripts/install.py Tue Sep 06 13:39:18 2022 +0200 +++ b/scripts/install.py Tue Sep 06 15:08:41 2022 +0200 @@ -1738,7 +1738,7 @@ exit(1) print("Found PyQt6-QScintilla") - impModulesList = [ + pyqt6BaseModulesList = [ "PyQt6.QtGui", "PyQt6.QtNetwork", "PyQt6.QtPrintSupport", @@ -1747,20 +1747,13 @@ "PyQt6.QtSvgWidgets", "PyQt6.QtWidgets", ] - optionalModulesList = { + requiredModulesList = { # key is pip project name # value is tuple of package name, pip install constraint - "docutils": ("docutils", ""), - "Markdown": ("markdown", ""), - "pyyaml": ("yaml", ""), "tomlkit": ("tomlkit", ""), - "chardet": ("chardet", ""), "asttokens": ("asttokens", ""), "EditorConfig": ("editorconfig", ""), - "Send2Trash": ("send2trash", ""), "Pygments": ("pygments", ""), - "pyenchant": ("enchant", ""), - "wheel": ("wheel", ""), "parso": ("parso", ""), "jedi": ("jedi", ""), "packaging": ("packaging", ""), @@ -1769,15 +1762,26 @@ "trove-classifiers": ("trove_classifiers", ""), "black": ("black", ">=22.6.0"), } + optionalModulesList = { + # key is pip project name + # value is tuple of package name, pip install constraint + "docutils": ("docutils", ""), + "Markdown": ("markdown", ""), + "pyyaml": ("yaml", ""), + "chardet": ("chardet", ""), + "Send2Trash": ("send2trash", ""), + "pyenchant": ("enchant", ""), + "wheel": ("wheel", ""), + } if not ignorePyqt6Tools: optionalModulesList["qt6-applications"] = ("qt6_applications", "") - # check mandatory modules + # check mandatory PyQt6 modules modulesOK = True - for impModule in impModulesList: - name = impModule.split(".")[1] + for pyqt6BaseModule in pyqt6BaseModulesList: + name = pyqt6BaseModule.split(".")[1] try: - __import__(impModule) + __import__(pyqt6BaseModule) print("Found", name) except ImportError as err: print("Sorry, please install {0}.".format(name)) @@ -1787,7 +1791,32 @@ if not modulesOK: exit(1) + # check required modules + requiredMissing = False + for requiredPackage in requiredModulesList: + try: + __import__(requiredModulesList[requiredPackage][0]) + print("Found", requiredPackage) + except ImportError as err: + if isSudo: + print("Required '{0}' could not be detected.".format(requiredPackage)) + requiredMissing = True + else: + msg = "Required '{0}' could not be detected.{1}".format( + requiredPackage, "\nError: {0}".format(err) if verbose else "" + ) + pipInstall( + requiredPackage + requiredModulesList[requiredPackage][1], + msg, + force=True, + ) + if requiredMissing: + print("Some required packages are missing and could not be installed.") + print("Install them manually with:") + print(" {0} install-dependencies.py --required".format(sys.executable)) + # check optional modules + optionalMissing = False for optPackage in optionalModulesList: try: __import__(optionalModulesList[optPackage][0]) @@ -1795,11 +1824,20 @@ except ImportError as err: if isSudo: print("Optional '{0}' could not be detected.".format(optPackage)) + optionalMissing = True else: msg = "Optional '{0}' could not be detected.{1}".format( optPackage, "\nError: {0}".format(err) if verbose else "" ) pipInstall(optPackage + optionalModulesList[optPackage][1], msg) + if optionalMissing: + print("Some optional packages are missing and could not be installed.") + print("Install them manually with:") + print(" {0} install-dependencies.py --optional".format(sys.executable)) + + if requiredMissing and optionalMissing: + print("Alternatively you may install all of them with:") + print(" {0} install-dependencies.py --all".format(sys.executable)) # determine the platform dependent black list if sys.platform.startswith(("win", "cygwin")):