scripts/install.py

branch
eric7
changeset 10801
5859861e7a1f
parent 10788
c14f37a9aa74
child 10814
ba20efe10336
child 10828
fc1310995b98
equal deleted inserted replaced
10800:c6ce5522be30 10801:5859861e7a1f
43 forceCleanDesktopLinks = False 43 forceCleanDesktopLinks = False
44 doCompile = True 44 doCompile = True
45 yes2All = False 45 yes2All = False
46 withPyqt6Tools = False 46 withPyqt6Tools = False
47 verbose = False 47 verbose = False
48 proxy = None
48 cfg = {} 49 cfg = {}
49 progLanguages = ["MicroPython", "Python3", "QSS"] 50 progLanguages = ["MicroPython", "Python3", "QSS"]
50 sourceDir = "eric" 51 sourceDir = "eric"
51 eric7SourceDir = "" 52 eric7SourceDir = ""
52 configName = "eric7config.py" 53 configName = "eric7config.py"
1456 without asking the user 1457 without asking the user
1457 @type bool 1458 @type bool
1458 @return flag indicating a successful installation 1459 @return flag indicating a successful installation
1459 @rtype bool 1460 @rtype bool
1460 """ 1461 """
1461 global yes2All 1462 global yes2All, proxy
1462 1463
1463 ok = False 1464 ok = False
1464 if yes2All or force: 1465 if yes2All or force:
1465 answer = "y" 1466 answer = "y"
1466 else: 1467 else:
1470 ), 1471 ),
1471 end=" ", 1472 end=" ",
1472 ) 1473 )
1473 answer = input() # secok 1474 answer = input() # secok
1474 if answer in ("", "Y", "y"): 1475 if answer in ("", "Y", "y"):
1475 exitCode = subprocess.run( # secok 1476 args = [
1476 [ 1477 sys.executable,
1477 sys.executable, 1478 "-m",
1478 "-m", 1479 "pip",
1479 "pip", 1480 "install",
1480 "install", 1481 "--prefer-binary",
1481 "--prefer-binary", 1482 "--upgrade",
1482 "--upgrade", 1483 ]
1483 packageName, 1484 if proxy:
1484 ] 1485 args.append(f"--proxy={proxy}")
1485 ).returncode 1486 args.append(packageName)
1487 exitCode = subprocess.run(args).returncode # secok
1486 ok = exitCode == 0 1488 ok = exitCode == 0
1487 1489
1488 return ok 1490 return ok
1489 1491
1490 1492
1493 Check, if pip is outdated. 1495 Check, if pip is outdated.
1494 1496
1495 @return flag indicating an outdated pip 1497 @return flag indicating an outdated pip
1496 @rtype bool 1498 @rtype bool
1497 """ 1499 """
1500 global proxy
1501
1498 try: 1502 try:
1503 args = [
1504 sys.executable,
1505 "-m",
1506 "pip",
1507 "list",
1508 "--outdated",
1509 "--format=json",
1510 ]
1511 if proxy:
1512 args.append(f"--proxy={proxy}")
1499 pipOut = ( 1513 pipOut = (
1500 subprocess.run( # secok 1514 subprocess.run( # secok
1501 [sys.executable, "-m", "pip", "list", "--outdated", "--format=json"], 1515 args,
1502 check=True, 1516 check=True,
1503 capture_output=True, 1517 capture_output=True,
1504 text=True, 1518 text=True,
1505 ) 1519 )
1506 .stdout.strip() 1520 .stdout.strip()
1527 1541
1528 def updatePip(): 1542 def updatePip():
1529 """ 1543 """
1530 Update the installed pip package. 1544 Update the installed pip package.
1531 """ 1545 """
1532 global yes2All 1546 global yes2All, proxy
1533 1547
1534 if yes2All: 1548 if yes2All:
1535 answer = "y" 1549 answer = "y"
1536 else: 1550 else:
1537 print("Shall 'pip' be updated (recommended)? (Y/n)", end=" ") 1551 print("Shall 'pip' be updated (recommended)? (Y/n)", end=" ")
1538 answer = input() # secok 1552 answer = input() # secok
1539 if answer in ("", "Y", "y"): 1553 if answer in ("", "Y", "y"):
1540 subprocess.run( # secok 1554 args = [
1541 [sys.executable, "-m", "pip", "install", "--upgrade", "pip"] 1555 sys.executable,
1542 ) 1556 "-m",
1557 "pip",
1558 "install",
1559 "--upgrade",
1560 ]
1561 if proxy:
1562 args.append(f"--proxy={proxy}")
1563 args.append("pip")
1564 subprocess.run(args) # secok
1543 1565
1544 1566
1545 def versionToStr(version): 1567 def versionToStr(version):
1546 """ 1568 """
1547 Function to convert a version number into a version string. 1569 Function to convert a version number into a version string.
2072 @rtype argparse.ArgumentParser 2094 @rtype argparse.ArgumentParser
2073 """ 2095 """
2074 parser = argparse.ArgumentParser( 2096 parser = argparse.ArgumentParser(
2075 description="Install eric7 from the source code tree.", 2097 description="Install eric7 from the source code tree.",
2076 epilog="The file given to the -f option must be valid Python code defining a" 2098 epilog="The file given to the -f option must be valid Python code defining a"
2077 "dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir', ericIconDir'," 2099 " dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir', ericIconDir',"
2078 " 'ericDTDDir', 'ericCSSDir', 'ericStylesDir', 'ericThemesDir', ericDocDir'," 2100 " 'ericDTDDir', 'ericCSSDir', 'ericStylesDir', 'ericThemesDir', ericDocDir',"
2079 " ericExamplesDir', ericTranslationsDir', 'ericTemplatesDir'," 2101 " ericExamplesDir', ericTranslationsDir', 'ericTemplatesDir',"
2080 " 'ericCodeTemplatesDir', ericOthersDir','bindir', 'mdir' and 'apidir." 2102 " 'ericCodeTemplatesDir', ericOthersDir','bindir', 'mdir' and 'apidir."
2081 "These define the directories for the installation of the various parts of" 2103 " These define the directories for the installation of the various parts of"
2082 " eric.", 2104 " eric.",
2083 ) 2105 )
2084 2106
2085 parser.add_argument( 2107 parser.add_argument(
2086 "-a", 2108 "-a",
2182 parser.add_argument( 2204 parser.add_argument(
2183 "--with-tools", 2205 "--with-tools",
2184 action="store_true", 2206 action="store_true",
2185 help="install the 'qt6-applications' package", 2207 help="install the 'qt6-applications' package",
2186 ) 2208 )
2209 parser.add_argument(
2210 "--proxy",
2211 default=None,
2212 metavar="url",
2213 help="HTTP proxy url will be used with pip (default: no proxy used)",
2214 )
2187 2215
2188 return parser 2216 return parser
2189 2217
2190 2218
2191 def main(argv): 2219 def main(argv):
2196 @type list of str 2224 @type list of str
2197 """ 2225 """
2198 global modDir, doCleanup, doCompile, distDir, cfg, apisDir 2226 global modDir, doCleanup, doCompile, distDir, cfg, apisDir
2199 global sourceDir, eric7SourceDir, configName, platBinDir 2227 global sourceDir, eric7SourceDir, configName, platBinDir
2200 global macAppBundlePath, macAppBundleName, macPythonExe 2228 global macAppBundlePath, macAppBundleName, macPythonExe
2201 global installApis, doCleanDesktopLinks, yes2All 2229 global installApis, doCleanDesktopLinks, yes2All, proxy
2202 global createInstallInfoFile, installCwd 2230 global createInstallInfoFile, installCwd
2203 global withPyqt6Tools 2231 global withPyqt6Tools
2204 global verbose 2232 global verbose
2205 2233
2206 if sys.version_info < (3, 8, 0) or sys.version_info > (3, 99, 99): 2234 if sys.version_info < (3, 8, 0) or sys.version_info > (3, 99, 99):
2223 depChecks = args.x 2251 depChecks = args.x
2224 doCleanup = args.c 2252 doCleanup = args.c
2225 doCompile = args.z 2253 doCompile = args.z
2226 installApis = not args.no_apis 2254 installApis = not args.no_apis
2227 yes2All = args.yes 2255 yes2All = args.yes
2256 proxy = args.proxy
2228 withPyqt6Tools = args.with_tools 2257 withPyqt6Tools = args.with_tools
2229 createInstallInfoFile = not args.no_info 2258 createInstallInfoFile = not args.no_info
2230 verbose = args.verbose 2259 verbose = args.verbose
2231 if sys.platform == "darwin": 2260 if sys.platform == "darwin":
2232 macAppBundleName = args.m 2261 macAppBundleName = args.m

eric ide

mercurial