install.py

changeset 2992
dbdf27746da5
parent 2969
0e1af1313b8b
child 3003
cb43c34239b1
equal deleted inserted replaced
2991:226481ff40d1 2992:dbdf27746da5
33 progLanguages = ["Python", "Ruby"] 33 progLanguages = ["Python", "Ruby"]
34 sourceDir = "eric" 34 sourceDir = "eric"
35 configName = 'eric5config.py' 35 configName = 'eric5config.py'
36 defaultMacAppBundleName = "eric5.app" 36 defaultMacAppBundleName = "eric5.app"
37 macAppBundleName = "eric5.app" 37 macAppBundleName = "eric5.app"
38 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(sys.exec_prefix) 38 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(
39 sys.exec_prefix)
39 40
40 # Define blacklisted versions of the prerequisites 41 # Define blacklisted versions of the prerequisites
41 BlackLists = { 42 BlackLists = {
42 "sip": ["4.11", "4.12.3"], 43 "sip": ["4.11", "4.12.3"],
43 "PyQt4": ["4.7.5"], 44 "PyQt4": ["4.7.5"],
91 global macPythonExe 92 global macPythonExe
92 93
93 print() 94 print()
94 print("Usage:") 95 print("Usage:")
95 if sys.platform == "darwin": 96 if sys.platform == "darwin":
96 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir] [-m name] [-p python]"\ 97 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
97 .format(progName)) 98 " [-m name] [-p python]".format(progName))
98 elif sys.platform.startswith("win"): 99 elif sys.platform.startswith("win"):
99 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"\ 100 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"\
100 .format(progName)) 101 .format(progName))
101 else: 102 else:
102 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"\ 103 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"\
110 print(" (no default value)") 111 print(" (no default value)")
111 print(" -b dir where the binaries will be installed") 112 print(" -b dir where the binaries will be installed")
112 print(" (default: {0})".format(platBinDir)) 113 print(" (default: {0})".format(platBinDir))
113 print(" -d dir where eric5 python files will be installed") 114 print(" -d dir where eric5 python files will be installed")
114 print(" (default: {0})".format(modDir)) 115 print(" (default: {0})".format(modDir))
115 print(" -f file configuration file naming the various installation paths") 116 print(" -f file configuration file naming the various installation"
117 " paths")
116 if not sys.platform.startswith("win"): 118 if not sys.platform.startswith("win"):
117 print(" -i dir temporary install prefix") 119 print(" -i dir temporary install prefix")
118 print(" (default: {0})".format(distDir)) 120 print(" (default: {0})".format(distDir))
119 if sys.platform == "darwin": 121 if sys.platform == "darwin":
120 print(" -m name name of the Mac app bundle") 122 print(" -m name name of the Mac app bundle")
121 print(" (default: {0})".format(macAppBundleName)) 123 print(" (default: {0})".format(macAppBundleName))
122 print(" -p python name of the python executable") 124 print(" -p python name of the python executable")
123 print(" (default: {0})".format(macPythonExe)) 125 print(" (default: {0})".format(macPythonExe))
124 print(" -x don't perform dependency checks (use on your own risk)") 126 print(" -x don't perform dependency checks (use on your own"
127 " risk)")
125 print(" -c don't cleanup old installation first") 128 print(" -c don't cleanup old installation first")
126 print(" -z don't compile the installed python files") 129 print(" -z don't compile the installed python files")
127 print() 130 print()
128 print("The file given to the -f option must be valid Python code defining a") 131 print("The file given to the -f option must be valid Python code"
129 print("dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir', 'ericIconDir',") 132 " defining a")
130 print("'ericDTDDir', 'ericCSSDir', 'ericStylesDir', 'ericDocDir', 'ericExamplesDir',") 133 print("dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir',"
134 " 'ericIconDir',")
135 print("'ericDTDDir', 'ericCSSDir', 'ericStylesDir', 'ericDocDir',"
136 " 'ericExamplesDir',")
131 print("'ericTranslationsDir', 'ericTemplatesDir', 'ericCodeTemplatesDir',") 137 print("'ericTranslationsDir', 'ericTemplatesDir', 'ericCodeTemplatesDir',")
132 print("'ericOthersDir','bindir', 'mdir' and 'apidir.") 138 print("'ericOthersDir','bindir', 'mdir' and 'apidir.")
133 print("These define the directories for the installation of the various parts of"\ 139 print("These define the directories for the installation of the various"
134 " eric5.") 140 " parts of eric5.")
135 141
136 exit(rcode) 142 exit(rcode)
137 143
138 144
139 def initGlobals(): 145 def initGlobals():
214 if isGuiScript: 220 if isGuiScript:
215 wrapper = \ 221 wrapper = \
216 '''@echo off\n''' \ 222 '''@echo off\n''' \
217 '''start "" "{2}\\pythonw.exe"''' \ 223 '''start "" "{2}\\pythonw.exe"''' \
218 ''' "{0}\\{1}.pyw"''' \ 224 ''' "{0}\\{1}.pyw"''' \
219 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(pydir, wfile, sys.exec_prefix) 225 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(
226 pydir, wfile, sys.exec_prefix)
220 else: 227 else:
221 wrapper = \ 228 wrapper = \
222 '''@"{0}\\python" "{1}\\{2}.py"''' \ 229 '''@"{0}\\python" "{1}\\{2}.py"''' \
223 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format( 230 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(
224 sys.exec_prefix, pydir, wfile) 231 sys.exec_prefix, pydir, wfile)
257 264
258 @param src name of the source directory 265 @param src name of the source directory
259 @param dst name of the destination directory 266 @param dst name of the destination directory
260 @param filters list of filter pattern determining the files to be copied 267 @param filters list of filter pattern determining the files to be copied
261 @param excludeDirs list of (sub)directories to exclude from copying 268 @param excludeDirs list of (sub)directories to exclude from copying
262 @keyparam excludePatterns list of filter pattern determining the files to be skipped 269 @keyparam excludePatterns list of filter pattern determining the files to
270 be skipped
263 """ 271 """
264 try: 272 try:
265 names = os.listdir(src) 273 names = os.listdir(src)
266 except OSError: 274 except OSError:
267 return # ignore missing directories (most probably the i18n directory) 275 # ignore missing directories (most probably the i18n directory)
276 return
268 277
269 for name in names: 278 for name in names:
270 skipIt = False 279 skipIt = False
271 for excludePattern in excludePatterns: 280 for excludePattern in excludePatterns:
272 if fnmatch.fnmatch(name, excludePattern): 281 if fnmatch.fnmatch(name, excludePattern):
282 shutil.copy2(srcname, dstname) 291 shutil.copy2(srcname, dstname)
283 os.chmod(dstname, 0o644) 292 os.chmod(dstname, 0o644)
284 break 293 break
285 else: 294 else:
286 if os.path.isdir(srcname) and not srcname in excludeDirs: 295 if os.path.isdir(srcname) and not srcname in excludeDirs:
287 copyTree(srcname, dstname, filters, excludePatterns=excludePatterns) 296 copyTree(srcname, dstname, filters,
297 excludePatterns=excludePatterns)
288 298
289 299
290 def createGlobalPluginsDir(): 300 def createGlobalPluginsDir():
291 """ 301 """
292 Create the global plugins directory, if it doesn't exist. 302 Create the global plugins directory, if it doesn't exist.
377 os.remove(f) 387 os.remove(f)
378 388
379 # Cleanup the install directories 389 # Cleanup the install directories
380 for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir', 390 for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir',
381 'ericIconDir', 'ericPixDir', 'ericTemplatesDir', 391 'ericIconDir', 'ericPixDir', 'ericTemplatesDir',
382 'ericCodeTemplatesDir', 'ericOthersDir', 'ericStylesDir', 'ericDir']: 392 'ericCodeTemplatesDir', 'ericOthersDir', 'ericStylesDir',
393 'ericDir']:
383 if os.path.exists(getConfig(name)): 394 if os.path.exists(getConfig(name)):
384 shutil.rmtree(getConfig(name), True) 395 shutil.rmtree(getConfig(name), True)
385 396
386 # Cleanup translations 397 # Cleanup translations
387 for name in glob.glob( 398 for name in glob.glob(
409 shutil.rmtree("/Developer/Applications/Eric5") 420 shutil.rmtree("/Developer/Applications/Eric5")
410 if os.path.exists("/Applications/" + macAppBundleName): 421 if os.path.exists("/Applications/" + macAppBundleName):
411 shutil.rmtree("/Applications/" + macAppBundleName) 422 shutil.rmtree("/Applications/" + macAppBundleName)
412 423
413 except (IOError, OSError) as msg: 424 except (IOError, OSError) as msg:
414 sys.stderr.write('Error: {0}\nTry install with admin rights.\n'.format(msg)) 425 sys.stderr.write(
426 'Error: {0}\nTry install with admin rights.\n'.format(msg))
415 exit(7) 427 exit(7)
416 428
417 429
418 def shutilCopy(src, dst, perm=0o644): 430 def shutilCopy(src, dst, perm=0o644):
419 """ 431 """
490 copyTree(sourceDir, cfg['ericDir'], ['*.rb'], 502 copyTree(sourceDir, cfg['ericDir'], ['*.rb'],
491 ['{1}{0}Examples'.format(os.sep, sourceDir)]) 503 ['{1}{0}Examples'.format(os.sep, sourceDir)])
492 copyTree('{1}{0}Plugins'.format(os.sep, sourceDir), 504 copyTree('{1}{0}Plugins'.format(os.sep, sourceDir),
493 '{0}{1}Plugins'.format(cfg['ericDir'], os.sep), 505 '{0}{1}Plugins'.format(cfg['ericDir'], os.sep),
494 ['*.png', '*.style']) 506 ['*.png', '*.style'])
495 copyTree('{1}{0}Documentation'.format(os.sep, sourceDir), cfg['ericDocDir'], 507 copyTree(
508 '{1}{0}Documentation'.format(os.sep, sourceDir), cfg['ericDocDir'],
496 ['*.html', '*.qch']) 509 ['*.html', '*.qch'])
497 copyTree('{1}{0}DTDs'.format(os.sep, sourceDir), cfg['ericDTDDir'], 510 copyTree('{1}{0}DTDs'.format(os.sep, sourceDir), cfg['ericDTDDir'],
498 ['*.dtd']) 511 ['*.dtd'])
499 copyTree('{1}{0}CSSs'.format(os.sep, sourceDir), cfg['ericCSSDir'], 512 copyTree('{1}{0}CSSs'.format(os.sep, sourceDir), cfg['ericCSSDir'],
500 ['*.css']) 513 ['*.css'])
501 copyTree('{1}{0}Styles'.format(os.sep, sourceDir), cfg['ericStylesDir'], 514 copyTree(
515 '{1}{0}Styles'.format(os.sep, sourceDir), cfg['ericStylesDir'],
502 ['*.qss']) 516 ['*.qss'])
503 copyTree('{1}{0}i18n'.format(os.sep, sourceDir), cfg['ericTranslationsDir'], 517 copyTree(
518 '{1}{0}i18n'.format(os.sep, sourceDir), cfg['ericTranslationsDir'],
504 ['*.qm']) 519 ['*.qm'])
505 copyTree('{1}{0}icons'.format(os.sep, sourceDir), cfg['ericIconDir'], 520 copyTree('{1}{0}icons'.format(os.sep, sourceDir), cfg['ericIconDir'],
506 ['*.png', 'LICENSE*.*', 'readme.txt']) 521 ['*.png', 'LICENSE*.*', 'readme.txt'])
507 copyTree('{1}{0}pixmaps'.format(os.sep, sourceDir), cfg['ericPixDir'], 522 copyTree('{1}{0}pixmaps'.format(os.sep, sourceDir), cfg['ericPixDir'],
508 ['*.png', '*.xpm', '*.ico', '*.gif']) 523 ['*.png', '*.xpm', '*.ico', '*.gif'])
510 cfg['ericTemplatesDir'], 525 cfg['ericTemplatesDir'],
511 ['*.tmpl']) 526 ['*.tmpl'])
512 copyTree('{1}{0}CodeTemplates'.format(os.sep, sourceDir), 527 copyTree('{1}{0}CodeTemplates'.format(os.sep, sourceDir),
513 cfg['ericCodeTemplatesDir'], 528 cfg['ericCodeTemplatesDir'],
514 ['*.tmpl']) 529 ['*.tmpl'])
515 copyTree('{1}{0}Examples'.format(os.sep, sourceDir), cfg['ericExamplesDir'], 530 copyTree(
531 '{1}{0}Examples'.format(os.sep, sourceDir), cfg['ericExamplesDir'],
516 ['*.py', '*.pyc', '*.pyo']) 532 ['*.py', '*.pyc', '*.pyo'])
517 533
518 # copy the wrappers 534 # copy the wrappers
519 for wname in wnames: 535 for wname in wnames:
520 shutilCopy(wname, cfg['bindir'], perm=0o755) 536 shutilCopy(wname, cfg['bindir'], perm=0o755)
521 os.remove(wname) 537 os.remove(wname)
522 538
523 # copy the license file 539 # copy the license file
524 shutilCopy('{1}{0}LICENSE.GPL3'.format(os.sep, sourceDir), cfg['ericDir']) 540 shutilCopy(
541 '{1}{0}LICENSE.GPL3'.format(os.sep, sourceDir), cfg['ericDir'])
525 542
526 # create the global plugins directory 543 # create the global plugins directory
527 createGlobalPluginsDir() 544 createGlobalPluginsDir()
528 545
529 except (IOError, OSError) as msg: 546 except (IOError, OSError) as msg:
530 sys.stderr.write('Error: {0}\nTry install with admin rights.\n'.format(msg)) 547 sys.stderr.write(
548 'Error: {0}\nTry install with admin rights.\n'.format(msg))
531 return(7) 549 return(7)
532 550
533 # copy some text files to the doc area 551 # copy some text files to the doc area
534 for name in ["LICENSE.GPL3", "THANKS", "changelog"]: 552 for name in ["LICENSE.GPL3", "THANKS", "changelog"]:
535 try: 553 try:
536 shutilCopy('{2}{0}{1}'.format(os.sep, name, sourceDir), cfg['ericDocDir']) 554 shutilCopy(
555 '{2}{0}{1}'.format(os.sep, name, sourceDir), cfg['ericDocDir'])
537 except EnvironmentError: 556 except EnvironmentError:
538 print("Could not install '{2}{0}{1}'.".format(os.sep, name, sourceDir)) 557 print("Could not install '{2}{0}{1}'.".format(
558 os.sep, name, sourceDir))
539 for name in glob.glob(os.path.join(sourceDir, 'README*.*')): 559 for name in glob.glob(os.path.join(sourceDir, 'README*.*')):
540 try: 560 try:
541 shutilCopy(name, cfg['ericDocDir']) 561 shutilCopy(name, cfg['ericDocDir'])
542 except EnvironmentError: 562 except EnvironmentError:
543 print("Could not install '{1}'.".format(name)) 563 print("Could not install '{1}'.".format(name))
544 564
545 # copy some more stuff 565 # copy some more stuff
546 for name in ['default.e4k', 'default_Mac.e4k']: 566 for name in ['default.e4k', 'default_Mac.e4k']:
547 try: 567 try:
548 shutilCopy('{2}{0}{1}'.format(os.sep, name, sourceDir), cfg['ericOthersDir']) 568 shutilCopy(
569 '{2}{0}{1}'.format(os.sep, name, sourceDir),
570 cfg['ericOthersDir'])
549 except EnvironmentError: 571 except EnvironmentError:
550 print("Could not install '{2}{0}{1}'.".format(os.sep, name, sourceDir)) 572 print("Could not install '{2}{0}{1}'.".format(
573 os.sep, name, sourceDir))
551 574
552 # install the API file 575 # install the API file
553 for progLanguage in progLanguages: 576 for progLanguage in progLanguages:
554 apidir = os.path.join(cfg['apidir'], progLanguage.lower()) 577 apidir = os.path.join(cfg['apidir'], progLanguage.lower())
555 if not os.path.exists(apidir): 578 if not os.path.exists(apidir):
556 os.makedirs(apidir) 579 os.makedirs(apidir)
557 for apiName in glob.glob(os.path.join(sourceDir, "APIs", progLanguage, "*.api")): 580 for apiName in glob.glob(os.path.join(sourceDir, "APIs",
581 progLanguage, "*.api")):
558 try: 582 try:
559 shutilCopy(apiName, apidir) 583 shutilCopy(apiName, apidir)
560 except EnvironmentError: 584 except EnvironmentError:
561 print("Could not install '{0}'.".format(apiName)) 585 print("Could not install '{0}'.".format(apiName))
562 for apiName in glob.glob(os.path.join(sourceDir, "APIs", progLanguage, "*.bas")): 586 for apiName in glob.glob(os.path.join(sourceDir, "APIs",
587 progLanguage, "*.bas")):
563 try: 588 try:
564 shutilCopy(apiName, apidir) 589 shutilCopy(apiName, apidir)
565 except EnvironmentError: 590 except EnvironmentError:
566 print("Could not install '{0}'.".format(apiName)) 591 print("Could not install '{0}'.".format(apiName))
567 if progLanguage == "Python": 592 if progLanguage == "Python":
568 # copy Python3 API files to the same destination 593 # copy Python3 API files to the same destination
569 for apiName in glob.glob(os.path.join(sourceDir, "APIs", "Python3", "*.api")): 594 for apiName in glob.glob(os.path.join(sourceDir, "APIs",
595 "Python3", "*.api")):
570 try: 596 try:
571 shutilCopy(apiName, apidir) 597 shutilCopy(apiName, apidir)
572 except EnvironmentError: 598 except EnvironmentError:
573 print("Could not install '{0}'.".format(apiName)) 599 print("Could not install '{0}'.".format(apiName))
574 for apiName in glob.glob(os.path.join(sourceDir, "APIs", "Python3", "*.bas")): 600 for apiName in glob.glob(os.path.join(sourceDir, "APIs",
601 "Python3", "*.bas")):
575 try: 602 try:
576 shutilCopy(apiName, apidir) 603 shutilCopy(apiName, apidir)
577 except EnvironmentError: 604 except EnvironmentError:
578 print("Could not install '{0}'.".format(apiName)) 605 print("Could not install '{0}'.".format(apiName))
579 606
583 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps")) 610 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps"))
584 if not os.path.exists(dst): 611 if not os.path.exists(dst):
585 os.makedirs(dst) 612 os.makedirs(dst)
586 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric.png"), 613 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric.png"),
587 os.path.join(dst, "eric.png")) 614 os.path.join(dst, "eric.png"))
588 dst = os.path.normpath(os.path.join(distDir, "usr/share/applications")) 615 dst = os.path.normpath(
616 os.path.join(distDir, "usr/share/applications"))
589 if not os.path.exists(dst): 617 if not os.path.exists(dst):
590 os.makedirs(dst) 618 os.makedirs(dst)
591 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), dst) 619 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), dst)
592 else: 620 else:
593 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric.png"), 621 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric.png"),
594 "/usr/share/pixmaps/eric.png") 622 "/usr/share/pixmaps/eric.png")
595 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), 623 shutilCopy(os.path.join(sourceDir, "eric5.desktop"),
596 "/usr/share/applications") 624 "/usr/share/applications")
597 shutilCopy(os.path.join(sourceDir, "icons", "default", "ericWeb48.png"), 625 shutilCopy(
626 os.path.join(sourceDir, "icons", "default", "ericWeb48.png"),
598 "/usr/share/pixmaps/ericWeb.png") 627 "/usr/share/pixmaps/ericWeb.png")
599 shutilCopy(os.path.join(sourceDir, "eric5_webbrowser.desktop"), 628 shutilCopy(os.path.join(sourceDir, "eric5_webbrowser.desktop"),
600 "/usr/share/applications") 629 "/usr/share/applications")
601 630
602 # Create a Mac application bundle 631 # Create a Mac application bundle
608 637
609 def createMacAppBundle(pydir): 638 def createMacAppBundle(pydir):
610 """ 639 """
611 Create a Mac application bundle. 640 Create a Mac application bundle.
612 641
613 @param pydir the name of the directory where the Python script will eventually 642 @param pydir the name of the directory where the Python script will
614 be installed (string) 643 eventually be installed (string)
615 """ 644 """
616 global cfg, sourceDir, macAppBundleName, macPythonExe 645 global cfg, sourceDir, macAppBundleName, macPythonExe
617 646
618 dirs = {"contents": "/Applications/{0}/Contents/".format(macAppBundleName), 647 dirs = {"contents": "/Applications/{0}/Contents/".format(macAppBundleName),
619 "exe": "/Applications/{0}/Contents/MacOS".format(macAppBundleName), 648 "exe": "/Applications/{0}/Contents/MacOS".format(macAppBundleName),
620 "icns": "/Applications/{0}/Contents/Resources".format(macAppBundleName)} 649 "icns": "/Applications/{0}/Contents/Resources".format(
650 macAppBundleName)}
621 os.makedirs(dirs["contents"]) 651 os.makedirs(dirs["contents"])
622 os.mkdir(dirs["exe"]) 652 os.mkdir(dirs["exe"])
623 os.mkdir(dirs["icns"]) 653 os.mkdir(dirs["icns"])
624 654
625 if macAppBundleName == defaultMacAppBundleName: 655 if macAppBundleName == defaultMacAppBundleName:
718 """ 748 """
719 global cfg, sourceDir 749 global cfg, sourceDir
720 750
721 apis = [] 751 apis = []
722 for progLanguage in progLanguages: 752 for progLanguage in progLanguages:
723 for apiName in glob.glob(os.path.join(sourceDir, "APIs", progLanguage, "*.api")): 753 for apiName in glob.glob(
754 os.path.join(sourceDir, "APIs", progLanguage, "*.api")):
724 apis.append(os.path.basename(apiName)) 755 apis.append(os.path.basename(apiName))
725 if progLanguage == "Python": 756 if progLanguage == "Python":
726 # treat Python3 API files the same as Python API files 757 # treat Python3 API files the same as Python API files
727 for apiName in glob.glob(os.path.join(sourceDir, "APIs", "Python3", "*.api")): 758 for apiName in glob.glob(
759 os.path.join(sourceDir, "APIs", "Python3", "*.api")):
728 apis.append(os.path.basename(apiName)) 760 apis.append(os.path.basename(apiName))
729 761
730 fn = 'eric5config.py' 762 fn = 'eric5config.py'
731 config = \ 763 config = \
732 """# -*- coding: utf-8 -*- 764 """# -*- coding: utf-8 -*-
762 try: 794 try:
763 return _pkg_config[name] 795 return _pkg_config[name]
764 except KeyError: 796 except KeyError:
765 pass 797 pass
766 798
767 raise AttributeError('"{{0}}" is not a valid configuration value'.format(name)) 799 raise AttributeError('"{{0}}" is not a valid configuration value'.format(
800 name))
768 """.format(cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'], 801 """.format(cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'],
769 cfg['ericDTDDir'], cfg['ericCSSDir'], 802 cfg['ericDTDDir'], cfg['ericCSSDir'],
770 cfg['ericStylesDir'], cfg['ericDocDir'], 803 cfg['ericStylesDir'], cfg['ericDocDir'],
771 cfg['ericExamplesDir'], cfg['ericTranslationsDir'], 804 cfg['ericExamplesDir'], cfg['ericTranslationsDir'],
772 cfg['ericTemplatesDir'], 805 cfg['ericTemplatesDir'],
854 # always assume, that snapshots are new enough 887 # always assume, that snapshots are new enough
855 if "snapshot" not in sipVersion: 888 if "snapshot" not in sipVersion:
856 # check for blacklisted versions 889 # check for blacklisted versions
857 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]: 890 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]:
858 if vers == sipVersion: 891 if vers == sipVersion:
859 print('Sorry, sip version {0} is not compatible with eric5.'\ 892 print(
860 .format(vers)) 893 'Sorry, sip version {0} is not compatible with eric5.'
894 .format(vers))
861 print('Please install another version.') 895 print('Please install another version.')
862 exit(3) 896 exit(3)
863 except ImportError: 897 except ImportError:
864 pass 898 pass
865 899
901 if maj < 2 or (maj == 2 and min < 6): 935 if maj < 2 or (maj == 2 and min < 6):
902 print('Sorry, you must have QScintilla 2.6.0 or higher or' \ 936 print('Sorry, you must have QScintilla 2.6.0 or higher or' \
903 ' a recent snapshot release.') 937 ' a recent snapshot release.')
904 exit(5) 938 exit(5)
905 # check for blacklisted versions 939 # check for blacklisted versions
906 for vers in BlackLists["QScintilla2"] + PlatformBlackLists["QScintilla2"]: 940 for vers in BlackLists["QScintilla2"] + \
941 PlatformBlackLists["QScintilla2"]:
907 if vers == scintillaVersion: 942 if vers == scintillaVersion:
908 print('Sorry, QScintilla2 version {0} is not compatible with eric5.'\ 943 print(
909 .format(vers)) 944 'Sorry, QScintilla2 version {0} is not compatible with'
945 ' eric5.'.format(vers))
910 print('Please install another version.') 946 print('Please install another version.')
911 exit(5) 947 exit(5)
912 print("QScintilla Version: ", QSCINTILLA_VERSION_STR) 948 print("QScintilla Version: ", QSCINTILLA_VERSION_STR)
913 print("All dependencies ok.") 949 print("All dependencies ok.")
914 print() 950 print()
928 map=None, **compileUi_args): 964 map=None, **compileUi_args):
929 """ 965 """
930 Creates Python modules from Qt Designer .ui files in a directory or 966 Creates Python modules from Qt Designer .ui files in a directory or
931 directory tree. 967 directory tree.
932 968
933 Note: This function is a modified version of the one found in PyQt4. 969 Note: This function is a modified version of the one found in
934 970 PyQt4.
935 @param dir Name of the directory to scan for files whose name ends with 971
936 '.ui'. By default the generated Python module is created in the same 972 @param dir Name of the directory to scan for files whose name ends
937 directory ending with '.py'. 973 with '.ui'. By default the generated Python module is created
938 @param recurse flag indicating that any sub-directories should be scanned. 974 in the same directory ending with '.py'.
939 @param map an optional callable that is passed the name of the directory 975 @param recurse flag indicating that any sub-directories should be
940 containing the '.ui' file and the name of the Python module that will be 976 scanned.
941 created. The callable should return a tuple of the name of the directory 977 @param map an optional callable that is passed the name of the
942 in which the Python module will be created and the (possibly modified) 978 directory containing the '.ui' file and the name of the Python
943 name of the module. 979 module that will be created. The callable should return a
944 @param compileUi_args any additional keyword arguments that are passed to 980 tuple of the name of the directory in which the Python module
945 the compileUi() function that is called to create each Python module. 981 will be created and the (possibly modified) name of the module.
982 @param compileUi_args any additional keyword arguments that are
983 passed to the compileUi() function that is called to create
984 each Python module.
946 """ 985 """
947 def compile_ui(ui_dir, ui_file): 986 def compile_ui(ui_dir, ui_file):
948 """ 987 """
949 Local function to compile a single .ui file. 988 Local function to compile a single .ui file.
950 989
954 # Ignore if it doesn't seem to be a .ui file. 993 # Ignore if it doesn't seem to be a .ui file.
955 if ui_file.endswith('.ui'): 994 if ui_file.endswith('.ui'):
956 py_dir = ui_dir 995 py_dir = ui_dir
957 py_file = ui_file[:-3] + '.py' 996 py_file = ui_file[:-3] + '.py'
958 997
959 # Allow the caller to change the name of the .py file or generate 998 # Allow the caller to change the name of the .py file or
960 # it in a different directory. 999 # generate it in a different directory.
961 if map is not None: 1000 if map is not None:
962 py_dir, py_file = list(map(py_dir, py_file)) 1001 py_dir, py_file = list(map(py_dir, py_file))
963 1002
964 # Make sure the destination directory exists. 1003 # Make sure the destination directory exists.
965 try: 1004 try:
988 if os.path.isfile(os.path.join(dir, ui)): 1027 if os.path.isfile(os.path.join(dir, ui)):
989 compile_ui(dir, ui) 1028 compile_ui(dir, ui)
990 1029
991 def pyName(py_dir, py_file): 1030 def pyName(py_dir, py_file):
992 """ 1031 """
993 Local function to create the Python source file name for the compiled .ui file. 1032 Local function to create the Python source file name for the compiled
1033 .ui file.
994 1034
995 @param py_dir suggested name of the directory (string) 1035 @param py_dir suggested name of the directory (string)
996 @param py_file suggested name for the compile source file (string) 1036 @param py_file suggested name for the compile source file (string)
997 @return tuple of directory name (string) and source file name (string) 1037 @return tuple of directory name (string) and source file name (string)
998 """ 1038 """
1119 if doCompile: 1159 if doCompile:
1120 print("\nCompiling source files ...") 1160 print("\nCompiling source files ...")
1121 if distDir: 1161 if distDir:
1122 compileall.compile_dir(sourceDir, 1162 compileall.compile_dir(sourceDir,
1123 ddir=os.path.join(distDir, modDir, cfg['ericDir']), 1163 ddir=os.path.join(distDir, modDir, cfg['ericDir']),
1124 rx=re.compile(r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"), 1164 rx=re.compile(
1165 r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"),
1125 quiet=True) 1166 quiet=True)
1126 py_compile.compile(configName, 1167 py_compile.compile(
1127 dfile=os.path.join(distDir, modDir, "eric5config.py")) 1168 configName,
1169 dfile=os.path.join(distDir, modDir, "eric5config.py"))
1128 else: 1170 else:
1129 compileall.compile_dir(sourceDir, 1171 compileall.compile_dir(sourceDir,
1130 ddir=os.path.join(modDir, cfg['ericDir']), 1172 ddir=os.path.join(modDir, cfg['ericDir']),
1131 rx=re.compile(r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"), 1173 rx=re.compile(
1174 r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"),
1132 quiet=True) 1175 quiet=True)
1133 py_compile.compile(configName, 1176 py_compile.compile(configName,
1134 dfile=os.path.join(modDir, "eric5config.py")) 1177 dfile=os.path.join(modDir, "eric5config.py"))
1135 print("\nInstalling eric5 ...") 1178 print("\nInstalling eric5 ...")
1136 res = installEric() 1179 res = installEric()

eric ide

mercurial