scripts/install.py

branch
maintenance
changeset 7824
096b3ebc1409
parent 7737
5371a22cf2aa
parent 7823
9a4e93471a06
child 7850
e64b178499da
equal deleted inserted replaced
7738:10554f5fac78 7824:096b3ebc1409
19 import fnmatch 19 import fnmatch
20 import subprocess # secok 20 import subprocess # secok
21 import time 21 import time
22 import io 22 import io
23 import json 23 import json
24 import shlex
25 import datetime
26 import getpass
24 27
25 # Define the globals. 28 # Define the globals.
26 progName = None 29 progName = None
27 currDir = os.getcwd() 30 currDir = os.getcwd()
28 modDir = None 31 modDir = None
35 doCleanup = True 38 doCleanup = True
36 doCleanDesktopLinks = False 39 doCleanDesktopLinks = False
37 forceCleanDesktopLinks = False 40 forceCleanDesktopLinks = False
38 doCompile = True 41 doCompile = True
39 yes2All = False 42 yes2All = False
43 ignorePyqt5Tools = False
40 cfg = {} 44 cfg = {}
41 progLanguages = ["Python", "Ruby", "QSS"] 45 progLanguages = ["Python", "Ruby", "QSS"]
42 sourceDir = "eric" 46 sourceDir = "eric"
43 eric6SourceDir = os.path.join(sourceDir, "eric6") 47 eric6SourceDir = os.path.join(sourceDir, "eric6")
44 configName = 'eric6config.py' 48 configName = 'eric6config.py'
50 defaultMacPythonExe = "" 54 defaultMacPythonExe = ""
51 macAppBundleName = defaultMacAppBundleName 55 macAppBundleName = defaultMacAppBundleName
52 macAppBundlePath = defaultMacAppBundlePath 56 macAppBundlePath = defaultMacAppBundlePath
53 macPythonExe = defaultMacPythonExe 57 macPythonExe = defaultMacPythonExe
54 58
59 installInfoName = "eric6install.json"
60 installInfo = {}
61 installCwd = ""
62
55 # Define blacklisted versions of the prerequisites 63 # Define blacklisted versions of the prerequisites
56 BlackLists = { 64 BlackLists = {
57 "sip": [], 65 "sip": [],
58 "PyQt5": [], 66 "PyQt5": [],
59 "QScintilla2": [], 67 "QScintilla2": [],
115 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 123 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
116 " [-m name] [-n path] [-p python] [--no-apis] [--yes]" 124 " [-m name] [-n path] [-p python] [--no-apis] [--yes]"
117 .format(progName)) 125 .format(progName))
118 elif sys.platform.startswith(("win", "cygwin")): 126 elif sys.platform.startswith(("win", "cygwin")):
119 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]" 127 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"
120 " [--clean-desktop] [--no-apis] [--yes]" 128 " [--clean-desktop] [--no-apis] [--no-tools] [--yes]"
121 .format(progName)) 129 .format(progName))
122 else: 130 else:
123 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 131 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
124 " [--no-apis] [--yes]" 132 " [--no-apis] [--no-tools] [--yes]"
125 .format(progName)) 133 .format(progName))
126 print("where:") 134 print("where:")
127 print(" -h, --help display this help message") 135 print(" -h, --help display this help message")
128 print(" -a dir where the API files will be installed") 136 print(" -a dir where the API files will be installed")
129 if apisDir: 137 if apisDir:
148 print(" (default: {0})".format(macAppBundlePath)) 156 print(" (default: {0})".format(macAppBundlePath))
149 print(" -p python path of the python executable") 157 print(" -p python path of the python executable")
150 print(" (default: {0})".format(macPythonExe)) 158 print(" (default: {0})".format(macPythonExe))
151 print(" -c don't cleanup old installation first") 159 print(" -c don't cleanup old installation first")
152 if sys.platform.startswith(("win", "cygwin")): 160 if sys.platform.startswith(("win", "cygwin")):
153 (" --clean-desktop delete desktop links before installation") 161 print(" --clean-desktop delete desktop links before installation")
162 if sys.platform != "darwin":
163 print(" --no-tools don't ask for installation of pyqt5-tools")
154 print(" -x don't perform dependency checks (use on your own" 164 print(" -x don't perform dependency checks (use on your own"
155 " risk)") 165 " risk)")
156 print(" -z don't compile the installed python files") 166 print(" -z don't compile the installed python files")
157 print(" --yes answer 'yes' to all questions") 167 print(" --yes answer 'yes' to all questions")
158 print() 168 print()
233 Copy a string to a file. 243 Copy a string to a file.
234 244
235 @param name the name of the file. 245 @param name the name of the file.
236 @param text the contents to copy to the file. 246 @param text the contents to copy to the file.
237 """ 247 """
238 f = open(name, "w") 248 with open(name, "w") as f:
239 f.write(text) 249 f.write(text)
240 f.close()
241 250
242 251
243 def copyDesktopFile(src, dst): 252 def copyDesktopFile(src, dst):
244 """ 253 """
245 Modify a desktop file and write it to its destination. 254 Modify a desktop file and write it to its destination.
247 @param src source file name (string) 256 @param src source file name (string)
248 @param dst destination file name (string) 257 @param dst destination file name (string)
249 """ 258 """
250 global cfg, platBinDir 259 global cfg, platBinDir
251 260
252 f = open(src, "r", encoding="utf-8") 261 with open(src, "r", encoding="utf-8") as f:
253 text = f.read() 262 text = f.read()
254 f.close()
255 263
256 text = text.replace("@BINDIR@", platBinDir) 264 text = text.replace("@BINDIR@", platBinDir)
257 text = text.replace("@MARKER@", "") 265 text = text.replace("@MARKER@", "")
258 text = text.replace("@PY_MARKER@", "") 266 text = text.replace("@PY_MARKER@", "")
259 267
260 f = open(dst, "w", encoding="utf-8") 268 with open(dst, "w", encoding="utf-8") as f:
261 f.write(text) 269 f.write(text)
262 f.close()
263 os.chmod(dst, 0o644) 270 os.chmod(dst, 0o644)
264 271
265 272
266 def copyAppStreamFile(src, dst): 273 def copyAppStreamFile(src, dst):
267 """ 274 """
277 # Installing from source tree 284 # Installing from source tree
278 from eric6.UI.Info import Version 285 from eric6.UI.Info import Version
279 else: 286 else:
280 Version = "Unknown" 287 Version = "Unknown"
281 288
282 f = open(src, "r", encoding="utf-8") 289 with open(src, "r", encoding="utf-8") as f:
283 text = f.read() 290 text = f.read()
284 f.close()
285 291
286 text = ( 292 text = (
287 text.replace("@MARKER@", "") 293 text.replace("@MARKER@", "")
288 .replace("@VERSION@", Version.split(None, 1)[0]) 294 .replace("@VERSION@", Version.split(None, 1)[0])
289 .replace("@DATE@", time.strftime("%Y-%m-%d")) 295 .replace("@DATE@", time.strftime("%Y-%m-%d"))
290 ) 296 )
291 297
292 f = open(dst, "w", encoding="utf-8") 298 with open(dst, "w", encoding="utf-8") as f:
293 f.write(text) 299 f.write(text)
294 f.close()
295 os.chmod(dst, 0o644) 300 os.chmod(dst, 0o644)
296 301
297 302
298 def wrapperNames(dname, wfile): 303 def wrapperNames(dname, wfile):
299 """ 304 """
422 pdir = os.path.join(cfg['mdir'], "eric6plugins") 427 pdir = os.path.join(cfg['mdir'], "eric6plugins")
423 fname = os.path.join(pdir, "__init__.py") 428 fname = os.path.join(pdir, "__init__.py")
424 if not os.path.exists(fname): 429 if not os.path.exists(fname):
425 if not os.path.exists(pdir): 430 if not os.path.exists(pdir):
426 os.mkdir(pdir, 0o755) 431 os.mkdir(pdir, 0o755)
427 f = open(fname, "w") 432 with open(fname, "w") as f:
428 f.write( 433 f.write(
429 '''# -*- coding: utf-8 -*- 434 '''# -*- coding: utf-8 -*-
430 435
431 """ 436 """
432 Package containing the global plugins. 437 Package containing the global plugins.
433 """ 438 """
434 ''' 439 '''
435 ) 440 )
436 f.close()
437 os.chmod(fname, 0o644) 441 os.chmod(fname, 0o644)
438 442
439 443
440 def cleanupSource(dirName): 444 def cleanupSource(dirName):
441 """ 445 """
715 for name in ["eric6_api", "eric6_doc"]: 719 for name in ["eric6_api", "eric6_doc"]:
716 wnames.append(createPyWrapper(cfg['ericDir'], name, scriptsDir, False)) 720 wnames.append(createPyWrapper(cfg['ericDir'], name, scriptsDir, False))
717 for name in ["eric6_compare", "eric6_configure", "eric6_diff", 721 for name in ["eric6_compare", "eric6_configure", "eric6_diff",
718 "eric6_editor", "eric6_hexeditor", "eric6_iconeditor", 722 "eric6_editor", "eric6_hexeditor", "eric6_iconeditor",
719 "eric6_plugininstall", "eric6_pluginrepository", 723 "eric6_plugininstall", "eric6_pluginrepository",
720 "eric6_pluginuninstall", "eric6_qregexp", 724 "eric6_pluginuninstall", "eric6_qregularexpression",
721 "eric6_qregularexpression", "eric6_re", "eric6_snap", 725 "eric6_re", "eric6_snap", "eric6_sqlbrowser", "eric6_tray",
722 "eric6_sqlbrowser", "eric6_tray", "eric6_trpreviewer", 726 "eric6_trpreviewer", "eric6_uipreviewer", "eric6_unittest",
723 "eric6_uipreviewer", "eric6_unittest", "eric6_browser", 727 "eric6_browser", "eric6_shell", "eric6"]:
724 "eric6_shell", "eric6"]:
725 wnames.append(createPyWrapper(cfg['ericDir'], name, scriptsDir)) 728 wnames.append(createPyWrapper(cfg['ericDir'], name, scriptsDir))
726 729
727 # set install prefix, if not None 730 # set install prefix, if not None
728 if distDir: 731 if distDir:
729 for key in list(cfg.keys()): 732 for key in list(cfg.keys()):
1238 for apiName in sorted( 1241 for apiName in sorted(
1239 glob.glob(os.path.join(eric6SourceDir, "APIs", 1242 glob.glob(os.path.join(eric6SourceDir, "APIs",
1240 "MicroPython", "*.api"))): 1243 "MicroPython", "*.api"))):
1241 apis.append(os.path.basename(apiName)) 1244 apis.append(os.path.basename(apiName))
1242 1245
1246 if sys.platform == "darwin":
1247 macConfig = (
1248 """ 'macAppBundlePath': r'{0}',\n"""
1249 """ 'macAppBundleName': r'{1}',\n"""
1250 ).format(macAppBundlePath, macAppBundleName)
1251 else:
1252 macConfig = ""
1243 config = ( 1253 config = (
1244 """# -*- coding: utf-8 -*-\n""" 1254 """# -*- coding: utf-8 -*-\n"""
1245 """#\n""" 1255 """#\n"""
1246 """# This module contains the configuration of the individual eric6""" 1256 """# This module contains the configuration of the individual eric6"""
1247 """ installation\n""" 1257 """ installation\n"""
1262 """ 'ericOthersDir': r'{11}',\n""" 1272 """ 'ericOthersDir': r'{11}',\n"""
1263 """ 'bindir': r'{12}',\n""" 1273 """ 'bindir': r'{12}',\n"""
1264 """ 'mdir': r'{13}',\n""" 1274 """ 'mdir': r'{13}',\n"""
1265 """ 'apidir': r'{14}',\n""" 1275 """ 'apidir': r'{14}',\n"""
1266 """ 'apis': {15},\n""" 1276 """ 'apis': {15},\n"""
1267 """ 'macAppBundlePath': r'{16}',\n""" 1277 """{16}"""
1268 """ 'macAppBundleName': r'{17}',\n"""
1269 """}}\n""" 1278 """}}\n"""
1270 """\n""" 1279 """\n"""
1271 """def getConfig(name):\n""" 1280 """def getConfig(name):\n"""
1272 """ '''\n""" 1281 """ '''\n"""
1273 """ Module function to get a configuration value.\n""" 1282 """ Module function to get a configuration value.\n"""
1292 cfg['ericExamplesDir'], cfg['ericTranslationsDir'], 1301 cfg['ericExamplesDir'], cfg['ericTranslationsDir'],
1293 cfg['ericTemplatesDir'], 1302 cfg['ericTemplatesDir'],
1294 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'], 1303 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'],
1295 cfg['bindir'], cfg['mdir'], 1304 cfg['bindir'], cfg['mdir'],
1296 cfg['apidir'], sorted(apis), 1305 cfg['apidir'], sorted(apis),
1297 macAppBundlePath, macAppBundleName, 1306 macConfig,
1298 ) 1307 )
1299 copyToFile(configName, config) 1308 copyToFile(configName, config)
1309
1310
1311 def createInstallInfo():
1312 """
1313 Record information about the way eric6 was installed.
1314 """
1315 global installInfo, installCwd, cfg
1316
1317 installDateTime = datetime.datetime.now(tz=None)
1318 try:
1319 installInfo["sudo"] = os.getuid() == 0
1320 except AttributeError:
1321 installInfo["sudo"] = False
1322 installInfo["user"] = getpass.getuser()
1323 installInfo["exe"] = sys.executable
1324 installInfo["argv"] = " ".join(shlex.quote(a) for a in sys.argv[:])
1325 installInfo["install_cwd"] = installCwd
1326 installInfo["eric"] = cfg["ericDir"]
1327 installInfo["virtualenv"] = installInfo["eric"].startswith(
1328 os.path.expanduser("~"))
1329 installInfo["installed"] = True
1330 installInfo["installed_on"] = installDateTime.strftime(
1331 "%Y-%m-%d %H:%M:%S")
1332 installInfo["guessed"] = False
1333 installInfo["edited"] = False
1334 installInfo["pip"] = False
1335 installInfo["remarks"] = ""
1336 installInfo["install_cwd_edited"] = False
1337 installInfo["exe_edited"] = False
1338 installInfo["argv_edited"] = False
1339 installInfo["eric_edited"] = False
1300 1340
1301 1341
1302 def pipInstall(packageName, message): 1342 def pipInstall(packageName, message):
1303 """ 1343 """
1304 Install the given package via pip. 1344 Install the given package via pip.
1374 1414
1375 def doDependancyChecks(): 1415 def doDependancyChecks():
1376 """ 1416 """
1377 Perform some dependency checks. 1417 Perform some dependency checks.
1378 """ 1418 """
1419 try:
1420 isSudo = os.getuid() == 0
1421 except AttributeError:
1422 isSudo = False
1423
1379 print('Checking dependencies') 1424 print('Checking dependencies')
1380 1425
1381 # update pip first even if we don't need to install anything 1426 # update pip first even if we don't need to install anything
1382 if isPipOutdated(): 1427 if not isSudo and isPipOutdated():
1383 updatePip() 1428 updatePip()
1384 print("\n") 1429 print("\n")
1385 1430
1386 # perform dependency checks 1431 # perform dependency checks
1387 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3])) 1432 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3]))
1397 exit(5) 1442 exit(5)
1398 1443
1399 try: 1444 try:
1400 from PyQt5.QtCore import qVersion 1445 from PyQt5.QtCore import qVersion
1401 except ImportError as msg: 1446 except ImportError as msg:
1402 installed = pipInstall( 1447 installed = not isSudo and pipInstall(
1403 "PyQt5", 1448 "PyQt5",
1404 "'PyQt5' could not be detected.\nError: {0}".format(msg) 1449 "'PyQt5' could not be detected.\nError: {0}".format(msg)
1405 ) 1450 )
1406 if installed: 1451 if installed:
1407 # try to import it again 1452 # try to import it again
1430 from PyQt5 import QtWebEngineWidgets # __IGNORE_WARNING__ 1475 from PyQt5 import QtWebEngineWidgets # __IGNORE_WARNING__
1431 except ImportError as msg: 1476 except ImportError as msg:
1432 from PyQt5.QtCore import PYQT_VERSION 1477 from PyQt5.QtCore import PYQT_VERSION
1433 if PYQT_VERSION >= 0x050c00: 1478 if PYQT_VERSION >= 0x050c00:
1434 # PyQt 5.12 separated QtWebEngine into a separate wheel 1479 # PyQt 5.12 separated QtWebEngine into a separate wheel
1435 installed = pipInstall( 1480 if isSudo:
1436 "PyQtWebEngine", 1481 print("Optional 'PyQtWebEngine' could not be detected.")
1437 "Optional 'PyQtWebEngine' could not be detected.\nError: {0}" 1482 else:
1438 .format(msg) 1483 pipInstall(
1439 ) 1484 "PyQtWebEngine",
1485 "Optional 'PyQtWebEngine' could not be detected.\n"
1486 "Error: {0}".format(msg)
1487 )
1440 1488
1441 try: 1489 try:
1442 from PyQt5 import QtChart # __IGNORE_WARNING__ 1490 from PyQt5 import QtChart # __IGNORE_WARNING__
1443 except ImportError as msg: 1491 except ImportError as msg:
1444 installed = pipInstall( 1492 if isSudo:
1445 "PyQtChart", 1493 print("Optional 'PyQtChart' could not be detected.")
1446 "Optional 'PyQtChart' could not be detected.\nError: {0}" 1494 else:
1447 .format(msg) 1495 pipInstall(
1448 ) 1496 "PyQtChart",
1497 "Optional 'PyQtChart' could not be detected.\n"
1498 "Error: {0}".format(msg)
1499 )
1449 1500
1450 try: 1501 try:
1451 from PyQt5 import Qsci # __IGNORE_WARNING__ 1502 from PyQt5 import Qsci # __IGNORE_WARNING__
1452 except ImportError as msg: 1503 except ImportError as msg:
1453 installed = pipInstall( 1504 installed = not isSudo and pipInstall(
1454 "QScintilla", 1505 "QScintilla",
1455 "'QScintilla' could not be detected.\nError: {0}".format(msg) 1506 "'QScintilla' could not be detected.\nError: {0}".format(msg)
1456 ) 1507 )
1457 if installed: 1508 if installed:
1458 # try to import it again 1509 # try to import it again
1477 altModulesList = [ 1528 altModulesList = [
1478 # Tuple with alternatives, flag indicating it's ok to not be 1529 # Tuple with alternatives, flag indicating it's ok to not be
1479 # available (e.g. for 32-Bit Windows) 1530 # available (e.g. for 32-Bit Windows)
1480 (("PyQt5.QtWebEngineWidgets", ), sys.maxsize <= 2**32), 1531 (("PyQt5.QtWebEngineWidgets", ), sys.maxsize <= 2**32),
1481 ] 1532 ]
1533 optionalModulesList = {}
1534 if sys.platform != "darwin" and not ignorePyqt5Tools:
1535 optionalModulesList["pyqt5-tools"] = "pyqt5_tools"
1536
1482 # check mandatory modules 1537 # check mandatory modules
1483 modulesOK = True 1538 modulesOK = True
1484 for impModule in impModulesList: 1539 for impModule in impModulesList:
1485 name = impModule.split(".")[1] 1540 name = impModule.split(".")[1]
1486 try: 1541 try:
1510 altModulesOK = False 1565 altModulesOK = False
1511 print('Sorry, please install {0}.' 1566 print('Sorry, please install {0}.'
1512 .format(" or ".join(altModules))) 1567 .format(" or ".join(altModules)))
1513 if not altModulesOK: 1568 if not altModulesOK:
1514 exit(1) 1569 exit(1)
1570 # check optional modules
1571 for optPackage in optionalModulesList:
1572 try:
1573 __import__(optionalModulesList[optPackage])
1574 print("Found", optPackage)
1575 except ImportError as msg:
1576 if isSudo:
1577 print("Optional '{0}' could not be detected."
1578 .format(optPackage))
1579 else:
1580 pipInstall(
1581 optPackage,
1582 "Optional '{0}' could not be detected.\n"
1583 "Error: {1}".format(optPackage, msg)
1584 )
1515 1585
1516 # determine the platform dependent black list 1586 # determine the platform dependent black list
1517 if sys.platform.startswith(("win", "cygwin")): 1587 if sys.platform.startswith(("win", "cygwin")):
1518 PlatformBlackLists = PlatformsBlackLists["windows"] 1588 PlatformBlackLists = PlatformsBlackLists["windows"]
1519 elif sys.platform.startswith("linux"): 1589 elif sys.platform.startswith("linux"):
1523 1593
1524 # check version of Qt 1594 # check version of Qt
1525 qtMajor = int(qVersion().split('.')[0]) 1595 qtMajor = int(qVersion().split('.')[0])
1526 qtMinor = int(qVersion().split('.')[1]) 1596 qtMinor = int(qVersion().split('.')[1])
1527 print("Qt Version: {0}".format(qVersion().strip())) 1597 print("Qt Version: {0}".format(qVersion().strip()))
1528 if qtMajor == 5 and qtMinor < 9: 1598 if qtMajor == 5 and qtMinor < 12:
1529 print('Sorry, you must have Qt version 5.9.0 or better.') 1599 print('Sorry, you must have Qt version 5.12.0 or better.')
1530 exit(2) 1600 exit(2)
1531 1601
1532 # check version of sip 1602 # check version of sip
1533 try: 1603 try:
1534 try: 1604 try:
1574 pyqtVersion += '.0' 1644 pyqtVersion += '.0'
1575 (major, minor, pat) = pyqtVersion.split('.') 1645 (major, minor, pat) = pyqtVersion.split('.')
1576 major = int(major) 1646 major = int(major)
1577 minor = int(minor) 1647 minor = int(minor)
1578 pat = int(pat) 1648 pat = int(pat)
1579 if major == 5 and minor < 9: 1649 if major == 5 and minor < 12:
1580 print('Sorry, you must have PyQt 5.9.0 or better or' 1650 print('Sorry, you must have PyQt 5.12.0 or better or'
1581 ' a recent snapshot release.') 1651 ' a recent snapshot release.')
1582 exit(4) 1652 exit(4)
1583 # check for blacklisted versions 1653 # check for blacklisted versions
1584 for vers in BlackLists["PyQt5"] + PlatformBlackLists["PyQt5"]: 1654 for vers in BlackLists["PyQt5"] + PlatformBlackLists["PyQt5"]:
1585 if vers == pyqtVersion: 1655 if vers == pyqtVersion:
1598 scintillaVersion += '.0' 1668 scintillaVersion += '.0'
1599 (major, minor, pat) = scintillaVersion.split('.') 1669 (major, minor, pat) = scintillaVersion.split('.')
1600 major = int(major) 1670 major = int(major)
1601 minor = int(minor) 1671 minor = int(minor)
1602 pat = int(pat) 1672 pat = int(pat)
1603 if major < 2 or (major == 2 and minor < 9): 1673 if (
1604 print('Sorry, you must have QScintilla 2.9.0 or higher or' 1674 major < 2 or
1675 (major == 2 and minor < 11) or
1676 (major == 2 and minor == 11 and pat < 1)
1677 ):
1678 print('Sorry, you must have QScintilla 2.11.1 or higher or'
1605 ' a recent snapshot release.') 1679 ' a recent snapshot release.')
1606 exit(5) 1680 exit(5)
1607 # check for blacklisted versions 1681 # check for blacklisted versions
1608 for vers in ( 1682 for vers in (
1609 BlackLists["QScintilla2"] + 1683 BlackLists["QScintilla2"] +
1671 hgOut = "" 1745 hgOut = ""
1672 if hgOut: 1746 if hgOut:
1673 hgOut = hgOut.strip() 1747 hgOut = hgOut.strip()
1674 if hgOut.endswith("+"): 1748 if hgOut.endswith("+"):
1675 hgOut = hgOut[:-1] 1749 hgOut = hgOut[:-1]
1676 f = open(fileName + ".orig", "r", encoding="utf-8") 1750 with open(fileName + ".orig", "r", encoding="utf-8") as f:
1677 text = f.read() 1751 text = f.read()
1678 f.close()
1679 text = ( 1752 text = (
1680 text.replace("@@REVISION@@", hgOut) 1753 text.replace("@@REVISION@@", hgOut)
1681 .replace("@@VERSION@@", "rev_" + hgOut) 1754 .replace("@@VERSION@@", "rev_" + hgOut)
1682 ) 1755 )
1683 copyToFile(fileName, text) 1756 copyToFile(fileName, text)
1795 1868
1796 # Parse the command line. 1869 # Parse the command line.
1797 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir 1870 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
1798 global sourceDir, eric6SourceDir, configName 1871 global sourceDir, eric6SourceDir, configName
1799 global macAppBundlePath, macAppBundleName, macPythonExe 1872 global macAppBundlePath, macAppBundleName, macPythonExe
1800 global installApis, doCleanDesktopLinks, yes2All 1873 global installApis, doCleanDesktopLinks, yes2All, installCwd
1874 global ignorePyqt5Tools
1801 1875
1802 if sys.version_info < (3, 5, 0) or sys.version_info > (3, 99, 99): 1876 if sys.version_info < (3, 5, 0) or sys.version_info > (3, 99, 99):
1803 print('Sorry, eric6 requires at least Python 3.5 for running.') 1877 print('Sorry, eric6 requires at least Python 3.5 for running.')
1804 exit(5) 1878 exit(5)
1805 1879
1806 progName = os.path.basename(argv[0]) 1880 progName = os.path.basename(argv[0])
1807 1881
1882 installCwd = os.getcwd()
1883
1808 if os.path.dirname(argv[0]): 1884 if os.path.dirname(argv[0]):
1809 os.chdir(os.path.dirname(argv[0])) 1885 os.chdir(os.path.dirname(argv[0]))
1810 1886
1811 initGlobals() 1887 initGlobals()
1812 1888
1813 try: 1889 try:
1814 if sys.platform.startswith(("win", "cygwin")): 1890 if sys.platform.startswith(("win", "cygwin")):
1815 optlist, args = getopt.getopt( 1891 optlist, args = getopt.getopt(
1816 argv[1:], "chxza:b:d:f:", 1892 argv[1:], "chxza:b:d:f:",
1817 ["help", "no-apis", "yes"]) 1893 ["help", "no-apis", "no-tools", "yes"])
1818 elif sys.platform == "darwin": 1894 elif sys.platform == "darwin":
1819 optlist, args = getopt.getopt( 1895 optlist, args = getopt.getopt(
1820 argv[1:], "chxza:b:d:f:i:m:n:p:", 1896 argv[1:], "chxza:b:d:f:i:m:n:p:",
1821 ["help", "no-apis", "yes"]) 1897 ["help", "no-apis", "yes"])
1822 else: 1898 else:
1823 optlist, args = getopt.getopt( 1899 optlist, args = getopt.getopt(
1824 argv[1:], "chxza:b:d:f:i:", 1900 argv[1:], "chxza:b:d:f:i:",
1825 ["help", "no-apis", "yes"]) 1901 ["help", "no-apis", "no-tools", "yes"])
1826 except getopt.GetoptError as err: 1902 except getopt.GetoptError as err:
1827 print(err) 1903 print(err)
1828 usage() 1904 usage()
1829 1905
1830 global platBinDir 1906 global platBinDir
1868 installApis = False 1944 installApis = False
1869 elif opt == "--clean-desktop": 1945 elif opt == "--clean-desktop":
1870 doCleanDesktopLinks = True 1946 doCleanDesktopLinks = True
1871 elif opt == "--yes": 1947 elif opt == "--yes":
1872 yes2All = True 1948 yes2All = True
1949 elif opt == "--no-tools":
1950 ignorePyqt5Tools = True
1873 1951
1874 infoName = "" 1952 infoName = ""
1875 installFromSource = not os.path.isdir(sourceDir) 1953 installFromSource = not os.path.isdir(sourceDir)
1876 1954
1877 # check dependencies 1955 # check dependencies
1923 2001
1924 # Create a config file and delete the default one 2002 # Create a config file and delete the default one
1925 print("\nCreating configuration file ...") 2003 print("\nCreating configuration file ...")
1926 createConfig() 2004 createConfig()
1927 2005
2006 createInstallInfo()
2007
1928 # Compile .ui files 2008 # Compile .ui files
1929 print("\nCompiling user interface files ...") 2009 print("\nCompiling user interface files ...")
1930 # step 1: remove old Ui_*.py files 2010 # step 1: remove old Ui_*.py files
1931 for root, _, files in os.walk(sourceDir): 2011 for root, _, files in os.walk(sourceDir):
1932 for file in [f for f in files if fnmatch.fnmatch(f, 'Ui_*.py')]: 2012 for file in [f for f in files if fnmatch.fnmatch(f, 'Ui_*.py')]:
1957 dfile=os.path.join(modDir, "eric6config.py")) 2037 dfile=os.path.join(modDir, "eric6config.py"))
1958 sys.stdout = sys.__stdout__ 2038 sys.stdout = sys.__stdout__
1959 print("\nInstalling eric6 ...") 2039 print("\nInstalling eric6 ...")
1960 res = installEric() 2040 res = installEric()
1961 2041
2042 with open(os.path.join(cfg["ericDir"],
2043 installInfoName), "w") as installInfoFile:
2044 json.dump(installInfo, installInfoFile, indent=2)
2045
1962 # do some cleanup 2046 # do some cleanup
1963 try: 2047 try:
1964 if installFromSource: 2048 if installFromSource:
1965 os.remove(configName) 2049 os.remove(configName)
1966 configNameC = configName + 'c' 2050 configNameC = configName + 'c'

eric ide

mercurial