--- a/scripts/install.py Tue Sep 28 18:03:00 2021 +0200 +++ b/scripts/install.py Wed Sep 29 17:14:24 2021 +0200 @@ -42,6 +42,7 @@ doCompile = True yes2All = False ignorePyqt6Tools = False +verbose = False cfg = {} progLanguages = ["Python", "Ruby", "QSS"] sourceDir = "eric" @@ -120,17 +121,19 @@ print() print("Usage:") if sys.platform == "darwin": - print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" - " [-m name] [-n path] [-p python] [--no-apis] [--no-info]" - " [--no-tools] [--yes]" + print(" {0} [-chvxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" + " [-m name] [-n path] [-p python] [--help] [--no-apis]" + " [--no-info] [--no-tools] [--verbose] [--yes]" .format(progName)) elif sys.platform.startswith(("win", "cygwin")): - print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]" - " [--clean-desktop] [--no-apis] [--no-info] [--no-tools] [--yes]" + print(" {0} [-chvxz] [-a dir] [-b dir] [-d dir] [-f file]" + " [--clean-desktop] [--help] [--no-apis] [--no-info]" + " [--no-tools] [--verbose] [--yes]" .format(progName)) else: - print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" - " [--no-apis] [--no-info] [--no-tools] [--yes]" + print(" {0} [-chvxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" + " [--help] [--no-apis] [--no-info] [--no-tools] [--verbose]" + " [--yes]" .format(progName)) print("where:") print(" -h, --help display this help message") @@ -162,6 +165,7 @@ print(" --clean-desktop delete desktop links before installation") print(" --no-info don't create the install info file") print(" --no-tools don't install qt6-applications") + print(" -v, --verbose print some more information") print(" -x don't perform dependency checks (use on your own" " risk)") print(" -z don't compile the installed python files") @@ -1344,7 +1348,7 @@ if yes2All or force: answer = "y" else: - print("{0}\n\nShall '{1}' be installed using pip? (Y/n)" + print("{0}\nShall '{1}' be installed using pip? (Y/n)" .format(message, packageName), end=" ") answer = input() # secok if answer in ("", "Y", "y"): @@ -1422,6 +1426,8 @@ """ Perform some dependency checks. """ + global verbose + # TODO: update as necessary for PyQt6 6.2.0 requiredVersions = { "pyqt6": 0x60101, @@ -1459,10 +1465,12 @@ try: from PyQt6.QtCore import qVersion - except ImportError as msg: + except ImportError as err: + msg = "'PyQt6' could not be detected.{0}".format( + "\nError: {0}".format(err) if verbose else "") installed = not isSudo and pipInstall( "PyQt6>={0}".format(versionToStr(requiredVersions["pyqt6"])), - "'PyQt6' could not be detected.\nError: {0}".format(msg) + msg ) if installed: # try to import it again @@ -1481,48 +1489,55 @@ try: pyuic = "pyuic6" from PyQt6 import uic # __IGNORE_WARNING__ - except ImportError as msg: + except ImportError as err: print("Sorry, {0} is not installed.".format(pyuic)) - print('Error: {0}'.format(msg)) + if verbose: + print('Error: {0}'.format(err)) exit(1) print("Found {0}".format(pyuic)) try: from PyQt6 import QtWebEngineWidgets # __IGNORE_WARNING__ - except ImportError as msg: + except ImportError as err: if isSudo: print("Optional 'PyQt6-WebEngine' could not be detected.") else: # TODO: should PyQt6-WebEngine be a must requirement? + msg = ( + "Optional 'PyQt6-WebEngine' could not be detected.{0}" + .format("\nError: {0}".format(err) if verbose else "") + ) pipInstall( "PyQt6-WebEngine>={0}".format( versionToStr(requiredVersions["pyqt6-webengine"])), - "Optional 'PyQt6-WebEngine' could not be detected.\n" - "Error: {0}".format(msg), + msg, force=False ) try: from PyQt6 import QtCharts # __IGNORE_WARNING__ - except ImportError as msg: + except ImportError as err: if isSudo: print("Optional 'PyQt6-Charts' could not be detected.") else: + msg = "Optional 'PyQt6-Charts' could not be detected.{0}".format( + "\nError: {0}".format(err) if verbose else "") pipInstall( "PyQt6-Charts>={0}".format( versionToStr(requiredVersions["pyqt6-charts"])), - "Optional 'PyQt6-Charts' could not be detected.\n" - "Error: {0}".format(msg) + msg ) print("Found PyQt6-Charts") try: from PyQt6 import Qsci # __IGNORE_WARNING__ - except ImportError as msg: + except ImportError as err: + msg = "'PyQt6-QScintilla' could not be detected.{0}".format( + "\nError: {0}".format(err) if verbose else "") installed = not isSudo and pipInstall( "PyQt6-QScintilla>={0}".format( versionToStr(requiredVersions["pyqt6-qscintilla"])), - "'PyQt6-QScintilla' could not be detected.\nError: {0}".format(msg) + msg ) if installed: # try to import it again @@ -1571,9 +1586,10 @@ try: __import__(impModule) print("Found", name) - except ImportError as msg: + except ImportError as err: print('Sorry, please install {0}.'.format(name)) - print('Error: {0}'.format(msg)) + if verbose: + print('Error: {0}'.format(err)) modulesOK = False if not modulesOK: exit(1) @@ -1583,15 +1599,18 @@ try: __import__(optionalModulesList[optPackage][0]) print("Found", optPackage) - except ImportError as msg: + except ImportError as err: if isSudo: print("Optional '{0}' could not be detected." .format(optPackage)) else: + msg = "Optional '{0}' could not be detected.{1}".format( + optPackage, + "\nError: {0}".format(err) if verbose else "" + ) pipInstall( optPackage + optionalModulesList[optPackage][1], - "Optional '{0}' could not be detected.\n" - "Error: {1}".format(optPackage, msg) + msg ) # determine the platform dependent black list @@ -1876,6 +1895,7 @@ global installApis, doCleanDesktopLinks, yes2All global createInstallInfoFile, installCwd global ignorePyqt6Tools + global verbose if sys.version_info < (3, 6, 0) or sys.version_info > (3, 99, 99): print('Sorry, eric requires at least Python 3.6 for running.') @@ -1893,16 +1913,16 @@ try: if sys.platform.startswith(("win", "cygwin")): optlist, args = getopt.getopt( - argv[1:], "chxza:b:d:f:", - ["help", "no-apis", "no-info", "no-tools", "yes"]) + argv[1:], "chvxza:b:d:f:", + ["help", "no-apis", "no-info", "no-tools", "verbose", "yes"]) elif sys.platform == "darwin": optlist, args = getopt.getopt( - argv[1:], "chxza:b:d:f:i:m:n:p:", - ["help", "no-apis", "no-info", "no-tools", "yes"]) + argv[1:], "chvxza:b:d:f:i:m:n:p:", + ["help", "no-apis", "no-info", "no-tools", "verbose", "yes"]) else: optlist, args = getopt.getopt( - argv[1:], "chxza:b:d:f:i:", - ["help", "no-apis", "no-info", "no-tools", "yes"]) + argv[1:], "chvxza:b:d:f:i:", + ["help", "no-apis", "no-info", "no-tools", "verbose", "yes"]) except getopt.GetoptError as err: print(err) usage() @@ -1955,6 +1975,8 @@ ignorePyqt6Tools = True elif opt == "--no-info": createInstallInfoFile = False + elif opt in ["-v", "--verbose"]: + verbose = True infoName = "" installFromSource = not os.path.isdir(sourceDir)