scripts/install.py

branch
eric7-maintenance
changeset 9549
67295777d9fe
parent 9449
c982bacca23f
parent 9485
0f3620304d7a
child 9654
7328efba128b
equal deleted inserted replaced
9451:24c847222774 9549:67295777d9fe
11 11
12 import compileall 12 import compileall
13 import contextlib 13 import contextlib
14 import datetime 14 import datetime
15 import fnmatch 15 import fnmatch
16 import getopt
16 import getpass 17 import getpass
17 import glob 18 import glob
19 import importlib
18 import io 20 import io
19 import json 21 import json
20 import os 22 import os
21 import py_compile 23 import py_compile
22 import re 24 import re
1211 os.path.join(directories["icns"], "eric.icns"), 1213 os.path.join(directories["icns"], "eric.icns"),
1212 ) 1214 )
1213 1215
1214 if os.path.exists(os.path.join("eric", "eric7", "UI", "Info.py")): 1216 if os.path.exists(os.path.join("eric", "eric7", "UI", "Info.py")):
1215 # Installing from archive 1217 # Installing from archive
1216 from eric.eric7.UI.Info import Version, CopyrightShort 1218 from eric.eric7.UI.Info import CopyrightShort, Version
1217 elif os.path.exists(os.path.join("eric7", "UI", "Info.py")): 1219 elif os.path.exists(os.path.join("eric7", "UI", "Info.py")):
1218 # Installing from source tree 1220 # Installing from source tree
1219 from eric7.UI.Info import Version, CopyrightShort 1221 from eric7.UI.Info import CopyrightShort, Version
1220 else: 1222 else:
1221 Version = "Unknown" 1223 Version = "Unknown"
1222 CopyrightShort = "(c) 2002 - 2022 Detlev Offenbach" 1224 CopyrightShort = "(c) 2002 - 2022 Detlev Offenbach"
1223 1225
1224 copyToFile( 1226 copyToFile(
1696 "packaging": ("packaging", ""), 1698 "packaging": ("packaging", ""),
1697 "cyclonedx-python-lib": ("cyclonedx", ""), 1699 "cyclonedx-python-lib": ("cyclonedx", ""),
1698 "cyclonedx-bom": ("cyclonedx_py", ""), 1700 "cyclonedx-bom": ("cyclonedx_py", ""),
1699 "trove-classifiers": ("trove_classifiers", ""), 1701 "trove-classifiers": ("trove_classifiers", ""),
1700 "black": ("black", ">=22.6.0"), 1702 "black": ("black", ">=22.6.0"),
1703 "isort": ("isort", ">=5.10.0"),
1701 } 1704 }
1702 optionalModulesList = { 1705 optionalModulesList = {
1703 # key is pip project name 1706 # key is pip project name
1704 # value is tuple of package name, pip install constraint 1707 # value is tuple of package name, pip install constraint
1705 "docutils": ("docutils", ""), 1708 "docutils": ("docutils", ""),
1716 # check mandatory PyQt6 modules 1719 # check mandatory PyQt6 modules
1717 modulesOK = True 1720 modulesOK = True
1718 for pyqt6BaseModule in pyqt6BaseModulesList: 1721 for pyqt6BaseModule in pyqt6BaseModulesList:
1719 name = pyqt6BaseModule.split(".")[1] 1722 name = pyqt6BaseModule.split(".")[1]
1720 try: 1723 try:
1721 __import__(pyqt6BaseModule) 1724 importlib.import_module(pyqt6BaseModule)
1722 print("Found", name) 1725 print("Found", name)
1723 except ImportError as err: 1726 except ImportError as err:
1724 print("Sorry, please install {0}.".format(name)) 1727 print("Sorry, please install {0}.".format(name))
1725 if verbose: 1728 if verbose:
1726 print("Error: {0}".format(err)) 1729 print("Error: {0}".format(err))
1730 1733
1731 # check required modules 1734 # check required modules
1732 requiredMissing = False 1735 requiredMissing = False
1733 for requiredPackage in requiredModulesList: 1736 for requiredPackage in requiredModulesList:
1734 try: 1737 try:
1735 __import__(requiredModulesList[requiredPackage][0]) 1738 importlib.import_module(requiredModulesList[requiredPackage][0])
1736 print("Found", requiredPackage) 1739 print("Found", requiredPackage)
1737 except ImportError as err: 1740 except ImportError as err:
1738 if isSudo: 1741 if isSudo:
1739 print("Required '{0}' could not be detected.".format(requiredPackage)) 1742 print("Required '{0}' could not be detected.".format(requiredPackage))
1740 requiredMissing = True 1743 requiredMissing = True
1754 1757
1755 # check optional modules 1758 # check optional modules
1756 optionalMissing = False 1759 optionalMissing = False
1757 for optPackage in optionalModulesList: 1760 for optPackage in optionalModulesList:
1758 try: 1761 try:
1759 __import__(optionalModulesList[optPackage][0]) 1762 importlib.import_module(optionalModulesList[optPackage][0])
1760 print("Found", optPackage) 1763 print("Found", optPackage)
1761 except ImportError as err: 1764 except ImportError as err:
1762 if isSudo: 1765 if isSudo:
1763 print("Optional '{0}' could not be detected.".format(optPackage)) 1766 print("Optional '{0}' could not be detected.".format(optPackage))
1764 optionalMissing = True 1767 optionalMissing = True
1962 @type str 1965 @type str
1963 @return value of requested registry variable 1966 @return value of requested registry variable
1964 @rtype any 1967 @rtype any
1965 """ 1968 """
1966 try: 1969 try:
1967 import winreg 1970 import winreg # __IGNORE_WARNING_I103__
1968 except ImportError: 1971 except ImportError:
1969 return None 1972 return None
1970 1973
1971 try: 1974 try:
1972 registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, winreg.KEY_READ) 1975 registryKey = winreg.OpenKey(winreg.HKEY_CURRENT_USER, path, 0, winreg.KEY_READ)
1986 @param targetPath path the shortcut shall point to 1989 @param targetPath path the shortcut shall point to
1987 @type str 1990 @type str
1988 @param iconPath path of the icon file 1991 @param iconPath path of the icon file
1989 @type str 1992 @type str
1990 """ 1993 """
1994 from pywintypes import com_error
1991 from win32com.client import Dispatch 1995 from win32com.client import Dispatch
1992 from pywintypes import com_error
1993 1996
1994 with contextlib.suppress(com_error): 1997 with contextlib.suppress(com_error):
1995 shell = Dispatch("WScript.Shell") 1998 shell = Dispatch("WScript.Shell")
1996 shortcut = shell.CreateShortCut(linkPath) 1999 shortcut = shell.CreateShortCut(linkPath)
1997 shortcut.Targetpath = targetPath 2000 shortcut.Targetpath = targetPath
2071 The main function of the script. 2074 The main function of the script.
2072 2075
2073 @param argv list of command line arguments 2076 @param argv list of command line arguments
2074 @type list of str 2077 @type list of str
2075 """ 2078 """
2076 import getopt
2077
2078 # Parse the command line. 2079 # Parse the command line.
2079 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir 2080 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
2080 global sourceDir, eric7SourceDir, configName 2081 global sourceDir, eric7SourceDir, configName
2081 global macAppBundlePath, macAppBundleName, macPythonExe 2082 global macAppBundlePath, macAppBundleName, macPythonExe
2082 global installApis, doCleanDesktopLinks, yes2All 2083 global installApis, doCleanDesktopLinks, yes2All
2314 """ eric-bugs@eric-ide.python-projects.org.\n""" 2315 """ eric-bugs@eric-ide.python-projects.org.\n"""
2315 ) 2316 )
2316 raise 2317 raise
2317 2318
2318 # 2319 #
2319 # eflag: noqa = M801 2320 # eflag: noqa = M801, I101, I102

eric ide

mercurial