scripts/install.py

changeset 8243
cc717c2ae956
parent 8240
93b8a353c4bf
child 8254
259484b0fc75
equal deleted inserted replaced
8242:aa713ac50c0d 8243:cc717c2ae956
98 global currDir 98 global currDir
99 99
100 print() 100 print()
101 101
102 if sys.platform.startswith(("win", "cygwin")): 102 if sys.platform.startswith(("win", "cygwin")):
103 try: 103 with contextlib.suppress():
104 input("Press enter to continue...") # secok 104 input("Press enter to continue...") # secok
105 except (EOFError, SyntaxError):
106 pass
107 105
108 os.chdir(currDir) 106 os.chdir(currDir)
109 107
110 sys.exit(rcode) 108 sys.exit(rcode)
111 109
556 os.path.join(getConfig('ericTranslationsDir'), 'eric6_*.qm')): 554 os.path.join(getConfig('ericTranslationsDir'), 'eric6_*.qm')):
557 if os.path.exists(name): 555 if os.path.exists(name):
558 os.remove(name) 556 os.remove(name)
559 557
560 # Cleanup API files 558 # Cleanup API files
561 try: 559 with contextlib.suppress(AttributeError):
562 apidir = getConfig('apidir') 560 apidir = getConfig('apidir')
563 for progLanguage in progLanguages: 561 for progLanguage in progLanguages:
564 for name in getConfig('apis'): 562 for name in getConfig('apis'):
565 apiname = os.path.join(apidir, progLanguage.lower(), name) 563 apiname = os.path.join(apidir, progLanguage.lower(), name)
566 if os.path.exists(apiname): 564 if os.path.exists(apiname):
567 os.remove(apiname) 565 os.remove(apiname)
568 for apiname in glob.glob( 566 for apiname in glob.glob(
569 os.path.join(apidir, progLanguage.lower(), "*.bas")): 567 os.path.join(apidir, progLanguage.lower(), "*.bas")):
570 if os.path.basename(apiname) != "eric6.bas": 568 if os.path.basename(apiname) != "eric6.bas":
571 os.remove(apiname) 569 os.remove(apiname)
572 except AttributeError:
573 pass
574 570
575 if sys.platform == "darwin": 571 if sys.platform == "darwin":
576 # delete the Mac app bundle 572 # delete the Mac app bundle
577 cleanUpMacAppBundle() 573 cleanUpMacAppBundle()
578 except OSError as msg: 574 except OSError as msg:
1447 1443
1448 try: 1444 try:
1449 from PyQt5.QtCore import qVersion 1445 from PyQt5.QtCore import qVersion
1450 except ImportError as msg: 1446 except ImportError as msg:
1451 installed = not isSudo and pipInstall( 1447 installed = not isSudo and pipInstall(
1452 "PyQt5>=5.12.1,<5.15.2", 1448 "PyQt5>=5.12.1",
1453 "'PyQt5' could not be detected.\nError: {0}".format(msg) 1449 "'PyQt5' could not be detected.\nError: {0}".format(msg)
1454 ) 1450 )
1455 if installed: 1451 if installed:
1456 # try to import it again 1452 # try to import it again
1457 try: 1453 try:
1483 # PyQt 5.12 separated QtWebEngine into a separate wheel 1479 # PyQt 5.12 separated QtWebEngine into a separate wheel
1484 if isSudo: 1480 if isSudo:
1485 print("Optional 'PyQtWebEngine' could not be detected.") 1481 print("Optional 'PyQtWebEngine' could not be detected.")
1486 else: 1482 else:
1487 pipInstall( 1483 pipInstall(
1488 "PyQtWebEngine>=5.12.1,<5.15.2", 1484 "PyQtWebEngine>=5.12.1",
1489 "Optional 'PyQtWebEngine' could not be detected.\n" 1485 "Optional 'PyQtWebEngine' could not be detected.\n"
1490 "Error: {0}".format(msg) 1486 "Error: {0}".format(msg)
1491 ) 1487 )
1492 1488
1493 try: 1489 try:
1495 except ImportError as msg: 1491 except ImportError as msg:
1496 if isSudo: 1492 if isSudo:
1497 print("Optional 'PyQtChart' could not be detected.") 1493 print("Optional 'PyQtChart' could not be detected.")
1498 else: 1494 else:
1499 pipInstall( 1495 pipInstall(
1500 "PyQtChart>=5.12.1,<5.15.2", 1496 "PyQtChart>=5.12.1",
1501 "Optional 'PyQtChart' could not be detected.\n" 1497 "Optional 'PyQtChart' could not be detected.\n"
1502 "Error: {0}".format(msg) 1498 "Error: {0}".format(msg)
1503 ) 1499 )
1504 1500
1505 try: 1501 try:
1563 altModulesOK = True 1559 altModulesOK = True
1564 for altModules, forcedOk in altModulesList: 1560 for altModules, forcedOk in altModulesList:
1565 modulesOK = False 1561 modulesOK = False
1566 for altModule in altModules: 1562 for altModule in altModules:
1567 name = altModule.split(".")[1] 1563 name = altModule.split(".")[1]
1568 try: 1564 with contextlib.suppress(ImportError):
1569 __import__(altModule) 1565 __import__(altModule)
1570 print("Found", name) 1566 print("Found", name)
1571 modulesOK = True 1567 modulesOK = True
1572 break 1568 break
1573 except ImportError:
1574 pass
1575 if not modulesOK and not forcedOk: 1569 if not modulesOK and not forcedOk:
1576 altModulesOK = False 1570 altModulesOK = False
1577 print('Sorry, please install {0}.' 1571 print('Sorry, please install {0}.'
1578 .format(" or ".join(altModules))) 1572 .format(" or ".join(altModules)))
1579 if not altModulesOK: 1573 if not altModulesOK:
1609 if qtMajor == 5 and qtMinor < 12: 1603 if qtMajor == 5 and qtMinor < 12:
1610 print('Sorry, you must have Qt version 5.12.0 or better.') 1604 print('Sorry, you must have Qt version 5.12.0 or better.')
1611 exit(2) 1605 exit(2)
1612 1606
1613 # check version of sip 1607 # check version of sip
1614 try: 1608 with contextlib.suppress(ImportError, AttributeError):
1615 try: 1609 try:
1616 from PyQt5 import sip 1610 from PyQt5 import sip
1617 except ImportError: 1611 except ImportError:
1618 import sip 1612 import sip
1619 sipVersion = sip.SIP_VERSION_STR 1613 sipVersion = sip.SIP_VERSION_STR
1625 (major, minor, pat) = sipVersion.split('.') 1619 (major, minor, pat) = sipVersion.split('.')
1626 major = int(major) 1620 major = int(major)
1627 minor = int(minor) 1621 minor = int(minor)
1628 pat = int(pat) 1622 pat = int(pat)
1629 if ( 1623 if (
1630 major < 4 or 1624 major < 5 or
1631 (major == 4 and minor < 14) or 1625 (major == 5 and minor < 0) or
1632 (major == 4 and minor == 14 and pat < 2) 1626 (major == 5 and minor == 0 and pat < 0)
1633 ): 1627 ):
1634 print('Sorry, you must have sip 4.14.2 or higher or' 1628 print('Sorry, you must have sip 5.0.0 or higher or'
1635 ' a recent snapshot release.') 1629 ' a recent snapshot release.')
1636 exit(3) 1630 exit(3)
1637 # check for blacklisted versions 1631 # check for blacklisted versions
1638 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]: 1632 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]:
1639 if vers == sipVersion: 1633 if vers == sipVersion:
1640 print( 1634 print(
1641 'Sorry, sip version {0} is not compatible with eric.' 1635 'Sorry, sip version {0} is not compatible with eric.'
1642 .format(vers)) 1636 .format(vers))
1643 print('Please install another version.') 1637 print('Please install another version.')
1644 exit(3) 1638 exit(3)
1645 except (ImportError, AttributeError):
1646 pass
1647 1639
1648 # check version of PyQt 1640 # check version of PyQt
1649 from PyQt5.QtCore import PYQT_VERSION_STR 1641 from PyQt5.QtCore import PYQT_VERSION_STR
1650 pyqtVersion = PYQT_VERSION_STR 1642 pyqtVersion = PYQT_VERSION_STR
1651 print("PyQt Version:", pyqtVersion.strip()) 1643 print("PyQt Version:", pyqtVersion.strip())
1700 ' eric.'.format(vers)) 1692 ' eric.'.format(vers))
1701 print('Please install another version.') 1693 print('Please install another version.')
1702 exit(5) 1694 exit(5)
1703 1695
1704 # print version info for additional modules 1696 # print version info for additional modules
1705 try: 1697 with contextlib.suppress(NameError, AttributeError):
1706 print("PyQtChart:", QtChart.PYQT_CHART_VERSION_STR) 1698 print("PyQtChart:", QtChart.PYQT_CHART_VERSION_STR)
1707 except (NameError, AttributeError): 1699
1708 pass 1700 with contextlib.suppress(ImportError, AttributeError):
1709 try:
1710 from PyQt5 import QtWebEngine 1701 from PyQt5 import QtWebEngine
1711 print("PyQtWebEngine.", QtWebEngine.PYQT_WEBENGINE_VERSION_STR) 1702 print("PyQtWebEngine.", QtWebEngine.PYQT_WEBENGINE_VERSION_STR)
1712 except (ImportError, AttributeError):
1713 pass
1714 1703
1715 print("All dependencies ok.") 1704 print("All dependencies ok.")
1716 print() 1705 print()
1717 1706
1718 1707
1805 @type str 1794 @type str
1806 """ 1795 """
1807 from win32com.client import Dispatch 1796 from win32com.client import Dispatch
1808 from pywintypes import com_error 1797 from pywintypes import com_error
1809 1798
1810 try: 1799 with contextlib.suppress(com_error):
1811 shell = Dispatch('WScript.Shell') 1800 shell = Dispatch('WScript.Shell')
1812 shortcut = shell.CreateShortCut(linkPath) 1801 shortcut = shell.CreateShortCut(linkPath)
1813 shortcut.Targetpath = targetPath 1802 shortcut.Targetpath = targetPath
1814 shortcut.WorkingDirectory = os.path.dirname(targetPath) 1803 shortcut.WorkingDirectory = os.path.dirname(targetPath)
1815 shortcut.IconLocation = iconPath 1804 shortcut.IconLocation = iconPath
1816 shortcut.save() 1805 shortcut.save()
1817 except com_error:
1818 # maybe restrictions prohibited link creation
1819 pass
1820 1806
1821 1807
1822 def windowsDesktopNames(): 1808 def windowsDesktopNames():
1823 """ 1809 """
1824 Function to generate the link names for the Windows Desktop. 1810 Function to generate the link names for the Windows Desktop.
1988 1974
1989 if len(cfg) == 0: 1975 if len(cfg) == 0:
1990 createInstallConfig() 1976 createInstallConfig()
1991 1977
1992 # get rid of development config file, if it exists 1978 # get rid of development config file, if it exists
1993 try: 1979 with contextlib.suppress(OSError):
1994 if installFromSource: 1980 if installFromSource:
1995 os.rename(configName, configName + ".orig") 1981 os.rename(configName, configName + ".orig")
1996 configNameC = configName + 'c' 1982 configNameC = configName + 'c'
1997 if os.path.exists(configNameC): 1983 if os.path.exists(configNameC):
1998 os.remove(configNameC) 1984 os.remove(configNameC)
1999 os.remove(configName) 1985 os.remove(configName)
2000 except OSError:
2001 pass
2002 1986
2003 # cleanup old installation 1987 # cleanup old installation
2004 print("Cleaning up old installation ...") 1988 print("Cleaning up old installation ...")
2005 try: 1989 try:
2006 if doCleanup: 1990 if doCleanup:

eric ide

mercurial