scripts/install.py

branch
eric7-maintenance
changeset 11155
e1843b6efa73
parent 11118
967a88a16a21
parent 11148
15e30f0c76a8
equal deleted inserted replaced
11126:32d0ec15eba0 11155:e1843b6efa73
158 # it's the wheel 158 # it's the wheel
159 qtDataDir = os.path.join(pyqtDataDir, "Qt6") 159 qtDataDir = os.path.join(pyqtDataDir, "Qt6")
160 else: 160 else:
161 # determine dynamically 161 # determine dynamically
162 try: 162 try:
163 from PyQt6.QtCore import QLibraryInfo # noqa: I101, I102 163 from PyQt6.QtCore import QLibraryInfo # noqa: I-101, I-102
164 164
165 qtDataDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.DataPath) 165 qtDataDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.DataPath)
166 except ImportError: 166 except ImportError:
167 qtDataDir = None 167 qtDataDir = None
168 apisDir = os.path.join(qtDataDir, "qsci", "api") if qtDataDir else None 168 apisDir = os.path.join(qtDataDir, "qsci", "api") if qtDataDir else None
222 @param dst destination file name 222 @param dst destination file name
223 @type str 223 @type str
224 """ 224 """
225 if os.path.exists(os.path.join("eric", "src", "eric7", "__version__.py")): 225 if os.path.exists(os.path.join("eric", "src", "eric7", "__version__.py")):
226 # Installing from installer archive 226 # Installing from installer archive
227 from eric.src.eric7.__version__ import Version # noqa: I101, I102 227 from eric.src.eric7.__version__ import Version # noqa: I-101, I-102
228 elif os.path.exists(os.path.join("src", "eric7", "__version__.py")): 228 elif os.path.exists(os.path.join("src", "eric7", "__version__.py")):
229 # Installing from source tree 229 # Installing from source tree
230 from src.eric7.__version__ import Version # noqa: I101, I102 230 from src.eric7.__version__ import Version # noqa: I-101, I-102
231 else: 231 else:
232 Version = "Unknown" 232 Version = "Unknown"
233 233
234 with open(src, "r", encoding="utf-8") as f: 234 with open(src, "r", encoding="utf-8") as f:
235 text = f.read() 235 text = f.read()
448 Uninstall the old eric files. 448 Uninstall the old eric files.
449 """ 449 """
450 global platBinDir 450 global platBinDir
451 451
452 try: 452 try:
453 from eric7.Globals import getConfig # noqa: I101 453 from eric7.Globals import getConfig # noqa: I-101
454 except ImportError: 454 except ImportError:
455 # eric wasn't installed previously 455 # eric wasn't installed previously
456 return 456 return
457 except SyntaxError: 457 except SyntaxError:
458 # an incomplete or old config file was found 458 # an incomplete or old config file was found
1192 wname = os.path.join(directories["exe"], "eric7_ide") 1192 wname = os.path.join(directories["exe"], "eric7_ide")
1193 1193
1194 # determine entry for DYLD_FRAMEWORK_PATH 1194 # determine entry for DYLD_FRAMEWORK_PATH
1195 dyldLine = "" 1195 dyldLine = ""
1196 try: 1196 try:
1197 from PyQt6.QtCore import QLibraryInfo # noqa: I101, I102 1197 from PyQt6.QtCore import QLibraryInfo # noqa: I-101, I-102
1198 1198
1199 qtLibraryDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.LibrariesPath) 1199 qtLibraryDir = QLibraryInfo.path(QLibraryInfo.LibraryPath.LibrariesPath)
1200 except ImportError: 1200 except ImportError:
1201 qtLibraryDir = "" 1201 qtLibraryDir = ""
1202 if qtLibraryDir: 1202 if qtLibraryDir:
1230 os.path.join(directories["icns"], "eric.icns"), 1230 os.path.join(directories["icns"], "eric.icns"),
1231 ) 1231 )
1232 1232
1233 if os.path.exists(os.path.join("eric", "eric7", "__version__.py")): 1233 if os.path.exists(os.path.join("eric", "eric7", "__version__.py")):
1234 # Installing from archive 1234 # Installing from archive
1235 from eric.eric7.__version__ import CopyrightShort, Version # noqa: I101, I102 1235 from eric.eric7.__version__ import CopyrightShort, Version # noqa: I-101, I-102
1236 elif os.path.exists(os.path.join("eric7", "__version__.py")): 1236 elif os.path.exists(os.path.join("eric7", "__version__.py")):
1237 # Installing from source tree 1237 # Installing from source tree
1238 from eric7.__version__ import CopyrightShort, Version # noqa: I101 1238 from eric7.__version__ import CopyrightShort, Version # noqa: I-101
1239 else: 1239 else:
1240 Version = "Unknown" 1240 Version = "Unknown"
1241 CopyrightShort = "(c) 2002 - 2025 Detlev Offenbach" 1241 CopyrightShort = "(c) 2002 - 2025 Detlev Offenbach"
1242 1242
1243 copyToFile( 1243 copyToFile(
1622 exit(5) 1622 exit(5)
1623 1623
1624 print("PyQt & Qt") 1624 print("PyQt & Qt")
1625 print("---------") 1625 print("---------")
1626 try: 1626 try:
1627 from PyQt6.QtCore import qVersion # noqa: I101, I102 1627 from PyQt6.QtCore import qVersion # noqa: I-101, I-102
1628 except ImportError as err: 1628 except ImportError as err:
1629 msg = "'PyQt6' could not be detected.{0}".format( 1629 msg = "'PyQt6' could not be detected.{0}".format(
1630 "\nError: {0}".format(err) if verbose else "" 1630 "\nError: {0}".format(err) if verbose else ""
1631 ) 1631 )
1632 installed = not isSudo and pipInstall( 1632 installed = not isSudo and pipInstall(
1633 "PyQt6>={0}".format(versionToStr(requiredVersions["pyqt6"])), msg 1633 "PyQt6>={0}".format(versionToStr(requiredVersions["pyqt6"])), msg
1634 ) 1634 )
1635 if installed: 1635 if installed:
1636 # try to import it again 1636 # try to import it again
1637 try: 1637 try:
1638 from PyQt6.QtCore import qVersion # noqa: I101, I102 1638 from PyQt6.QtCore import qVersion # noqa: I-101, I-102
1639 except ImportError as msg: 1639 except ImportError as msg:
1640 print("Sorry, please install PyQt6.") 1640 print("Sorry, please install PyQt6.")
1641 print("Error: {0}".format(msg)) 1641 print("Error: {0}".format(msg))
1642 exit(1) 1642 exit(1)
1643 else: 1643 else:
1845 1845
1846 # check version of sip 1846 # check version of sip
1847 # ==================== 1847 # ====================
1848 with contextlib.suppress(ImportError, AttributeError): 1848 with contextlib.suppress(ImportError, AttributeError):
1849 try: 1849 try:
1850 from PyQt6 import sip # noqa: I101, I102 1850 from PyQt6 import sip # noqa: I-101, I-102
1851 except ImportError: 1851 except ImportError:
1852 import sip # noqa: I101, I102 1852 import sip # noqa: I-101, I-102
1853 print("sip:", sip.SIP_VERSION_STR.strip()) 1853 print("sip:", sip.SIP_VERSION_STR.strip())
1854 # always assume, that snapshots or dev versions are new enough 1854 # always assume, that snapshots or dev versions are new enough
1855 if "snapshot" not in sip.SIP_VERSION_STR and "dev" not in sip.SIP_VERSION_STR: 1855 if "snapshot" not in sip.SIP_VERSION_STR and "dev" not in sip.SIP_VERSION_STR:
1856 if sip.SIP_VERSION < requiredVersions["sip"]: 1856 if sip.SIP_VERSION < requiredVersions["sip"]:
1857 print( 1857 print(
1872 print("Please install another version.") 1872 print("Please install another version.")
1873 exit(3) 1873 exit(3)
1874 1874
1875 # check version of PyQt6 1875 # check version of PyQt6
1876 # ====================== 1876 # ======================
1877 from PyQt6.QtCore import PYQT_VERSION, PYQT_VERSION_STR # noqa: I101, I102 1877 from PyQt6.QtCore import PYQT_VERSION, PYQT_VERSION_STR # noqa: I-101, I-102
1878 1878
1879 print("PyQt6:", PYQT_VERSION_STR.strip()) 1879 print("PyQt6:", PYQT_VERSION_STR.strip())
1880 # always assume, that snapshots or dev versions are new enough 1880 # always assume, that snapshots or dev versions are new enough
1881 if "snapshot" not in PYQT_VERSION_STR and "dev" not in PYQT_VERSION_STR: 1881 if "snapshot" not in PYQT_VERSION_STR and "dev" not in PYQT_VERSION_STR:
1882 if PYQT_VERSION < requiredVersions["pyqt6"]: 1882 if PYQT_VERSION < requiredVersions["pyqt6"]:
1898 print("Please install another version.") 1898 print("Please install another version.")
1899 exit(4) 1899 exit(4)
1900 1900
1901 # check version of QScintilla 1901 # check version of QScintilla
1902 # =========================== 1902 # ===========================
1903 from PyQt6.Qsci import ( # noqa: I101, I102 1903 from PyQt6.Qsci import ( # noqa: I-101, I-102
1904 QSCINTILLA_VERSION, 1904 QSCINTILLA_VERSION,
1905 QSCINTILLA_VERSION_STR, 1905 QSCINTILLA_VERSION_STR,
1906 ) 1906 )
1907 1907
1908 print("PyQt6-QScintilla:", QSCINTILLA_VERSION_STR.strip()) 1908 print("PyQt6-QScintilla:", QSCINTILLA_VERSION_STR.strip())
1926 print("Please install another version.") 1926 print("Please install another version.")
1927 exit(5) 1927 exit(5)
1928 1928
1929 # print version info for additional modules 1929 # print version info for additional modules
1930 with contextlib.suppress(NameError, AttributeError): 1930 with contextlib.suppress(NameError, AttributeError):
1931 from PyQt6.QtCharts import PYQT_CHART_VERSION_STR # noqa: I101, I102 1931 from PyQt6.QtCharts import PYQT_CHART_VERSION_STR # noqa: I-101, I-102
1932 1932
1933 print("PyQt6-Charts:", PYQT_CHART_VERSION_STR) 1933 print("PyQt6-Charts:", PYQT_CHART_VERSION_STR)
1934 1934
1935 with contextlib.suppress(ImportError, AttributeError): 1935 with contextlib.suppress(ImportError, AttributeError):
1936 from PyQt6 import QtWebEngineCore # noqa: I101, I102 1936 from PyQt6 import QtWebEngineCore # noqa: I-101, I-102
1937 1937
1938 print("PyQt6-WebEngine:", QtWebEngineCore.PYQT_WEBENGINE_VERSION_STR) 1938 print("PyQt6-WebEngine:", QtWebEngineCore.PYQT_WEBENGINE_VERSION_STR)
1939 1939
1940 print() 1940 print()
1941 print("All dependencies ok.") 1941 print("All dependencies ok.")
1992 @type str 1992 @type str
1993 @return value of requested registry variable 1993 @return value of requested registry variable
1994 @rtype Any 1994 @rtype Any
1995 """ 1995 """
1996 try: 1996 try:
1997 import winreg # noqa: I101, I103 1997 import winreg # noqa: I-101, I-103
1998 except ImportError: 1998 except ImportError:
1999 return None 1999 return None
2000 2000
2001 try: 2001 try:
2002 registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, winreg.KEY_READ) 2002 registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, winreg.KEY_READ)
2019 @type str 2019 @type str
2020 """ 2020 """
2021 # replicate stuff done in pywin32.pth - needed only here 2021 # replicate stuff done in pywin32.pth - needed only here
2022 import pywin32_bootstrap # noqa 2022 import pywin32_bootstrap # noqa
2023 2023
2024 from pywintypes import com_error # noqa: I102 2024 from pywintypes import com_error # noqa: I-102
2025 from win32com.client import Dispatch # noqa: I102 2025 from win32com.client import Dispatch # noqa: I-102
2026 2026
2027 with contextlib.suppress(com_error): 2027 with contextlib.suppress(com_error):
2028 shell = Dispatch("WScript.Shell") 2028 shell = Dispatch("WScript.Shell")
2029 shortcut = shell.CreateShortCut(linkPath) 2029 shortcut = shell.CreateShortCut(linkPath)
2030 shortcut.Targetpath = targetPath 2030 shortcut.Targetpath = targetPath
2438 """ eric-bugs@eric-ide.python-projects.org.\n""" 2438 """ eric-bugs@eric-ide.python-projects.org.\n"""
2439 ) 2439 )
2440 raise 2440 raise
2441 2441
2442 # 2442 #
2443 # eflag: noqa = M801 2443 # eflag: noqa = M-801

eric ide

mercurial