scripts/install.py

branch
eric7
changeset 10042
ca636e8d80fd
parent 9986
2c571c1c7b0d
child 10046
35b27af462ef
equal deleted inserted replaced
10041:67c8efa6d098 10042:ca636e8d80fd
220 # it's the wheel 220 # it's the wheel
221 qtDataDir = os.path.join(pyqtDataDir, "Qt6") 221 qtDataDir = os.path.join(pyqtDataDir, "Qt6")
222 else: 222 else:
223 # determine dynamically 223 # determine dynamically
224 try: 224 try:
225 from PyQt6.QtCore import QLibraryInfo 225 from PyQt6.QtCore import QLibraryInfo # noqa: I101, I102
226 226
227 qtDataDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.DataPath) 227 qtDataDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.DataPath)
228 except ImportError: 228 except ImportError:
229 qtDataDir = None 229 qtDataDir = None
230 apisDir = os.path.join(qtDataDir, "qsci", "api") if qtDataDir else None 230 apisDir = os.path.join(qtDataDir, "qsci", "api") if qtDataDir else None
272 @param src source file name (string) 272 @param src source file name (string)
273 @param dst destination file name (string) 273 @param dst destination file name (string)
274 """ 274 """
275 if os.path.exists(os.path.join("eric", "src", "eric7", "UI", "Info.py")): 275 if os.path.exists(os.path.join("eric", "src", "eric7", "UI", "Info.py")):
276 # Installing from installer archive 276 # Installing from installer archive
277 from eric.src.eric7.UI.Info import Version 277 from eric.src.eric7.UI.Info import Version # noqa: I101, I102
278 elif os.path.exists(os.path.join("src", "eric7", "UI", "Info.py")): 278 elif os.path.exists(os.path.join("src", "eric7", "UI", "Info.py")):
279 # Installing from source tree 279 # Installing from source tree
280 from src.eric7.UI.Info import Version 280 from src.eric7.UI.Info import Version # noqa: I101, I102
281 else: 281 else:
282 Version = "Unknown" 282 Version = "Unknown"
283 283
284 with open(src, "r", encoding="utf-8") as f: 284 with open(src, "r", encoding="utf-8") as f:
285 text = f.read() 285 text = f.read()
484 Uninstall the old eric files. 484 Uninstall the old eric files.
485 """ 485 """
486 global platBinDir 486 global platBinDir
487 487
488 try: 488 try:
489 from eric7.Globals import getConfig 489 from eric7.Globals import getConfig # noqa: I101
490 except ImportError: 490 except ImportError:
491 # eric wasn't installed previously 491 # eric wasn't installed previously
492 return 492 return
493 except SyntaxError: 493 except SyntaxError:
494 # an incomplete or old config file was found 494 # an incomplete or old config file was found
1185 wname = os.path.join(directories["exe"], "eric7_ide") 1185 wname = os.path.join(directories["exe"], "eric7_ide")
1186 1186
1187 # determine entry for DYLD_FRAMEWORK_PATH 1187 # determine entry for DYLD_FRAMEWORK_PATH
1188 dyldLine = "" 1188 dyldLine = ""
1189 try: 1189 try:
1190 from PyQt6.QtCore import QLibraryInfo 1190 from PyQt6.QtCore import QLibraryInfo # noqa: I101, I102
1191 1191
1192 qtLibraryDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.LibrariesPath) 1192 qtLibraryDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.LibrariesPath)
1193 except ImportError: 1193 except ImportError:
1194 qtLibraryDir = "" 1194 qtLibraryDir = ""
1195 if qtLibraryDir: 1195 if qtLibraryDir:
1223 os.path.join(directories["icns"], "eric.icns"), 1223 os.path.join(directories["icns"], "eric.icns"),
1224 ) 1224 )
1225 1225
1226 if os.path.exists(os.path.join("eric", "eric7", "UI", "Info.py")): 1226 if os.path.exists(os.path.join("eric", "eric7", "UI", "Info.py")):
1227 # Installing from archive 1227 # Installing from archive
1228 from eric.eric7.UI.Info import CopyrightShort, Version 1228 from eric.eric7.UI.Info import CopyrightShort, Version # noqa: I101, I102
1229 elif os.path.exists(os.path.join("eric7", "UI", "Info.py")): 1229 elif os.path.exists(os.path.join("eric7", "UI", "Info.py")):
1230 # Installing from source tree 1230 # Installing from source tree
1231 from eric7.UI.Info import CopyrightShort, Version 1231 from eric7.UI.Info import CopyrightShort, Version # noqa: I101
1232 else: 1232 else:
1233 Version = "Unknown" 1233 Version = "Unknown"
1234 CopyrightShort = "(c) 2002 - 2023 Detlev Offenbach" 1234 CopyrightShort = "(c) 2002 - 2023 Detlev Offenbach"
1235 1235
1236 copyToFile( 1236 copyToFile(
1593 exit(5) 1593 exit(5)
1594 1594
1595 print("PyQt & Qt") 1595 print("PyQt & Qt")
1596 print("---------") 1596 print("---------")
1597 try: 1597 try:
1598 from PyQt6.QtCore import qVersion 1598 from PyQt6.QtCore import qVersion # noqa: I101, I102
1599 except ImportError as err: 1599 except ImportError as err:
1600 msg = "'PyQt6' could not be detected.{0}".format( 1600 msg = "'PyQt6' could not be detected.{0}".format(
1601 "\nError: {0}".format(err) if verbose else "" 1601 "\nError: {0}".format(err) if verbose else ""
1602 ) 1602 )
1603 installed = not isSudo and pipInstall( 1603 installed = not isSudo and pipInstall(
1604 "PyQt6>={0}".format(versionToStr(requiredVersions["pyqt6"])), msg 1604 "PyQt6>={0}".format(versionToStr(requiredVersions["pyqt6"])), msg
1605 ) 1605 )
1606 if installed: 1606 if installed:
1607 # try to import it again 1607 # try to import it again
1608 try: 1608 try:
1609 from PyQt6.QtCore import qVersion 1609 from PyQt6.QtCore import qVersion # noqa: I101, I102
1610 except ImportError as msg: 1610 except ImportError as msg:
1611 print("Sorry, please install PyQt6.") 1611 print("Sorry, please install PyQt6.")
1612 print("Error: {0}".format(msg)) 1612 print("Error: {0}".format(msg))
1613 exit(1) 1613 exit(1)
1614 else: 1614 else:
1821 1821
1822 # check version of sip 1822 # check version of sip
1823 # ==================== 1823 # ====================
1824 with contextlib.suppress(ImportError, AttributeError): 1824 with contextlib.suppress(ImportError, AttributeError):
1825 try: 1825 try:
1826 from PyQt6 import sip 1826 from PyQt6 import sip # noqa: I101, I102
1827 except ImportError: 1827 except ImportError:
1828 import sip 1828 import sip # noqa: I101, I102
1829 print("sip:", sip.SIP_VERSION_STR.strip()) 1829 print("sip:", sip.SIP_VERSION_STR.strip())
1830 # always assume, that snapshots or dev versions are new enough 1830 # always assume, that snapshots or dev versions are new enough
1831 if "snapshot" not in sip.SIP_VERSION_STR and "dev" not in sip.SIP_VERSION_STR: 1831 if "snapshot" not in sip.SIP_VERSION_STR and "dev" not in sip.SIP_VERSION_STR:
1832 if sip.SIP_VERSION < requiredVersions["sip"]: 1832 if sip.SIP_VERSION < requiredVersions["sip"]:
1833 print( 1833 print(
1848 print("Please install another version.") 1848 print("Please install another version.")
1849 exit(3) 1849 exit(3)
1850 1850
1851 # check version of PyQt6 1851 # check version of PyQt6
1852 # ====================== 1852 # ======================
1853 from PyQt6.QtCore import PYQT_VERSION, PYQT_VERSION_STR 1853 from PyQt6.QtCore import PYQT_VERSION, PYQT_VERSION_STR # noqa: I101, I102
1854 1854
1855 print("PyQt6:", PYQT_VERSION_STR.strip()) 1855 print("PyQt6:", PYQT_VERSION_STR.strip())
1856 # always assume, that snapshots or dev versions are new enough 1856 # always assume, that snapshots or dev versions are new enough
1857 if "snapshot" not in PYQT_VERSION_STR and "dev" not in PYQT_VERSION_STR: 1857 if "snapshot" not in PYQT_VERSION_STR and "dev" not in PYQT_VERSION_STR:
1858 if PYQT_VERSION < requiredVersions["pyqt6"]: 1858 if PYQT_VERSION < requiredVersions["pyqt6"]:
1874 print("Please install another version.") 1874 print("Please install another version.")
1875 exit(4) 1875 exit(4)
1876 1876
1877 # check version of QScintilla 1877 # check version of QScintilla
1878 # =========================== 1878 # ===========================
1879 from PyQt6.Qsci import QSCINTILLA_VERSION, QSCINTILLA_VERSION_STR 1879 from PyQt6.Qsci import QSCINTILLA_VERSION, QSCINTILLA_VERSION_STR # noqa: I101, I102
1880 1880
1881 print("PyQt6-QScintilla:", QSCINTILLA_VERSION_STR.strip()) 1881 print("PyQt6-QScintilla:", QSCINTILLA_VERSION_STR.strip())
1882 # always assume, that snapshots or dev versions are new enough 1882 # always assume, that snapshots or dev versions are new enough
1883 if "snapshot" not in QSCINTILLA_VERSION_STR and "dev" not in QSCINTILLA_VERSION_STR: 1883 if "snapshot" not in QSCINTILLA_VERSION_STR and "dev" not in QSCINTILLA_VERSION_STR:
1884 if QSCINTILLA_VERSION < requiredVersions["pyqt6-qscintilla"]: 1884 if QSCINTILLA_VERSION < requiredVersions["pyqt6-qscintilla"]:
1902 # print version info for additional modules 1902 # print version info for additional modules
1903 with contextlib.suppress(NameError, AttributeError): 1903 with contextlib.suppress(NameError, AttributeError):
1904 print("PyQt6-Charts:", QtCharts.PYQT_CHART_VERSION_STR) 1904 print("PyQt6-Charts:", QtCharts.PYQT_CHART_VERSION_STR)
1905 1905
1906 with contextlib.suppress(ImportError, AttributeError): 1906 with contextlib.suppress(ImportError, AttributeError):
1907 from PyQt6 import QtWebEngineCore 1907 from PyQt6 import QtWebEngineCore # noqa: I101, I102
1908 1908
1909 print("PyQt6-WebEngine:", QtWebEngineCore.PYQT_WEBENGINE_VERSION_STR) 1909 print("PyQt6-WebEngine:", QtWebEngineCore.PYQT_WEBENGINE_VERSION_STR)
1910 1910
1911 print() 1911 print()
1912 print("All dependencies ok.") 1912 print("All dependencies ok.")
1933 @type str 1933 @type str
1934 @param mapFunc function to change directory and/or name of the resulting Python file 1934 @param mapFunc function to change directory and/or name of the resulting Python file
1935 (defaults to None) 1935 (defaults to None)
1936 @type func (optional) 1936 @type func (optional)
1937 """ 1937 """
1938 from PyQt6.uic import compileUi 1938 from PyQt6.uic import compileUi # noqa: I102
1939 1939
1940 py_dir, py_file = os.path.split(ui_path[:-3] + ".py") 1940 py_dir, py_file = os.path.split(ui_path[:-3] + ".py")
1941 1941
1942 # Allow the caller to change the name of the .py file or generate 1942 # Allow the caller to change the name of the .py file or generate
1943 # it in a different directory. 1943 # it in a different directory.
2050 @type str 2050 @type str
2051 @return value of requested registry variable 2051 @return value of requested registry variable
2052 @rtype any 2052 @rtype any
2053 """ 2053 """
2054 try: 2054 try:
2055 import winreg # __IGNORE_WARNING_I103__ 2055 import winreg # noqa: I101, I103
2056 except ImportError: 2056 except ImportError:
2057 return None 2057 return None
2058 2058
2059 try: 2059 try:
2060 registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, winreg.KEY_READ) 2060 registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, winreg.KEY_READ)
2074 @param targetPath path the shortcut shall point to 2074 @param targetPath path the shortcut shall point to
2075 @type str 2075 @type str
2076 @param iconPath path of the icon file 2076 @param iconPath path of the icon file
2077 @type str 2077 @type str
2078 """ 2078 """
2079 from pywintypes import com_error 2079 from pywintypes import com_error # noqa: I102
2080 from win32com.client import Dispatch 2080 from win32com.client import Dispatch # noqa: I102
2081 2081
2082 with contextlib.suppress(com_error): 2082 with contextlib.suppress(com_error):
2083 shell = Dispatch("WScript.Shell") 2083 shell = Dispatch("WScript.Shell")
2084 shortcut = shell.CreateShortCut(linkPath) 2084 shortcut = shell.CreateShortCut(linkPath)
2085 shortcut.Targetpath = targetPath 2085 shortcut.Targetpath = targetPath
2417 """ eric-bugs@eric-ide.python-projects.org.\n""" 2417 """ eric-bugs@eric-ide.python-projects.org.\n"""
2418 ) 2418 )
2419 raise 2419 raise
2420 2420
2421 # 2421 #
2422 # eflag: noqa = M801, I101, I102 2422 # eflag: noqa = M801

eric ide

mercurial