scripts/install.py

branch
eric7
changeset 8656
8fbaa183c41e
parent 8654
7244c30032d8
child 8660
1848e8e4b380
equal deleted inserted replaced
8655:e8dd241cbfef 8656:8fbaa183c41e
40 doCleanDesktopLinks = False 40 doCleanDesktopLinks = False
41 forceCleanDesktopLinks = False 41 forceCleanDesktopLinks = False
42 doCompile = True 42 doCompile = True
43 yes2All = False 43 yes2All = False
44 ignorePyqt6Tools = False 44 ignorePyqt6Tools = False
45 verbose = False
45 cfg = {} 46 cfg = {}
46 progLanguages = ["Python", "Ruby", "QSS"] 47 progLanguages = ["Python", "Ruby", "QSS"]
47 sourceDir = "eric" 48 sourceDir = "eric"
48 eric7SourceDir = os.path.join(sourceDir, "eric7") 49 eric7SourceDir = os.path.join(sourceDir, "eric7")
49 configName = 'eric7config.py' 50 configName = 'eric7config.py'
118 global macAppBundleName, macAppBundlePath, macPythonExe 119 global macAppBundleName, macAppBundlePath, macPythonExe
119 120
120 print() 121 print()
121 print("Usage:") 122 print("Usage:")
122 if sys.platform == "darwin": 123 if sys.platform == "darwin":
123 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 124 print(" {0} [-chvxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
124 " [-m name] [-n path] [-p python] [--no-apis] [--no-info]" 125 " [-m name] [-n path] [-p python] [--help] [--no-apis]"
125 " [--no-tools] [--yes]" 126 " [--no-info] [--no-tools] [--verbose] [--yes]"
126 .format(progName)) 127 .format(progName))
127 elif sys.platform.startswith(("win", "cygwin")): 128 elif sys.platform.startswith(("win", "cygwin")):
128 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]" 129 print(" {0} [-chvxz] [-a dir] [-b dir] [-d dir] [-f file]"
129 " [--clean-desktop] [--no-apis] [--no-info] [--no-tools] [--yes]" 130 " [--clean-desktop] [--help] [--no-apis] [--no-info]"
131 " [--no-tools] [--verbose] [--yes]"
130 .format(progName)) 132 .format(progName))
131 else: 133 else:
132 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 134 print(" {0} [-chvxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
133 " [--no-apis] [--no-info] [--no-tools] [--yes]" 135 " [--help] [--no-apis] [--no-info] [--no-tools] [--verbose]"
136 " [--yes]"
134 .format(progName)) 137 .format(progName))
135 print("where:") 138 print("where:")
136 print(" -h, --help display this help message") 139 print(" -h, --help display this help message")
137 print(" -a dir where the API files will be installed") 140 print(" -a dir where the API files will be installed")
138 if apisDir: 141 if apisDir:
160 print(" -c don't cleanup old installation first") 163 print(" -c don't cleanup old installation first")
161 if sys.platform.startswith(("win", "cygwin")): 164 if sys.platform.startswith(("win", "cygwin")):
162 print(" --clean-desktop delete desktop links before installation") 165 print(" --clean-desktop delete desktop links before installation")
163 print(" --no-info don't create the install info file") 166 print(" --no-info don't create the install info file")
164 print(" --no-tools don't install qt6-applications") 167 print(" --no-tools don't install qt6-applications")
168 print(" -v, --verbose print some more information")
165 print(" -x don't perform dependency checks (use on your own" 169 print(" -x don't perform dependency checks (use on your own"
166 " risk)") 170 " risk)")
167 print(" -z don't compile the installed python files") 171 print(" -z don't compile the installed python files")
168 print(" --yes answer 'yes' to all questions") 172 print(" --yes answer 'yes' to all questions")
169 print() 173 print()
1342 1346
1343 ok = False 1347 ok = False
1344 if yes2All or force: 1348 if yes2All or force:
1345 answer = "y" 1349 answer = "y"
1346 else: 1350 else:
1347 print("{0}\n\nShall '{1}' be installed using pip? (Y/n)" 1351 print("{0}\nShall '{1}' be installed using pip? (Y/n)"
1348 .format(message, packageName), end=" ") 1352 .format(message, packageName), end=" ")
1349 answer = input() # secok 1353 answer = input() # secok
1350 if answer in ("", "Y", "y"): 1354 if answer in ("", "Y", "y"):
1351 exitCode = subprocess.call( # secok 1355 exitCode = subprocess.call( # secok
1352 [sys.executable, "-m", "pip", "install", "--prefer-binary", 1356 [sys.executable, "-m", "pip", "install", "--prefer-binary",
1420 1424
1421 def doDependancyChecks(): 1425 def doDependancyChecks():
1422 """ 1426 """
1423 Perform some dependency checks. 1427 Perform some dependency checks.
1424 """ 1428 """
1429 global verbose
1430
1425 # TODO: update as necessary for PyQt6 6.2.0 1431 # TODO: update as necessary for PyQt6 6.2.0
1426 requiredVersions = { 1432 requiredVersions = {
1427 "pyqt6": 0x60101, 1433 "pyqt6": 0x60101,
1428 "pyqt6-charts": 0x60101, 1434 "pyqt6-charts": 0x60101,
1429 "pyqt6-webengine": 0x60200, 1435 "pyqt6-webengine": 0x60200,
1457 print('Please install it and try again.') 1463 print('Please install it and try again.')
1458 exit(5) 1464 exit(5)
1459 1465
1460 try: 1466 try:
1461 from PyQt6.QtCore import qVersion 1467 from PyQt6.QtCore import qVersion
1462 except ImportError as msg: 1468 except ImportError as err:
1469 msg = "'PyQt6' could not be detected.{0}".format(
1470 "\nError: {0}".format(err) if verbose else "")
1463 installed = not isSudo and pipInstall( 1471 installed = not isSudo and pipInstall(
1464 "PyQt6>={0}".format(versionToStr(requiredVersions["pyqt6"])), 1472 "PyQt6>={0}".format(versionToStr(requiredVersions["pyqt6"])),
1465 "'PyQt6' could not be detected.\nError: {0}".format(msg) 1473 msg
1466 ) 1474 )
1467 if installed: 1475 if installed:
1468 # try to import it again 1476 # try to import it again
1469 try: 1477 try:
1470 from PyQt6.QtCore import qVersion 1478 from PyQt6.QtCore import qVersion
1479 print("Found PyQt6") 1487 print("Found PyQt6")
1480 1488
1481 try: 1489 try:
1482 pyuic = "pyuic6" 1490 pyuic = "pyuic6"
1483 from PyQt6 import uic # __IGNORE_WARNING__ 1491 from PyQt6 import uic # __IGNORE_WARNING__
1484 except ImportError as msg: 1492 except ImportError as err:
1485 print("Sorry, {0} is not installed.".format(pyuic)) 1493 print("Sorry, {0} is not installed.".format(pyuic))
1486 print('Error: {0}'.format(msg)) 1494 if verbose:
1495 print('Error: {0}'.format(err))
1487 exit(1) 1496 exit(1)
1488 print("Found {0}".format(pyuic)) 1497 print("Found {0}".format(pyuic))
1489 1498
1490 try: 1499 try:
1491 from PyQt6 import QtWebEngineWidgets # __IGNORE_WARNING__ 1500 from PyQt6 import QtWebEngineWidgets # __IGNORE_WARNING__
1492 except ImportError as msg: 1501 except ImportError as err:
1493 if isSudo: 1502 if isSudo:
1494 print("Optional 'PyQt6-WebEngine' could not be detected.") 1503 print("Optional 'PyQt6-WebEngine' could not be detected.")
1495 else: 1504 else:
1496 # TODO: should PyQt6-WebEngine be a must requirement? 1505 # TODO: should PyQt6-WebEngine be a must requirement?
1506 msg = (
1507 "Optional 'PyQt6-WebEngine' could not be detected.{0}"
1508 .format("\nError: {0}".format(err) if verbose else "")
1509 )
1497 pipInstall( 1510 pipInstall(
1498 "PyQt6-WebEngine>={0}".format( 1511 "PyQt6-WebEngine>={0}".format(
1499 versionToStr(requiredVersions["pyqt6-webengine"])), 1512 versionToStr(requiredVersions["pyqt6-webengine"])),
1500 "Optional 'PyQt6-WebEngine' could not be detected.\n" 1513 msg,
1501 "Error: {0}".format(msg),
1502 force=False 1514 force=False
1503 ) 1515 )
1504 1516
1505 try: 1517 try:
1506 from PyQt6 import QtCharts # __IGNORE_WARNING__ 1518 from PyQt6 import QtCharts # __IGNORE_WARNING__
1507 except ImportError as msg: 1519 except ImportError as err:
1508 if isSudo: 1520 if isSudo:
1509 print("Optional 'PyQt6-Charts' could not be detected.") 1521 print("Optional 'PyQt6-Charts' could not be detected.")
1510 else: 1522 else:
1523 msg = "Optional 'PyQt6-Charts' could not be detected.{0}".format(
1524 "\nError: {0}".format(err) if verbose else "")
1511 pipInstall( 1525 pipInstall(
1512 "PyQt6-Charts>={0}".format( 1526 "PyQt6-Charts>={0}".format(
1513 versionToStr(requiredVersions["pyqt6-charts"])), 1527 versionToStr(requiredVersions["pyqt6-charts"])),
1514 "Optional 'PyQt6-Charts' could not be detected.\n" 1528 msg
1515 "Error: {0}".format(msg)
1516 ) 1529 )
1517 print("Found PyQt6-Charts") 1530 print("Found PyQt6-Charts")
1518 1531
1519 try: 1532 try:
1520 from PyQt6 import Qsci # __IGNORE_WARNING__ 1533 from PyQt6 import Qsci # __IGNORE_WARNING__
1521 except ImportError as msg: 1534 except ImportError as err:
1535 msg = "'PyQt6-QScintilla' could not be detected.{0}".format(
1536 "\nError: {0}".format(err) if verbose else "")
1522 installed = not isSudo and pipInstall( 1537 installed = not isSudo and pipInstall(
1523 "PyQt6-QScintilla>={0}".format( 1538 "PyQt6-QScintilla>={0}".format(
1524 versionToStr(requiredVersions["pyqt6-qscintilla"])), 1539 versionToStr(requiredVersions["pyqt6-qscintilla"])),
1525 "'PyQt6-QScintilla' could not be detected.\nError: {0}".format(msg) 1540 msg
1526 ) 1541 )
1527 if installed: 1542 if installed:
1528 # try to import it again 1543 # try to import it again
1529 try: 1544 try:
1530 from PyQt6 import Qsci # __IGNORE_WARNING__ 1545 from PyQt6 import Qsci # __IGNORE_WARNING__
1569 for impModule in impModulesList: 1584 for impModule in impModulesList:
1570 name = impModule.split(".")[1] 1585 name = impModule.split(".")[1]
1571 try: 1586 try:
1572 __import__(impModule) 1587 __import__(impModule)
1573 print("Found", name) 1588 print("Found", name)
1574 except ImportError as msg: 1589 except ImportError as err:
1575 print('Sorry, please install {0}.'.format(name)) 1590 print('Sorry, please install {0}.'.format(name))
1576 print('Error: {0}'.format(msg)) 1591 if verbose:
1592 print('Error: {0}'.format(err))
1577 modulesOK = False 1593 modulesOK = False
1578 if not modulesOK: 1594 if not modulesOK:
1579 exit(1) 1595 exit(1)
1580 1596
1581 # check optional modules 1597 # check optional modules
1582 for optPackage in optionalModulesList: 1598 for optPackage in optionalModulesList:
1583 try: 1599 try:
1584 __import__(optionalModulesList[optPackage][0]) 1600 __import__(optionalModulesList[optPackage][0])
1585 print("Found", optPackage) 1601 print("Found", optPackage)
1586 except ImportError as msg: 1602 except ImportError as err:
1587 if isSudo: 1603 if isSudo:
1588 print("Optional '{0}' could not be detected." 1604 print("Optional '{0}' could not be detected."
1589 .format(optPackage)) 1605 .format(optPackage))
1590 else: 1606 else:
1607 msg = "Optional '{0}' could not be detected.{1}".format(
1608 optPackage,
1609 "\nError: {0}".format(err) if verbose else ""
1610 )
1591 pipInstall( 1611 pipInstall(
1592 optPackage + optionalModulesList[optPackage][1], 1612 optPackage + optionalModulesList[optPackage][1],
1593 "Optional '{0}' could not be detected.\n" 1613 msg
1594 "Error: {1}".format(optPackage, msg)
1595 ) 1614 )
1596 1615
1597 # determine the platform dependent black list 1616 # determine the platform dependent black list
1598 if sys.platform.startswith(("win", "cygwin")): 1617 if sys.platform.startswith(("win", "cygwin")):
1599 PlatformBlackLists = PlatformsBlackLists["windows"] 1618 PlatformBlackLists = PlatformsBlackLists["windows"]
1874 global sourceDir, eric7SourceDir, configName 1893 global sourceDir, eric7SourceDir, configName
1875 global macAppBundlePath, macAppBundleName, macPythonExe 1894 global macAppBundlePath, macAppBundleName, macPythonExe
1876 global installApis, doCleanDesktopLinks, yes2All 1895 global installApis, doCleanDesktopLinks, yes2All
1877 global createInstallInfoFile, installCwd 1896 global createInstallInfoFile, installCwd
1878 global ignorePyqt6Tools 1897 global ignorePyqt6Tools
1898 global verbose
1879 1899
1880 if sys.version_info < (3, 6, 0) or sys.version_info > (3, 99, 99): 1900 if sys.version_info < (3, 6, 0) or sys.version_info > (3, 99, 99):
1881 print('Sorry, eric requires at least Python 3.6 for running.') 1901 print('Sorry, eric requires at least Python 3.6 for running.')
1882 exit(5) 1902 exit(5)
1883 1903
1891 initGlobals() 1911 initGlobals()
1892 1912
1893 try: 1913 try:
1894 if sys.platform.startswith(("win", "cygwin")): 1914 if sys.platform.startswith(("win", "cygwin")):
1895 optlist, args = getopt.getopt( 1915 optlist, args = getopt.getopt(
1896 argv[1:], "chxza:b:d:f:", 1916 argv[1:], "chvxza:b:d:f:",
1897 ["help", "no-apis", "no-info", "no-tools", "yes"]) 1917 ["help", "no-apis", "no-info", "no-tools", "verbose", "yes"])
1898 elif sys.platform == "darwin": 1918 elif sys.platform == "darwin":
1899 optlist, args = getopt.getopt( 1919 optlist, args = getopt.getopt(
1900 argv[1:], "chxza:b:d:f:i:m:n:p:", 1920 argv[1:], "chvxza:b:d:f:i:m:n:p:",
1901 ["help", "no-apis", "no-info", "no-tools", "yes"]) 1921 ["help", "no-apis", "no-info", "no-tools", "verbose", "yes"])
1902 else: 1922 else:
1903 optlist, args = getopt.getopt( 1923 optlist, args = getopt.getopt(
1904 argv[1:], "chxza:b:d:f:i:", 1924 argv[1:], "chvxza:b:d:f:i:",
1905 ["help", "no-apis", "no-info", "no-tools", "yes"]) 1925 ["help", "no-apis", "no-info", "no-tools", "verbose", "yes"])
1906 except getopt.GetoptError as err: 1926 except getopt.GetoptError as err:
1907 print(err) 1927 print(err)
1908 usage() 1928 usage()
1909 1929
1910 global platBinDir 1930 global platBinDir
1953 yes2All = True 1973 yes2All = True
1954 elif opt == "--no-tools": 1974 elif opt == "--no-tools":
1955 ignorePyqt6Tools = True 1975 ignorePyqt6Tools = True
1956 elif opt == "--no-info": 1976 elif opt == "--no-info":
1957 createInstallInfoFile = False 1977 createInstallInfoFile = False
1978 elif opt in ["-v", "--verbose"]:
1979 verbose = True
1958 1980
1959 infoName = "" 1981 infoName = ""
1960 installFromSource = not os.path.isdir(sourceDir) 1982 installFromSource = not os.path.isdir(sourceDir)
1961 1983
1962 # check dependencies 1984 # check dependencies

eric ide

mercurial