install.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2846
b852fe4d153a
parent 3003
cb43c34239b1
child 3058
0a02c433f52d
equal deleted inserted replaced
3056:9986ec0e559a 3057:10516539f238
45 progLanguages = ["Python", "Ruby"] 45 progLanguages = ["Python", "Ruby"]
46 sourceDir = "eric" 46 sourceDir = "eric"
47 configName = 'eric5config.py' 47 configName = 'eric5config.py'
48 defaultMacAppBundleName = "eric5.app" 48 defaultMacAppBundleName = "eric5.app"
49 macAppBundleName = "eric5.app" 49 macAppBundleName = "eric5.app"
50 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(sys.exec_prefix) 50 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(
51 sys.exec_prefix)
51 52
52 # Define blacklisted versions of the prerequisites 53 # Define blacklisted versions of the prerequisites
53 BlackLists = { 54 BlackLists = {
54 "sip": ["4.11", "4.12.3"], 55 "sip": ["4.11", "4.12.3"],
55 "PyQt4": ["4.7.5"], 56 "PyQt4": ["4.7.5"],
104 global macPythonExe 105 global macPythonExe
105 106
106 print() 107 print()
107 print("Usage:") 108 print("Usage:")
108 if sys.platform == "darwin": 109 if sys.platform == "darwin":
109 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir] [-m name] [-p python]"\ 110 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
110 .format(progName)) 111 " [-m name] [-p python]".format(progName))
111 elif sys.platform.startswith("win"): 112 elif sys.platform.startswith("win"):
112 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"\ 113 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"\
113 .format(progName)) 114 .format(progName))
114 else: 115 else:
115 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"\ 116 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"\
123 print(" (no default value)") 124 print(" (no default value)")
124 print(" -b dir where the binaries will be installed") 125 print(" -b dir where the binaries will be installed")
125 print(" (default: {0})".format(platBinDir)) 126 print(" (default: {0})".format(platBinDir))
126 print(" -d dir where eric5 python files will be installed") 127 print(" -d dir where eric5 python files will be installed")
127 print(" (default: {0})".format(modDir)) 128 print(" (default: {0})".format(modDir))
128 print(" -f file configuration file naming the various installation paths") 129 print(" -f file configuration file naming the various installation"
130 " paths")
129 if not sys.platform.startswith("win"): 131 if not sys.platform.startswith("win"):
130 print(" -i dir temporary install prefix") 132 print(" -i dir temporary install prefix")
131 print(" (default: {0})".format(distDir)) 133 print(" (default: {0})".format(distDir))
132 if sys.platform == "darwin": 134 if sys.platform == "darwin":
133 print(" -m name name of the Mac app bundle") 135 print(" -m name name of the Mac app bundle")
134 print(" (default: {0})".format(macAppBundleName)) 136 print(" (default: {0})".format(macAppBundleName))
135 print(" -p python name of the python executable") 137 print(" -p python name of the python executable")
136 print(" (default: {0})".format(macPythonExe)) 138 print(" (default: {0})".format(macPythonExe))
137 print(" -x don't perform dependency checks (use on your own risk)") 139 print(" -x don't perform dependency checks (use on your own"
140 " risk)")
138 print(" -c don't cleanup old installation first") 141 print(" -c don't cleanup old installation first")
139 print(" -z don't compile the installed python files") 142 print(" -z don't compile the installed python files")
140 print() 143 print()
141 print("The file given to the -f option must be valid Python code defining a") 144 print("The file given to the -f option must be valid Python code"
142 print("dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir', 'ericIconDir',") 145 " defining a")
143 print("'ericDTDDir', 'ericCSSDir', 'ericStylesDir', 'ericDocDir', 'ericExamplesDir',") 146 print("dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir',"
147 " 'ericIconDir',")
148 print("'ericDTDDir', 'ericCSSDir', 'ericStylesDir', 'ericDocDir',"
149 " 'ericExamplesDir',")
144 print("'ericTranslationsDir', 'ericTemplatesDir', 'ericCodeTemplatesDir',") 150 print("'ericTranslationsDir', 'ericTemplatesDir', 'ericCodeTemplatesDir',")
145 print("'ericOthersDir','bindir', 'mdir' and 'apidir.") 151 print("'ericOthersDir','bindir', 'mdir' and 'apidir.")
146 print("These define the directories for the installation of the various parts of"\ 152 print("These define the directories for the installation of the various"
147 " eric5.") 153 " parts of eric5.")
148 154
149 exit(rcode) 155 exit(rcode)
150 156
151 157
152 def initGlobals(): 158 def initGlobals():
153 """ 159 """
154 Sets the values of globals that need more than a simple assignment. 160 Module function to set the values of globals that need more than a
161 simple assignment.
155 """ 162 """
156 global platBinDir, modDir, pyModDir, apisDir 163 global platBinDir, modDir, pyModDir, apisDir
157 164
158 if sys.platform.startswith("win"): 165 if sys.platform.startswith("win"):
159 platBinDir = sys.exec_prefix 166 platBinDir = sys.exec_prefix
228 if isGuiScript: 235 if isGuiScript:
229 wrapper = \ 236 wrapper = \
230 '''@echo off\n''' \ 237 '''@echo off\n''' \
231 '''start "" "{2}\\pythonw.exe"''' \ 238 '''start "" "{2}\\pythonw.exe"''' \
232 ''' "{0}\\{1}.pyw"''' \ 239 ''' "{0}\\{1}.pyw"''' \
233 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(pydir, wfile, sys.exec_prefix) 240 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(
241 pydir, wfile, sys.exec_prefix)
234 else: 242 else:
235 wrapper = \ 243 wrapper = \
236 '''@"{0}\\python" "{1}\\{2}.py"''' \ 244 '''@"{0}\\python" "{1}\\{2}.py"''' \
237 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format( 245 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(
238 sys.exec_prefix, pydir, wfile) 246 sys.exec_prefix, pydir, wfile)
271 279
272 @param src name of the source directory 280 @param src name of the source directory
273 @param dst name of the destination directory 281 @param dst name of the destination directory
274 @param filters list of filter pattern determining the files to be copied 282 @param filters list of filter pattern determining the files to be copied
275 @param excludeDirs list of (sub)directories to exclude from copying 283 @param excludeDirs list of (sub)directories to exclude from copying
276 @keyparam excludePatterns list of filter pattern determining the files to be skipped 284 @keyparam excludePatterns list of filter pattern determining the files to
285 be skipped
277 """ 286 """
278 try: 287 try:
279 names = os.listdir(src) 288 names = os.listdir(src)
280 except OSError: 289 except OSError:
281 return # ignore missing directories (most probably the i18n directory) 290 # ignore missing directories (most probably the i18n directory)
291 return
282 292
283 for name in names: 293 for name in names:
284 skipIt = False 294 skipIt = False
285 for excludePattern in excludePatterns: 295 for excludePattern in excludePatterns:
286 if fnmatch.fnmatch(name, excludePattern): 296 if fnmatch.fnmatch(name, excludePattern):
296 shutil.copy2(srcname, dstname) 306 shutil.copy2(srcname, dstname)
297 os.chmod(dstname, 0o644) 307 os.chmod(dstname, 0o644)
298 break 308 break
299 else: 309 else:
300 if os.path.isdir(srcname) and not srcname in excludeDirs: 310 if os.path.isdir(srcname) and not srcname in excludeDirs:
301 copyTree(srcname, dstname, filters, excludePatterns=excludePatterns) 311 copyTree(srcname, dstname, filters,
312 excludePatterns=excludePatterns)
302 313
303 314
304 def createGlobalPluginsDir(): 315 def createGlobalPluginsDir():
305 """ 316 """
306 Create the global plugins directory, if it doesn't exist. 317 Create the global plugins directory, if it doesn't exist.
389 path, ext = os.path.splitext(e5cfile) 400 path, ext = os.path.splitext(e5cfile)
390 for f in glob.glob("{0}.*{1}".format(path, ext)): 401 for f in glob.glob("{0}.*{1}".format(path, ext)):
391 os.remove(f) 402 os.remove(f)
392 403
393 # Cleanup the install directories 404 # Cleanup the install directories
394 for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir', 'ericCSSDir', 405 for name in ['ericExamplesDir', 'ericDocDir', 'ericDTDDir',
395 'ericIconDir', 'ericPixDir', 'ericTemplatesDir', 406 'ericCSSDir', 'ericIconDir', 'ericPixDir',
396 'ericCodeTemplatesDir', 'ericOthersDir', 'ericStylesDir', 'ericDir']: 407 'ericTemplatesDir', 'ericCodeTemplatesDir',
408 'ericOthersDir', 'ericStylesDir', 'ericDir']:
397 if os.path.exists(getConfig(name)): 409 if os.path.exists(getConfig(name)):
398 shutil.rmtree(getConfig(name), True) 410 shutil.rmtree(getConfig(name), True)
399 411
400 # Cleanup translations 412 # Cleanup translations
401 for name in glob.glob( 413 for name in glob.glob(
423 shutil.rmtree("/Developer/Applications/Eric5") 435 shutil.rmtree("/Developer/Applications/Eric5")
424 if os.path.exists("/Applications/" + macAppBundleName): 436 if os.path.exists("/Applications/" + macAppBundleName):
425 shutil.rmtree("/Applications/" + macAppBundleName) 437 shutil.rmtree("/Applications/" + macAppBundleName)
426 438
427 except (IOError, OSError) as msg: 439 except (IOError, OSError) as msg:
428 sys.stderr.write('Error: {0}\nTry install with admin rights.\n'.format(msg)) 440 sys.stderr.write(
441 'Error: {0}\nTry install with admin rights.\n'.format(msg))
429 exit(7) 442 exit(7)
430 443
431 444
432 def shutilCopy(src, dst, perm=0o644): 445 def shutilCopy(src, dst, perm=0o644):
433 """ 446 """
496 shutilCopy(configName, modDir) 509 shutilCopy(configName, modDir)
497 if os.path.exists(configName + 'c'): 510 if os.path.exists(configName + 'c'):
498 shutilCopy(configName + 'c', modDir) 511 shutilCopy(configName + 'c', modDir)
499 512
500 # copy the various parts of eric5 513 # copy the various parts of eric5
501 copyTree(sourceDir, cfg['ericDir'], ['*.py', '*.pyc', '*.pyo', '*.pyw'], 514 copyTree(sourceDir, cfg['ericDir'],
515 ['*.py', '*.pyc', '*.pyo', '*.pyw'],
502 ['{1}{0}Examples'.format(os.sep, sourceDir)], 516 ['{1}{0}Examples'.format(os.sep, sourceDir)],
503 excludePatterns=["eric5config.py*"]) 517 excludePatterns=["eric5config.py*"])
504 copyTree(sourceDir, cfg['ericDir'], ['*.rb'], 518 copyTree(sourceDir, cfg['ericDir'], ['*.rb'],
505 ['{1}{0}Examples'.format(os.sep, sourceDir)]) 519 ['{1}{0}Examples'.format(os.sep, sourceDir)])
506 copyTree('{1}{0}Plugins'.format(os.sep, sourceDir), 520 copyTree('{1}{0}Plugins'.format(os.sep, sourceDir),
507 '{0}{1}Plugins'.format(cfg['ericDir'], os.sep), 521 '{0}{1}Plugins'.format(cfg['ericDir'], os.sep),
508 ['*.png', '*.style']) 522 ['*.png', '*.style'])
509 copyTree('{1}{0}Documentation'.format(os.sep, sourceDir), cfg['ericDocDir'], 523 copyTree(
524 '{1}{0}Documentation'.format(os.sep, sourceDir), cfg['ericDocDir'],
510 ['*.html', '*.qch']) 525 ['*.html', '*.qch'])
511 copyTree('{1}{0}DTDs'.format(os.sep, sourceDir), cfg['ericDTDDir'], 526 copyTree('{1}{0}DTDs'.format(os.sep, sourceDir), cfg['ericDTDDir'],
512 ['*.dtd']) 527 ['*.dtd'])
513 copyTree('{1}{0}CSSs'.format(os.sep, sourceDir), cfg['ericCSSDir'], 528 copyTree('{1}{0}CSSs'.format(os.sep, sourceDir), cfg['ericCSSDir'],
514 ['*.css']) 529 ['*.css'])
515 copyTree('{1}{0}Styles'.format(os.sep, sourceDir), cfg['ericStylesDir'], 530 copyTree(
531 '{1}{0}Styles'.format(os.sep, sourceDir), cfg['ericStylesDir'],
516 ['*.qss']) 532 ['*.qss'])
517 copyTree('{1}{0}i18n'.format(os.sep, sourceDir), cfg['ericTranslationsDir'], 533 copyTree(
534 '{1}{0}i18n'.format(os.sep, sourceDir), cfg['ericTranslationsDir'],
518 ['*.qm']) 535 ['*.qm'])
519 copyTree('{1}{0}icons'.format(os.sep, sourceDir), cfg['ericIconDir'], 536 copyTree('{1}{0}icons'.format(os.sep, sourceDir), cfg['ericIconDir'],
520 ['*.png', 'LICENSE*.*', 'readme.txt']) 537 ['*.png', 'LICENSE*.*', 'readme.txt'])
521 copyTree('{1}{0}pixmaps'.format(os.sep, sourceDir), cfg['ericPixDir'], 538 copyTree('{1}{0}pixmaps'.format(os.sep, sourceDir), cfg['ericPixDir'],
522 ['*.png', '*.xpm', '*.ico', '*.gif']) 539 ['*.png', '*.xpm', '*.ico', '*.gif'])
524 cfg['ericTemplatesDir'], 541 cfg['ericTemplatesDir'],
525 ['*.tmpl']) 542 ['*.tmpl'])
526 copyTree('{1}{0}CodeTemplates'.format(os.sep, sourceDir), 543 copyTree('{1}{0}CodeTemplates'.format(os.sep, sourceDir),
527 cfg['ericCodeTemplatesDir'], 544 cfg['ericCodeTemplatesDir'],
528 ['*.tmpl']) 545 ['*.tmpl'])
529 copyTree('{1}{0}Examples'.format(os.sep, sourceDir), cfg['ericExamplesDir'], 546 copyTree(
547 '{1}{0}Examples'.format(os.sep, sourceDir), cfg['ericExamplesDir'],
530 ['*.py', '*.pyc', '*.pyo']) 548 ['*.py', '*.pyc', '*.pyo'])
531 549
532 # copy the wrappers 550 # copy the wrappers
533 for wname in wnames: 551 for wname in wnames:
534 shutilCopy(wname, cfg['bindir'], perm=0o755) 552 shutilCopy(wname, cfg['bindir'], perm=0o755)
535 os.remove(wname) 553 os.remove(wname)
536 554
537 # copy the license file 555 # copy the license file
538 shutilCopy('{1}{0}LICENSE.GPL3'.format(os.sep, sourceDir), cfg['ericDir']) 556 shutilCopy(
557 '{1}{0}LICENSE.GPL3'.format(os.sep, sourceDir), cfg['ericDir'])
539 558
540 # create the global plugins directory 559 # create the global plugins directory
541 createGlobalPluginsDir() 560 createGlobalPluginsDir()
542 561
543 except (IOError, OSError) as msg: 562 except (IOError, OSError) as msg:
544 sys.stderr.write('Error: {0}\nTry install with admin rights.\n'.format(msg)) 563 sys.stderr.write(
564 'Error: {0}\nTry install with admin rights.\n'.format(msg))
545 return(7) 565 return(7)
546 566
547 # copy some text files to the doc area 567 # copy some text files to the doc area
548 for name in ["LICENSE.GPL3", "THANKS", "changelog"]: 568 for name in ["LICENSE.GPL3", "THANKS", "changelog"]:
549 try: 569 try:
550 shutilCopy('{2}{0}{1}'.format(os.sep, name, sourceDir), cfg['ericDocDir']) 570 shutilCopy(
571 '{2}{0}{1}'.format(os.sep, name, sourceDir), cfg['ericDocDir'])
551 except EnvironmentError: 572 except EnvironmentError:
552 print("Could not install '{2}{0}{1}'.".format(os.sep, name, sourceDir)) 573 print("Could not install '{2}{0}{1}'.".format(
574 os.sep, name, sourceDir))
553 for name in glob.glob(os.path.join(sourceDir, 'README*.*')): 575 for name in glob.glob(os.path.join(sourceDir, 'README*.*')):
554 try: 576 try:
555 shutilCopy(name, cfg['ericDocDir']) 577 shutilCopy(name, cfg['ericDocDir'])
556 except EnvironmentError: 578 except EnvironmentError:
557 print("Could not install '{1}'.".format(name)) 579 print("Could not install '{1}'.".format(name))
558 580
559 # copy some more stuff 581 # copy some more stuff
560 for name in ['default.e4k', 'default_Mac.e4k']: 582 for name in ['default.e4k', 'default_Mac.e4k']:
561 try: 583 try:
562 shutilCopy('{2}{0}{1}'.format(os.sep, name, sourceDir), cfg['ericOthersDir']) 584 shutilCopy(
585 '{2}{0}{1}'.format(os.sep, name, sourceDir),
586 cfg['ericOthersDir'])
563 except EnvironmentError: 587 except EnvironmentError:
564 print("Could not install '{2}{0}{1}'.".format(os.sep, name, sourceDir)) 588 print("Could not install '{2}{0}{1}'.".format(
589 os.sep, name, sourceDir))
565 590
566 # install the API file 591 # install the API file
567 for progLanguage in progLanguages: 592 for progLanguage in progLanguages:
568 apidir = os.path.join(cfg['apidir'], progLanguage.lower()) 593 apidir = os.path.join(cfg['apidir'], progLanguage.lower())
569 if not os.path.exists(apidir): 594 if not os.path.exists(apidir):
570 os.makedirs(apidir) 595 os.makedirs(apidir)
571 for apiName in glob.glob(os.path.join(sourceDir, "APIs", progLanguage, "*.api")): 596 for apiName in glob.glob(os.path.join(sourceDir, "APIs",
597 progLanguage, "*.api")):
572 try: 598 try:
573 shutilCopy(apiName, apidir) 599 shutilCopy(apiName, apidir)
574 except EnvironmentError: 600 except EnvironmentError:
575 print("Could not install '{0}'.".format(apiName)) 601 print("Could not install '{0}'.".format(apiName))
576 for apiName in glob.glob(os.path.join(sourceDir, "APIs", progLanguage, "*.bas")): 602 for apiName in glob.glob(os.path.join(sourceDir, "APIs",
603 progLanguage, "*.bas")):
577 try: 604 try:
578 shutilCopy(apiName, apidir) 605 shutilCopy(apiName, apidir)
579 except EnvironmentError: 606 except EnvironmentError:
580 print("Could not install '{0}'.".format(apiName)) 607 print("Could not install '{0}'.".format(apiName))
581 if progLanguage == "Python": 608 if progLanguage == "Python":
582 # copy Python3 API files to the same destination 609 # copy Python3 API files to the same destination
583 for apiName in glob.glob(os.path.join(sourceDir, "APIs", "Python3", "*.api")): 610 for apiName in glob.glob(os.path.join(sourceDir, "APIs",
611 "Python3", "*.api")):
584 try: 612 try:
585 shutilCopy(apiName, apidir) 613 shutilCopy(apiName, apidir)
586 except EnvironmentError: 614 except EnvironmentError:
587 print("Could not install '{0}'.".format(apiName)) 615 print("Could not install '{0}'.".format(apiName))
588 for apiName in glob.glob(os.path.join(sourceDir, "APIs", "Python3", "*.bas")): 616 for apiName in glob.glob(os.path.join(sourceDir, "APIs",
617 "Python3", "*.bas")):
589 try: 618 try:
590 shutilCopy(apiName, apidir) 619 shutilCopy(apiName, apidir)
591 except EnvironmentError: 620 except EnvironmentError:
592 print("Could not install '{0}'.".format(apiName)) 621 print("Could not install '{0}'.".format(apiName))
593 622
597 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps")) 626 dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps"))
598 if not os.path.exists(dst): 627 if not os.path.exists(dst):
599 os.makedirs(dst) 628 os.makedirs(dst)
600 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric.png"), 629 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric.png"),
601 os.path.join(dst, "eric.png")) 630 os.path.join(dst, "eric.png"))
602 dst = os.path.normpath(os.path.join(distDir, "usr/share/applications")) 631 dst = os.path.normpath(
632 os.path.join(distDir, "usr/share/applications"))
603 if not os.path.exists(dst): 633 if not os.path.exists(dst):
604 os.makedirs(dst) 634 os.makedirs(dst)
605 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), dst) 635 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), dst)
606 else: 636 else:
607 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric.png"), 637 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric.png"),
608 "/usr/share/pixmaps/eric.png") 638 "/usr/share/pixmaps/eric.png")
609 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), 639 shutilCopy(os.path.join(sourceDir, "eric5.desktop"),
610 "/usr/share/applications") 640 "/usr/share/applications")
611 shutilCopy(os.path.join(sourceDir, "icons", "default", "ericWeb48.png"), 641 shutilCopy(
642 os.path.join(sourceDir, "icons", "default", "ericWeb48.png"),
612 "/usr/share/pixmaps/ericWeb.png") 643 "/usr/share/pixmaps/ericWeb.png")
613 shutilCopy(os.path.join(sourceDir, "eric5_webbrowser.desktop"), 644 shutilCopy(os.path.join(sourceDir, "eric5_webbrowser.desktop"),
614 "/usr/share/applications") 645 "/usr/share/applications")
615 646
616 # Create a Mac application bundle 647 # Create a Mac application bundle
622 653
623 def createMacAppBundle(pydir): 654 def createMacAppBundle(pydir):
624 """ 655 """
625 Create a Mac application bundle. 656 Create a Mac application bundle.
626 657
627 @param pydir the name of the directory where the Python script will eventually 658 @param pydir the name of the directory where the Python script will
628 be installed (string) 659 eventually be installed (string)
629 """ 660 """
630 global cfg, sourceDir, macAppBundleName, macPythonExe 661 global cfg, sourceDir, macAppBundleName, macPythonExe
631 662
632 dirs = {"contents": "/Applications/{0}/Contents/".format(macAppBundleName), 663 dirs = {"contents": "/Applications/{0}/Contents/".format(macAppBundleName),
633 "exe": "/Applications/{0}/Contents/MacOS".format(macAppBundleName), 664 "exe": "/Applications/{0}/Contents/MacOS".format(macAppBundleName),
634 "icns": "/Applications/{0}/Contents/Resources".format(macAppBundleName)} 665 "icns": "/Applications/{0}/Contents/Resources".format(
666 macAppBundleName)}
635 os.makedirs(dirs["contents"]) 667 os.makedirs(dirs["contents"])
636 os.mkdir(dirs["exe"]) 668 os.mkdir(dirs["exe"])
637 os.mkdir(dirs["icns"]) 669 os.mkdir(dirs["icns"])
638 670
639 if macAppBundleName == defaultMacAppBundleName: 671 if macAppBundleName == defaultMacAppBundleName:
732 """ 764 """
733 global cfg, sourceDir 765 global cfg, sourceDir
734 766
735 apis = [] 767 apis = []
736 for progLanguage in progLanguages: 768 for progLanguage in progLanguages:
737 for apiName in glob.glob(os.path.join(sourceDir, "APIs", progLanguage, "*.api")): 769 for apiName in glob.glob(
770 os.path.join(sourceDir, "APIs", progLanguage, "*.api")):
738 apis.append(os.path.basename(apiName)) 771 apis.append(os.path.basename(apiName))
739 if progLanguage == "Python": 772 if progLanguage == "Python":
740 # treat Python3 API files the same as Python API files 773 # treat Python3 API files the same as Python API files
741 for apiName in glob.glob(os.path.join(sourceDir, "APIs", "Python3", "*.api")): 774 for apiName in glob.glob(
775 os.path.join(sourceDir, "APIs", "Python3", "*.api")):
742 apis.append(os.path.basename(apiName)) 776 apis.append(os.path.basename(apiName))
743 777
744 fn = 'eric5config.py' 778 fn = 'eric5config.py'
745 config = \ 779 config = \
746 """# -*- coding: utf-8 -*- 780 """# -*- coding: utf-8 -*-
776 try: 810 try:
777 return _pkg_config[name] 811 return _pkg_config[name]
778 except KeyError: 812 except KeyError:
779 pass 813 pass
780 814
781 raise AttributeError('"{{0}}" is not a valid configuration value'.format(name)) 815 raise AttributeError('"{{0}}" is not a valid configuration value'.format(
816 name))
782 """.format(cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'], 817 """.format(cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'],
783 cfg['ericDTDDir'], cfg['ericCSSDir'], 818 cfg['ericDTDDir'], cfg['ericCSSDir'],
784 cfg['ericStylesDir'], cfg['ericDocDir'], 819 cfg['ericStylesDir'], cfg['ericDocDir'],
785 cfg['ericExamplesDir'], cfg['ericTranslationsDir'], 820 cfg['ericExamplesDir'], cfg['ericTranslationsDir'],
786 cfg['ericTemplatesDir'], 821 cfg['ericTemplatesDir'],
871 # always assume, that snapshots are new enough 906 # always assume, that snapshots are new enough
872 if "snapshot" not in sipVersion: 907 if "snapshot" not in sipVersion:
873 # check for blacklisted versions 908 # check for blacklisted versions
874 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]: 909 for vers in BlackLists["sip"] + PlatformBlackLists["sip"]:
875 if vers == sipVersion: 910 if vers == sipVersion:
876 print('Sorry, sip version {0} is not compatible with eric5.'\ 911 print(
877 .format(vers)) 912 'Sorry, sip version {0} is not compatible with eric5.'
913 .format(vers))
878 print('Please install another version.') 914 print('Please install another version.')
879 exit(3) 915 exit(3)
880 except ImportError: 916 except ImportError:
881 pass 917 pass
882 918
918 if maj < 2 or (maj == 2 and min < 6): 954 if maj < 2 or (maj == 2 and min < 6):
919 print('Sorry, you must have QScintilla 2.6.0 or higher or' \ 955 print('Sorry, you must have QScintilla 2.6.0 or higher or' \
920 ' a recent snapshot release.') 956 ' a recent snapshot release.')
921 exit(5) 957 exit(5)
922 # check for blacklisted versions 958 # check for blacklisted versions
923 for vers in BlackLists["QScintilla2"] + PlatformBlackLists["QScintilla2"]: 959 for vers in BlackLists["QScintilla2"] + \
960 PlatformBlackLists["QScintilla2"]:
924 if vers == scintillaVersion: 961 if vers == scintillaVersion:
925 print('Sorry, QScintilla2 version {0} is not compatible with eric5.'\ 962 print(
926 .format(vers)) 963 'Sorry, QScintilla2 version {0} is not compatible with'
964 ' eric5.'.format(vers))
927 print('Please install another version.') 965 print('Please install another version.')
928 exit(5) 966 exit(5)
929 print("QScintilla Version: ", QSCINTILLA_VERSION_STR) 967 print("QScintilla Version: ", QSCINTILLA_VERSION_STR)
930 print("All dependencies ok.") 968 print("All dependencies ok.")
931 print() 969 print()
932 970
933 971
934 def compileUiFiles(): 972 def compileUiFiles():
935 """ 973 """
936 Compile the .ui files to Python sources. 974 Compile the .ui files to Python sources.
937 """ 975 """ # __IGNORE_WARNING__
938 global sourceDir 976 global sourceDir
939 try: 977 try:
940 from PyQt4.uic import compileUiDir 978 from PyQt4.uic import compileUiDir
941 except ImportError: 979 except ImportError:
942 from PyQt4.uic import compileUi 980 from PyQt4.uic import compileUi
943 981
944 def compileUiDir(dir, recurse = False, map = None, # __IGNORE_WARNING__ 982 def compileUiDir(dir, recurse=False, # __IGNORE_WARNING__
945 ** compileUi_args): 983 map=None, **compileUi_args):
946 """ 984 """
947 Creates Python modules from Qt Designer .ui files in a directory or 985 Creates Python modules from Qt Designer .ui files in a directory or
948 directory tree. 986 directory tree.
949 987
950 Note: This function is a modified version of the one found in PyQt4. 988 Note: This function is a modified version of the one found in
951 989 PyQt4.
952 @param dir Name of the directory to scan for files whose name ends with 990
953 '.ui'. By default the generated Python module is created in the same 991 @param dir Name of the directory to scan for files whose name ends
954 directory ending with '.py'. 992 with '.ui'. By default the generated Python module is created
955 @param recurse flag indicating that any sub-directories should be scanned. 993 in the same directory ending with '.py'.
956 @param map an optional callable that is passed the name of the directory 994 @param recurse flag indicating that any sub-directories should be
957 containing the '.ui' file and the name of the Python module that will be 995 scanned.
958 created. The callable should return a tuple of the name of the directory 996 @param map an optional callable that is passed the name of the
959 in which the Python module will be created and the (possibly modified) 997 directory containing the '.ui' file and the name of the Python
960 name of the module. 998 module that will be created. The callable should return a
961 @param compileUi_args any additional keyword arguments that are passed to 999 tuple of the name of the directory in which the Python module
962 the compileUi() function that is called to create each Python module. 1000 will be created and the (possibly modified) name of the module.
1001 @param compileUi_args any additional keyword arguments that are
1002 passed to the compileUi() function that is called to create
1003 each Python module.
963 """ 1004 """
964 def compile_ui(ui_dir, ui_file): 1005 def compile_ui(ui_dir, ui_file):
965 """ 1006 """
966 Local function to compile a single .ui file. 1007 Local function to compile a single .ui file.
967 1008
971 # Ignore if it doesn't seem to be a .ui file. 1012 # Ignore if it doesn't seem to be a .ui file.
972 if ui_file.endswith('.ui'): 1013 if ui_file.endswith('.ui'):
973 py_dir = ui_dir 1014 py_dir = ui_dir
974 py_file = ui_file[:-3] + '.py' 1015 py_file = ui_file[:-3] + '.py'
975 1016
976 # Allow the caller to change the name of the .py file or generate 1017 # Allow the caller to change the name of the .py file or
977 # it in a different directory. 1018 # generate it in a different directory.
978 if map is not None: 1019 if map is not None:
979 py_dir, py_file = list(map(py_dir, py_file)) 1020 py_dir, py_file = list(map(py_dir, py_file))
980 1021
981 # Make sure the destination directory exists. 1022 # Make sure the destination directory exists.
982 try: 1023 try:
1005 if os.path.isfile(os.path.join(dir, ui)): 1046 if os.path.isfile(os.path.join(dir, ui)):
1006 compile_ui(dir, ui) 1047 compile_ui(dir, ui)
1007 1048
1008 def pyName(py_dir, py_file): 1049 def pyName(py_dir, py_file):
1009 """ 1050 """
1010 Local function to create the Python source file name for the compiled .ui file. 1051 Local function to create the Python source file name for the compiled
1052 .ui file.
1011 1053
1012 @param py_dir suggested name of the directory (string) 1054 @param py_dir suggested name of the directory (string)
1013 @param py_file suggested name for the compile source file (string) 1055 @param py_file suggested name for the compile source file (string)
1014 @return tuple of directory name (string) and source file name (string) 1056 @return tuple of directory name (string) and source file name (string)
1015 """ 1057 """
1074 doCompile = False 1116 doCompile = False
1075 elif opt == "-f": 1117 elif opt == "-f":
1076 try: 1118 try:
1077 exec(compile(open(arg).read(), arg, 'exec'), globals()) 1119 exec(compile(open(arg).read(), arg, 'exec'), globals())
1078 if len(cfg) != configLength: 1120 if len(cfg) != configLength:
1079 print("The configuration dictionary in '{0}' is incorrect. Aborting"\ 1121 print("The configuration dictionary in '{0}' is incorrect."
1080 .format(arg)) 1122 " Aborting".format(arg))
1081 exit(6) 1123 exit(6)
1082 except: 1124 except:
1083 cfg = {} 1125 cfg = {}
1084 elif opt == "-m": 1126 elif opt == "-m":
1085 macAppBundleName = arg 1127 macAppBundleName = arg
1140 if distDir: 1182 if distDir:
1141 compileall.compile_dir(sourceDir, 1183 compileall.compile_dir(sourceDir,
1142 ddir=os.path.join(distDir, modDir, cfg['ericDir']), 1184 ddir=os.path.join(distDir, modDir, cfg['ericDir']),
1143 rx=re.compile(r"DebugClients[\\/]Python[\\/]"), 1185 rx=re.compile(r"DebugClients[\\/]Python[\\/]"),
1144 quiet=True) 1186 quiet=True)
1145 py_compile.compile(configName, 1187 py_compile.compile(
1146 dfile=os.path.join(distDir, modDir, "eric5config.py")) 1188 configName,
1189 dfile=os.path.join(distDir, modDir, "eric5config.py"))
1147 else: 1190 else:
1148 compileall.compile_dir(sourceDir, 1191 compileall.compile_dir(sourceDir,
1149 ddir=os.path.join(modDir, cfg['ericDir']), 1192 ddir=os.path.join(modDir, cfg['ericDir']),
1150 rx=re.compile(r"DebugClients[\\/]Python[\\/]"), 1193 rx=re.compile(r"DebugClients[\\/]Python[\\/]"),
1151 quiet=True) 1194 quiet=True)
1176 try: 1219 try:
1177 main(sys.argv) 1220 main(sys.argv)
1178 except SystemExit: 1221 except SystemExit:
1179 raise 1222 raise
1180 except: 1223 except:
1181 print("""An internal error occured. Please report all the output of the program, 1224 print("""
1225 An internal error occured. Please report all the output of the program,
1182 including the following traceback, to eric5-bugs@eric-ide.python-projects.org. 1226 including the following traceback, to eric5-bugs@eric-ide.python-projects.org.
1183 """) 1227 """)
1184 raise 1228 raise

eric ide

mercurial