install.py

changeset 3597
137370f7114b
parent 3596
f98e1946c74f
child 3607
0baeb7c76a5b
equal deleted inserted replaced
3596:f98e1946c74f 3597:137370f7114b
39 platBinDir = None 39 platBinDir = None
40 distDir = None 40 distDir = None
41 apisDir = None 41 apisDir = None
42 doCleanup = True 42 doCleanup = True
43 doCompile = True 43 doCompile = True
44 includePythonVariant = False
44 cfg = {} 45 cfg = {}
45 progLanguages = ["Python", "Ruby", "QSS"] 46 progLanguages = ["Python", "Ruby", "QSS"]
46 sourceDir = "eric" 47 sourceDir = "eric"
47 configName = 'eric5config.py' 48 configName = 'eric5config.py'
48 defaultMacAppBundleName = "eric5.app" 49 defaultMacAppBundleName = "eric5.app"
75 "PyQt4": ["4.9.2", "4.9.3"], 76 "PyQt4": ["4.9.2", "4.9.3"],
76 "QScintilla2": [], 77 "QScintilla2": [],
77 }, 78 },
78 } 79 }
79 80
81 # Define file name markers for Python variants
82 PythonMarkers = {
83 2: "_py2",
84 3: "_py3",
85 }
86
80 87
81 def exit(rcode=0): 88 def exit(rcode=0):
82 """ 89 """
83 Exit the install script. 90 Exit the install script.
84 91
108 global macAppBundleName, macAppBundlePath, macPythonExe 115 global macAppBundleName, macAppBundlePath, macPythonExe
109 116
110 print() 117 print()
111 print("Usage:") 118 print("Usage:")
112 if sys.platform == "darwin": 119 if sys.platform == "darwin":
113 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 120 print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
114 " [-m name] [-p python]".format(progName)) 121 " [-m name] [-p python]".format(progName))
115 elif sys.platform.startswith("win"): 122 elif sys.platform.startswith("win"):
116 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]" 123 print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file]"
117 .format(progName)) 124 .format(progName))
118 else: 125 else:
119 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 126 print(" {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
120 .format(progName)) 127 .format(progName))
121 print("where:") 128 print("where:")
122 print(" -h display this help message") 129 print(" -h display this help message")
123 print(" -a dir where the API files will be installed") 130 print(" -a dir where the API files will be installed")
124 if apisDir: 131 if apisDir:
140 print(" -n path path of the directory the Mac app bundle will") 147 print(" -n path path of the directory the Mac app bundle will")
141 print(" be created in") 148 print(" be created in")
142 print(" (default: {0}".format(macAppBundlePath)) 149 print(" (default: {0}".format(macAppBundlePath))
143 print(" -p python name of the python executable") 150 print(" -p python name of the python executable")
144 print(" (default: {0})".format(macPythonExe)) 151 print(" (default: {0})".format(macPythonExe))
152 print(" -c don't cleanup old installation first")
145 print(" -x don't perform dependency checks (use on your own" 153 print(" -x don't perform dependency checks (use on your own"
146 " risk)") 154 " risk)")
147 print(" -c don't cleanup old installation first") 155 print(" -y add the Python variant to the executable names")
148 print(" -z don't compile the installed python files") 156 print(" -z don't compile the installed python files")
149 print() 157 print()
150 print("The file given to the -f option must be valid Python code" 158 print("The file given to the -f option must be valid Python code"
151 " defining a") 159 " defining a")
152 print("dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir'," 160 print("dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir',"
349 @param dirName name of the directory to prune (string) 357 @param dirName name of the directory to prune (string)
350 """ 358 """
351 # step 1: delete all Ui_*.py files without a corresponding 359 # step 1: delete all Ui_*.py files without a corresponding
352 # *.ui file 360 # *.ui file
353 dirListing = os.listdir(dirName) 361 dirListing = os.listdir(dirName)
354 for formName, sourceName in [(f.replace('Ui_',"").replace(".py",".ui"), f) 362 for formName, sourceName in [
355 for f in dirListing 363 (f.replace('Ui_', "").replace(".py", ".ui"), f)
356 if fnmatch.fnmatch(f, "Ui_*.py")]: 364 for f in dirListing if fnmatch.fnmatch(f, "Ui_*.py")]:
357 if not os.path.exists(os.path.join(dirName, formName)): 365 if not os.path.exists(os.path.join(dirName, formName)):
358 os.remove(os.path.join(dirName, sourceName)) 366 os.remove(os.path.join(dirName, sourceName))
359 if os.path.exists(os.path.join(dirName, sourceName + "c")): 367 if os.path.exists(os.path.join(dirName, sourceName + "c")):
360 os.remove(os.path.join(dirName, sourceName + "c")) 368 os.remove(os.path.join(dirName, sourceName + "c"))
361 369
374 382
375 def cleanUp(): 383 def cleanUp():
376 """ 384 """
377 Uninstall the old eric files. 385 Uninstall the old eric files.
378 """ 386 """
379 global macAppBundleName, macAppBundlePath, platBinDir 387 global macAppBundleName, macAppBundlePath, platBinDir, includePythonVariant
380 388
381 try: 389 try:
382 from eric5config import getConfig 390 from eric5config import getConfig
383 except ImportError: 391 except ImportError:
384 # eric5 wasn't installed previously 392 # eric5 wasn't installed previously
405 "eric5-unittest", "eric5", 413 "eric5-unittest", "eric5",
406 "eric5-tray", "eric5-editor", 414 "eric5-tray", "eric5-editor",
407 "eric5-plugininstall", "eric5-pluginuninstall", 415 "eric5-plugininstall", "eric5-pluginuninstall",
408 "eric5-pluginrepository", "eric5-sqlbrowser", 416 "eric5-pluginrepository", "eric5-sqlbrowser",
409 "eric5-webbrowser", "eric5-iconeditor", 417 "eric5-webbrowser", "eric5-iconeditor",
418 ]
419 rem_wnames2 = [
410 "eric5_api", "eric5_compare", 420 "eric5_api", "eric5_compare",
411 "eric5_configure", "eric5_diff", 421 "eric5_configure", "eric5_diff",
412 "eric5_doc", "eric5_qregularexpression", 422 "eric5_doc", "eric5_qregularexpression",
413 "eric5_qregexp", "eric5_re", 423 "eric5_qregexp", "eric5_re",
414 "eric5_trpreviewer", "eric5_uipreviewer", 424 "eric5_trpreviewer", "eric5_uipreviewer",
417 "eric5_plugininstall", "eric5_pluginuninstall", 427 "eric5_plugininstall", "eric5_pluginuninstall",
418 "eric5_pluginrepository", "eric5_sqlbrowser", 428 "eric5_pluginrepository", "eric5_sqlbrowser",
419 "eric5_webbrowser", "eric5_iconeditor", 429 "eric5_webbrowser", "eric5_iconeditor",
420 "eric5_snap", 430 "eric5_snap",
421 ] 431 ]
432 if includePythonVariant:
433 marker = PythonMarkers[sys.version_info.major]
434 rem_wnames.extend([n + marker for n in rem_wnames2])
435 else:
436 rem_wnames.extend(rem_wnames2)
422 437
423 try: 438 try:
424 for rem_wname in rem_wnames: 439 for rem_wname in rem_wnames:
425 for d in [platBinDir, getConfig('bindir')]: 440 for d in [platBinDir, getConfig('bindir')]:
426 rwname = wrapperName(d, rem_wname) 441 rwname = wrapperName(d, rem_wname)
478 if os.path.exists("/Applications/" + macAppBundleName): 493 if os.path.exists("/Applications/" + macAppBundleName):
479 shutil.rmtree("/Applications/" + macAppBundleName) 494 shutil.rmtree("/Applications/" + macAppBundleName)
480 bundlePath = os.path.join(macAppBundlePath, macAppBundleName) 495 bundlePath = os.path.join(macAppBundlePath, macAppBundleName)
481 if os.path.exists(bundlePath): 496 if os.path.exists(bundlePath):
482 shutil.rmtree(bundlePath) 497 shutil.rmtree(bundlePath)
483
484 except (IOError, OSError) as msg: 498 except (IOError, OSError) as msg:
485 sys.stderr.write( 499 sys.stderr.write(
486 'Error: {0}\nTry install with admin rights.\n'.format(msg)) 500 'Error: {0}\nTry install with admin rights.\n'.format(msg))
487 exit(7) 501 exit(7)
488 502
506 Actually perform the installation steps. 520 Actually perform the installation steps.
507 521
508 @return result code (integer) 522 @return result code (integer)
509 """ 523 """
510 global distDir, doCleanup, cfg, progLanguages, sourceDir, configName 524 global distDir, doCleanup, cfg, progLanguages, sourceDir, configName
525 global includePythonVariant
511 526
512 # Create the platform specific wrappers. 527 # Create the platform specific wrappers.
513 wnames = [] 528 wnames = []
514 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_api", False)) 529 if includePythonVariant:
515 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_compare")) 530 marker = PythonMarkers[sys.version_info.major]
516 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_configure")) 531 else:
517 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_diff")) 532 marker = ""
518 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_doc", False)) 533 wnames.append(createPyWrapper(cfg['ericDir'],
519 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_editor")) 534 "eric5_api" + marker,
520 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_iconeditor")) 535 False))
521 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_plugininstall")) 536 wnames.append(createPyWrapper(cfg['ericDir'],
522 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_pluginrepository")) 537 "eric5_compare" + marker))
523 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_pluginuninstall")) 538 wnames.append(createPyWrapper(cfg['ericDir'],
524 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_qregexp")) 539 "eric5_configure" + marker))
525 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_qregularexpression")) 540 wnames.append(createPyWrapper(cfg['ericDir'],
526 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_re")) 541 "eric5_diff" + marker))
527 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_snap")) 542 wnames.append(createPyWrapper(cfg['ericDir'],
528 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_sqlbrowser")) 543 "eric5_doc" + marker,
529 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_tray")) 544 False))
530 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_trpreviewer")) 545 wnames.append(createPyWrapper(cfg['ericDir'],
531 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_uipreviewer")) 546 "eric5_editor" + marker))
532 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_unittest")) 547 wnames.append(createPyWrapper(cfg['ericDir'],
533 wnames.append(createPyWrapper(cfg['ericDir'], "eric5_webbrowser")) 548 "eric5_iconeditor" + marker))
534 wnames.append(createPyWrapper(cfg['ericDir'], "eric5")) 549 wnames.append(createPyWrapper(cfg['ericDir'],
550 "eric5_plugininstall" + marker))
551 wnames.append(createPyWrapper(cfg['ericDir'],
552 "eric5_pluginrepository" + marker))
553 wnames.append(createPyWrapper(cfg['ericDir'],
554 "eric5_pluginuninstall" + marker))
555 wnames.append(createPyWrapper(cfg['ericDir'],
556 "eric5_qregexp" + marker))
557 wnames.append(createPyWrapper(cfg['ericDir'],
558 "eric5_qregularexpression" + marker))
559 wnames.append(createPyWrapper(cfg['ericDir'],
560 "eric5_re" + marker))
561 wnames.append(createPyWrapper(cfg['ericDir'],
562 "eric5_snap" + marker))
563 wnames.append(createPyWrapper(cfg['ericDir'],
564 "eric5_sqlbrowser" + marker))
565 wnames.append(createPyWrapper(cfg['ericDir'],
566 "eric5_tray" + marker))
567 wnames.append(createPyWrapper(cfg['ericDir'],
568 "eric5_trpreviewer" + marker))
569 wnames.append(createPyWrapper(cfg['ericDir'],
570 "eric5_uipreviewer" + marker))
571 wnames.append(createPyWrapper(cfg['ericDir'],
572 "eric5_unittest" + marker))
573 wnames.append(createPyWrapper(cfg['ericDir'],
574 "eric5_webbrowser" + marker))
575 wnames.append(createPyWrapper(cfg['ericDir'],
576 "eric5" + marker))
535 577
536 # set install prefix, if not None 578 # set install prefix, if not None
537 if distDir: 579 if distDir:
538 for key in list(cfg.keys()): 580 for key in list(cfg.keys()):
539 cfg[key] = os.path.normpath(distDir + os.sep + cfg[key]) 581 cfg[key] = os.path.normpath(distDir + os.sep + cfg[key])
1133 """ 1175 """
1134 import getopt 1176 import getopt
1135 1177
1136 # Parse the command line. 1178 # Parse the command line.
1137 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir 1179 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
1138 global sourceDir, configName 1180 global sourceDir, configName, includePythonVariant
1139 global macAppBundlePath, macAppBundleName, macPythonExe 1181 global macAppBundlePath, macAppBundleName, macPythonExe
1140 1182
1141 if sys.version_info < (2, 6, 0) or sys.version_info > (3, 9, 9): 1183 if sys.version_info < (2, 6, 0) or sys.version_info > (3, 9, 9):
1142 print('Sorry, eric5 requires at least Python 2.6 or ' 1184 print('Sorry, eric5 requires at least Python 2.6 or '
1143 'Python 3 for running.') 1185 'Python 3 for running.')
1150 1192
1151 initGlobals() 1193 initGlobals()
1152 1194
1153 try: 1195 try:
1154 if sys.platform.startswith("win"): 1196 if sys.platform.startswith("win"):
1155 optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:") 1197 optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:")
1156 elif sys.platform == "darwin": 1198 elif sys.platform == "darwin":
1157 optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:i:m:n:p:") 1199 optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:i:m:n:p:")
1158 else: 1200 else:
1159 optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:i:") 1201 optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:i:")
1160 except getopt.GetoptError: 1202 except getopt.GetoptError:
1161 usage() 1203 usage()
1162 1204
1163 global platBinDir 1205 global platBinDir
1164 1206
1179 depChecks = False 1221 depChecks = False
1180 elif opt == "-c": 1222 elif opt == "-c":
1181 doCleanup = False 1223 doCleanup = False
1182 elif opt == "-z": 1224 elif opt == "-z":
1183 doCompile = False 1225 doCompile = False
1226 elif opt == "-y":
1227 includePythonVariant = True
1184 elif opt == "-f": 1228 elif opt == "-f":
1185 try: 1229 try:
1186 exec(compile(open(arg).read(), arg, 'exec'), globals()) 1230 exec(compile(open(arg).read(), arg, 'exec'), globals())
1187 if len(cfg) != configLength: 1231 if len(cfg) != configLength:
1188 print("The configuration dictionary in '{0}' is incorrect." 1232 print("The configuration dictionary in '{0}' is incorrect."

eric ide

mercurial