scripts/install.py

changeset 7921
0d429bd82699
parent 7900
72b88fb20261
child 7923
91e843545d9a
equal deleted inserted replaced
7920:322d1ee01510 7921:0d429bd82699
54 defaultMacPythonExe = "" 54 defaultMacPythonExe = ""
55 macAppBundleName = defaultMacAppBundleName 55 macAppBundleName = defaultMacAppBundleName
56 macAppBundlePath = defaultMacAppBundlePath 56 macAppBundlePath = defaultMacAppBundlePath
57 macPythonExe = defaultMacPythonExe 57 macPythonExe = defaultMacPythonExe
58 58
59 createInstallInfoFile = True
59 installInfoName = "eric6install.json" 60 installInfoName = "eric6install.json"
60 installInfo = {} 61 installInfo = {}
61 installCwd = "" 62 installCwd = ""
62 63
63 # Define blacklisted versions of the prerequisites 64 # Define blacklisted versions of the prerequisites
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} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
124 " [-m name] [-n path] [-p python] [--no-apis] [--yes]" 125 " [-m name] [-n path] [-p python] [--no-apis] [--no-info]"
126 " [--yes]"
125 .format(progName)) 127 .format(progName))
126 elif sys.platform.startswith(("win", "cygwin")): 128 elif sys.platform.startswith(("win", "cygwin")):
127 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]" 129 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"
128 " [--clean-desktop] [--no-apis] [--no-tools] [--yes]" 130 " [--clean-desktop] [--no-apis] [--no-info] [--no-tools] [--yes]"
129 .format(progName)) 131 .format(progName))
130 else: 132 else:
131 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 133 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
132 " [--no-apis] [--no-tools] [--yes]" 134 " [--no-apis] [--no-info] [--no-tools] [--yes]"
133 .format(progName)) 135 .format(progName))
134 print("where:") 136 print("where:")
135 print(" -h, --help display this help message") 137 print(" -h, --help display this help message")
136 print(" -a dir where the API files will be installed") 138 print(" -a dir where the API files will be installed")
137 if apisDir: 139 if apisDir:
157 print(" -p python path of the python executable") 159 print(" -p python path of the python executable")
158 print(" (default: {0})".format(macPythonExe)) 160 print(" (default: {0})".format(macPythonExe))
159 print(" -c don't cleanup old installation first") 161 print(" -c don't cleanup old installation first")
160 if sys.platform.startswith(("win", "cygwin")): 162 if sys.platform.startswith(("win", "cygwin")):
161 print(" --clean-desktop delete desktop links before installation") 163 print(" --clean-desktop delete desktop links before installation")
164 print(" --no-info don't create the install info file")
162 if sys.platform != "darwin": 165 if sys.platform != "darwin":
163 print(" --no-tools don't ask for installation of pyqt5-tools" 166 print(" --no-tools don't ask for installation of pyqt5-tools"
164 "/qt5-applications") 167 "/qt5-applications")
165 print(" -x don't perform dependency checks (use on your own" 168 print(" -x don't perform dependency checks (use on your own"
166 " risk)") 169 " risk)")
1311 1314
1312 def createInstallInfo(): 1315 def createInstallInfo():
1313 """ 1316 """
1314 Record information about the way eric6 was installed. 1317 Record information about the way eric6 was installed.
1315 """ 1318 """
1316 global installInfo, installCwd, cfg 1319 global createInstallInfoFile, installInfo, installCwd, cfg
1317 1320
1318 installDateTime = datetime.datetime.now(tz=None) 1321 if createInstallInfoFile:
1319 try: 1322 installDateTime = datetime.datetime.now(tz=None)
1320 installInfo["sudo"] = os.getuid() == 0 1323 try:
1321 except AttributeError: 1324 installInfo["sudo"] = os.getuid() == 0
1322 installInfo["sudo"] = False 1325 except AttributeError:
1323 installInfo["user"] = getpass.getuser() 1326 installInfo["sudo"] = False
1324 installInfo["exe"] = sys.executable 1327 installInfo["user"] = getpass.getuser()
1325 installInfo["argv"] = " ".join(shlex.quote(a) for a in sys.argv[:]) 1328 installInfo["exe"] = sys.executable
1326 installInfo["install_cwd"] = installCwd 1329 installInfo["argv"] = " ".join(shlex.quote(a) for a in sys.argv[:])
1327 installInfo["eric"] = cfg["ericDir"] 1330 installInfo["install_cwd"] = installCwd
1328 installInfo["virtualenv"] = installInfo["eric"].startswith( 1331 installInfo["eric"] = cfg["ericDir"]
1329 os.path.expanduser("~")) 1332 installInfo["virtualenv"] = installInfo["eric"].startswith(
1330 installInfo["installed"] = True 1333 os.path.expanduser("~"))
1331 installInfo["installed_on"] = installDateTime.strftime( 1334 installInfo["installed"] = True
1332 "%Y-%m-%d %H:%M:%S") 1335 installInfo["installed_on"] = installDateTime.strftime(
1333 installInfo["guessed"] = False 1336 "%Y-%m-%d %H:%M:%S")
1334 installInfo["edited"] = False 1337 installInfo["guessed"] = False
1335 installInfo["pip"] = False 1338 installInfo["edited"] = False
1336 installInfo["remarks"] = "" 1339 installInfo["pip"] = False
1337 installInfo["install_cwd_edited"] = False 1340 installInfo["remarks"] = ""
1338 installInfo["exe_edited"] = False 1341 installInfo["install_cwd_edited"] = False
1339 installInfo["argv_edited"] = False 1342 installInfo["exe_edited"] = False
1340 installInfo["eric_edited"] = False 1343 installInfo["argv_edited"] = False
1344 installInfo["eric_edited"] = False
1341 1345
1342 1346
1343 def pipInstall(packageName, message): 1347 def pipInstall(packageName, message):
1344 """ 1348 """
1345 Install the given package via pip. 1349 Install the given package via pip.
1869 1873
1870 # Parse the command line. 1874 # Parse the command line.
1871 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir 1875 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
1872 global sourceDir, eric6SourceDir, configName 1876 global sourceDir, eric6SourceDir, configName
1873 global macAppBundlePath, macAppBundleName, macPythonExe 1877 global macAppBundlePath, macAppBundleName, macPythonExe
1874 global installApis, doCleanDesktopLinks, yes2All, installCwd 1878 global installApis, doCleanDesktopLinks, yes2All
1879 global createInstallInfoFile, installCwd
1875 global ignorePyqt5Tools 1880 global ignorePyqt5Tools
1876 1881
1877 if sys.version_info < (3, 6, 0) or sys.version_info > (3, 99, 99): 1882 if sys.version_info < (3, 6, 0) or sys.version_info > (3, 99, 99):
1878 print('Sorry, eric6 requires at least Python 3.6 for running.') 1883 print('Sorry, eric6 requires at least Python 3.6 for running.')
1879 exit(5) 1884 exit(5)
1889 1894
1890 try: 1895 try:
1891 if sys.platform.startswith(("win", "cygwin")): 1896 if sys.platform.startswith(("win", "cygwin")):
1892 optlist, args = getopt.getopt( 1897 optlist, args = getopt.getopt(
1893 argv[1:], "chxza:b:d:f:", 1898 argv[1:], "chxza:b:d:f:",
1894 ["help", "no-apis", "no-tools", "yes"]) 1899 ["help", "no-apis", "no-info", "no-tools", "yes"])
1895 elif sys.platform == "darwin": 1900 elif sys.platform == "darwin":
1896 optlist, args = getopt.getopt( 1901 optlist, args = getopt.getopt(
1897 argv[1:], "chxza:b:d:f:i:m:n:p:", 1902 argv[1:], "chxza:b:d:f:i:m:n:p:",
1898 ["help", "no-apis", "yes"]) 1903 ["help", "no-apis", "no-info", "yes"])
1899 else: 1904 else:
1900 optlist, args = getopt.getopt( 1905 optlist, args = getopt.getopt(
1901 argv[1:], "chxza:b:d:f:i:", 1906 argv[1:], "chxza:b:d:f:i:",
1902 ["help", "no-apis", "no-tools", "yes"]) 1907 ["help", "no-apis", "no-info", "no-tools", "yes"])
1903 except getopt.GetoptError as err: 1908 except getopt.GetoptError as err:
1904 print(err) 1909 print(err)
1905 usage() 1910 usage()
1906 1911
1907 global platBinDir 1912 global platBinDir
1947 doCleanDesktopLinks = True 1952 doCleanDesktopLinks = True
1948 elif opt == "--yes": 1953 elif opt == "--yes":
1949 yes2All = True 1954 yes2All = True
1950 elif opt == "--no-tools": 1955 elif opt == "--no-tools":
1951 ignorePyqt5Tools = True 1956 ignorePyqt5Tools = True
1957 elif opt == "--no-info":
1958 createInstallInfoFile = False
1952 1959
1953 infoName = "" 1960 infoName = ""
1954 installFromSource = not os.path.isdir(sourceDir) 1961 installFromSource = not os.path.isdir(sourceDir)
1955 1962
1956 # check dependencies 1963 # check dependencies
2038 dfile=os.path.join(modDir, "eric6config.py")) 2045 dfile=os.path.join(modDir, "eric6config.py"))
2039 sys.stdout = sys.__stdout__ 2046 sys.stdout = sys.__stdout__
2040 print("\nInstalling eric6 ...") 2047 print("\nInstalling eric6 ...")
2041 res = installEric() 2048 res = installEric()
2042 2049
2043 with open(os.path.join(cfg["ericDir"], 2050 if createInstallInfoFile:
2044 installInfoName), "w") as installInfoFile: 2051 with open(os.path.join(cfg["ericDir"],
2045 json.dump(installInfo, installInfoFile, indent=2) 2052 installInfoName), "w") as installInfoFile:
2053 json.dump(installInfo, installInfoFile, indent=2)
2046 2054
2047 # do some cleanup 2055 # do some cleanup
2048 try: 2056 try:
2049 if installFromSource: 2057 if installFromSource:
2050 os.remove(configName) 2058 os.remove(configName)

eric ide

mercurial