install.py

branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3022
57179e4cdadd
child 3060
5883ce99ee12
equal deleted inserted replaced
3057:10516539f238 3058:0a02c433f52d
78 78
79 79
80 def exit(rcode=0): 80 def exit(rcode=0):
81 """ 81 """
82 Exit the install script. 82 Exit the install script.
83
84 @param rcode result code to report back (integer)
83 """ 85 """
84 global currDir 86 global currDir
85 87
86 if sys.platform.startswith("win"): 88 if sys.platform.startswith("win"):
87 # different meaning of input between Py2 and Py3 89 # different meaning of input between Py2 and Py3
109 if sys.platform == "darwin": 111 if sys.platform == "darwin":
110 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 112 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
111 " [-m name] [-p python]".format(progName)) 113 " [-m name] [-p python]".format(progName))
112 elif sys.platform.startswith("win"): 114 elif sys.platform.startswith("win"):
113 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"\ 115 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file]"\
114 .format(progName)) 116 .format(progName))
115 else: 117 else:
116 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"\ 118 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"\
117 .format(progName)) 119 .format(progName))
118 print("where:") 120 print("where:")
119 print(" -h display this help message") 121 print(" -h display this help message")
120 print(" -a dir where the API files will be installed") 122 print(" -a dir where the API files will be installed")
121 if apisDir: 123 if apisDir:
122 print(" (default: {0})".format(apisDir)) 124 print(" (default: {0})".format(apisDir))
249 elif sys.platform == "darwin": 251 elif sys.platform == "darwin":
250 pyexec = "{0}/bin/pythonw3".format(sys.exec_prefix) 252 pyexec = "{0}/bin/pythonw3".format(sys.exec_prefix)
251 if not os.path.exists(pyexec): 253 if not os.path.exists(pyexec):
252 pyexec = "{0}/bin/python3".format(sys.exec_prefix) 254 pyexec = "{0}/bin/python3".format(sys.exec_prefix)
253 wname = wfile 255 wname = wfile
254 wrapper = \ 256 wrapper = (
255 '''#!/bin/sh 257 '''#!/bin/sh
256 258
257 exec "{0}" "{1}/{2}.py" "$@" 259 exec "{0}" "{1}/{2}.py" "$@"
258 '''.format(pyexec, pydir, wfile) 260 '''.format(pyexec, pydir, wfile))
259 261
260 # *nix systems 262 # *nix systems
261 else: 263 else:
262 wname = wfile 264 wname = wfile
263 wrapper = \ 265 wrapper = (
264 '''#!/bin/sh 266 '''#!/bin/sh
265 267
266 exec "{0}" "{1}/{2}.py" "$@" 268 exec "{0}" "{1}/{2}.py" "$@"
267 '''.format(sys.executable, pydir, wfile) 269 '''.format(sys.executable, pydir, wfile))
268 270
269 copyToFile(wname, wrapper) 271 copyToFile(wname, wrapper)
270 os.chmod(wname, 0o755) 272 os.chmod(wname, 0o755)
271 273
272 return wname 274 return wname
509 shutilCopy(configName, modDir) 511 shutilCopy(configName, modDir)
510 if os.path.exists(configName + 'c'): 512 if os.path.exists(configName + 'c'):
511 shutilCopy(configName + 'c', modDir) 513 shutilCopy(configName + 'c', modDir)
512 514
513 # copy the various parts of eric5 515 # copy the various parts of eric5
514 copyTree(sourceDir, cfg['ericDir'], 516 copyTree(
517 sourceDir, cfg['ericDir'],
515 ['*.py', '*.pyc', '*.pyo', '*.pyw'], 518 ['*.py', '*.pyc', '*.pyo', '*.pyw'],
516 ['{1}{0}Examples'.format(os.sep, sourceDir)], 519 ['{1}{0}Examples'.format(os.sep, sourceDir)],
517 excludePatterns=["eric5config.py*"]) 520 excludePatterns=["eric5config.py*"])
518 copyTree(sourceDir, cfg['ericDir'], ['*.rb'], 521 copyTree(
522 sourceDir, cfg['ericDir'], ['*.rb'],
519 ['{1}{0}Examples'.format(os.sep, sourceDir)]) 523 ['{1}{0}Examples'.format(os.sep, sourceDir)])
520 copyTree('{1}{0}Plugins'.format(os.sep, sourceDir), 524 copyTree(
525 '{1}{0}Plugins'.format(os.sep, sourceDir),
521 '{0}{1}Plugins'.format(cfg['ericDir'], os.sep), 526 '{0}{1}Plugins'.format(cfg['ericDir'], os.sep),
522 ['*.png', '*.style']) 527 ['*.png', '*.style'])
523 copyTree( 528 copyTree(
524 '{1}{0}Documentation'.format(os.sep, sourceDir), cfg['ericDocDir'], 529 '{1}{0}Documentation'.format(os.sep, sourceDir), cfg['ericDocDir'],
525 ['*.html', '*.qch']) 530 ['*.html', '*.qch'])
526 copyTree('{1}{0}DTDs'.format(os.sep, sourceDir), cfg['ericDTDDir'], 531 copyTree(
532 '{1}{0}DTDs'.format(os.sep, sourceDir), cfg['ericDTDDir'],
527 ['*.dtd']) 533 ['*.dtd'])
528 copyTree('{1}{0}CSSs'.format(os.sep, sourceDir), cfg['ericCSSDir'], 534 copyTree(
535 '{1}{0}CSSs'.format(os.sep, sourceDir), cfg['ericCSSDir'],
529 ['*.css']) 536 ['*.css'])
530 copyTree( 537 copyTree(
531 '{1}{0}Styles'.format(os.sep, sourceDir), cfg['ericStylesDir'], 538 '{1}{0}Styles'.format(os.sep, sourceDir), cfg['ericStylesDir'],
532 ['*.qss']) 539 ['*.qss'])
533 copyTree( 540 copyTree(
534 '{1}{0}i18n'.format(os.sep, sourceDir), cfg['ericTranslationsDir'], 541 '{1}{0}i18n'.format(os.sep, sourceDir), cfg['ericTranslationsDir'],
535 ['*.qm']) 542 ['*.qm'])
536 copyTree('{1}{0}icons'.format(os.sep, sourceDir), cfg['ericIconDir'], 543 copyTree(
544 '{1}{0}icons'.format(os.sep, sourceDir), cfg['ericIconDir'],
537 ['*.png', 'LICENSE*.*', 'readme.txt']) 545 ['*.png', 'LICENSE*.*', 'readme.txt'])
538 copyTree('{1}{0}pixmaps'.format(os.sep, sourceDir), cfg['ericPixDir'], 546 copyTree(
547 '{1}{0}pixmaps'.format(os.sep, sourceDir), cfg['ericPixDir'],
539 ['*.png', '*.xpm', '*.ico', '*.gif']) 548 ['*.png', '*.xpm', '*.ico', '*.gif'])
540 copyTree('{1}{0}DesignerTemplates'.format(os.sep, sourceDir), 549 copyTree(
550 '{1}{0}DesignerTemplates'.format(os.sep, sourceDir),
541 cfg['ericTemplatesDir'], 551 cfg['ericTemplatesDir'],
542 ['*.tmpl']) 552 ['*.tmpl'])
543 copyTree('{1}{0}CodeTemplates'.format(os.sep, sourceDir), 553 copyTree(
554 '{1}{0}CodeTemplates'.format(os.sep, sourceDir),
544 cfg['ericCodeTemplatesDir'], 555 cfg['ericCodeTemplatesDir'],
545 ['*.tmpl']) 556 ['*.tmpl'])
546 copyTree( 557 copyTree(
547 '{1}{0}Examples'.format(os.sep, sourceDir), cfg['ericExamplesDir'], 558 '{1}{0}Examples'.format(os.sep, sourceDir), cfg['ericExamplesDir'],
548 ['*.py', '*.pyc', '*.pyo']) 559 ['*.py', '*.pyc', '*.pyo'])
632 os.path.join(distDir, "usr/share/applications")) 643 os.path.join(distDir, "usr/share/applications"))
633 if not os.path.exists(dst): 644 if not os.path.exists(dst):
634 os.makedirs(dst) 645 os.makedirs(dst)
635 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), dst) 646 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), dst)
636 else: 647 else:
637 shutilCopy(os.path.join(sourceDir, "icons", "default", "eric.png"), 648 shutilCopy(os.path.join(
649 sourceDir, "icons", "default", "eric.png"),
638 "/usr/share/pixmaps/eric.png") 650 "/usr/share/pixmaps/eric.png")
639 shutilCopy(os.path.join(sourceDir, "eric5.desktop"), 651 shutilCopy(os.path.join(
652 sourceDir, "eric5.desktop"),
640 "/usr/share/applications") 653 "/usr/share/applications")
641 shutilCopy( 654 shutilCopy(os.path.join(
642 os.path.join(sourceDir, "icons", "default", "ericWeb48.png"), 655 sourceDir, "icons", "default", "ericWeb48.png"),
643 "/usr/share/pixmaps/ericWeb.png") 656 "/usr/share/pixmaps/ericWeb.png")
644 shutilCopy(os.path.join(sourceDir, "eric5_webbrowser.desktop"), 657 shutilCopy(os.path.join(
658 sourceDir, "eric5_webbrowser.desktop"),
645 "/usr/share/applications") 659 "/usr/share/applications")
646 660
647 # Create a Mac application bundle 661 # Create a Mac application bundle
648 if sys.platform == "darwin": 662 if sys.platform == "darwin":
649 createMacAppBundle(cfg['ericDir']) 663 createMacAppBundle(cfg['ericDir'])
680 pybin = os.path.join(sys.exec_prefix, "bin") 694 pybin = os.path.join(sys.exec_prefix, "bin")
681 pathlist = path.split(os.pathsep) 695 pathlist = path.split(os.pathsep)
682 if pybin not in pathlist: 696 if pybin not in pathlist:
683 pathlist.insert(0, pybin) 697 pathlist.insert(0, pybin)
684 path = os.pathsep.join(pathlist) 698 path = os.pathsep.join(pathlist)
685 wrapper = \ 699 wrapper = (
686 '''#!/bin/sh 700 '''#!/bin/sh
687 701
688 PATH={0} 702 PATH={0}
689 exec "{1}" "{2}/{3}.py" "$@" 703 exec "{1}" "{2}/{3}.py" "$@"
690 '''.format(path, starter, pydir, "eric5") 704 '''.format(path, starter, pydir, "eric5"))
691 else: 705 else:
692 wrapper = \ 706 wrapper = (
693 '''#!/bin/sh 707 '''#!/bin/sh
694 708
695 exec "{0}" "{1}/{2}.py" "$@" 709 exec "{0}" "{1}/{2}.py" "$@"
696 '''.format(starter, pydir, "eric5") 710 '''.format(starter, pydir, "eric5"))
697 copyToFile(wname, wrapper) 711 copyToFile(wname, wrapper)
698 os.chmod(wname, 0o755) 712 os.chmod(wname, 0o755)
699 713
700 shutilCopy(os.path.join(sourceDir, "pixmaps", "eric_2.icns"), 714 shutilCopy(os.path.join(sourceDir, "pixmaps", "eric_2.icns"),
701 os.path.join(dirs["icns"], "eric.icns")) 715 os.path.join(dirs["icns"], "eric.icns"))
702 716
703 copyToFile(os.path.join(dirs["contents"], "Info.plist"), 717 copyToFile(
718 os.path.join(dirs["contents"], "Info.plist"),
704 '''<?xml version="1.0" encoding="UTF-8"?> 719 '''<?xml version="1.0" encoding="UTF-8"?>
705 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" 720 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
706 "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 721 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
707 <plist version="1.0"> 722 <plist version="1.0">
708 <dict> 723 <dict>
721 <key>CFBundleSignature</key> 736 <key>CFBundleSignature</key>
722 <string>????</string> 737 <string>????</string>
723 <key>CFBundleVersion</key> 738 <key>CFBundleVersion</key>
724 <string>1.0</string> 739 <string>1.0</string>
725 </dict> 740 </dict>
726 </plist> 741 </plist>\n'''.format(macAppBundleName.replace(".app", "")))
727 '''.format(macAppBundleName.replace(".app", ""))
728 )
729 742
730 743
731 def createInstallConfig(): 744 def createInstallConfig():
732 """ 745 """
733 Create the installation config dictionary. 746 Create the installation config dictionary.
811 return _pkg_config[name] 824 return _pkg_config[name]
812 except KeyError: 825 except KeyError:
813 pass 826 pass
814 827
815 raise AttributeError('"{{0}}" is not a valid configuration value'.format( 828 raise AttributeError('"{{0}}" is not a valid configuration value'.format(
816 name)) 829 name))\n""".format(
817 """.format(cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'], 830 cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'],
818 cfg['ericDTDDir'], cfg['ericCSSDir'], 831 cfg['ericDTDDir'], cfg['ericCSSDir'],
819 cfg['ericStylesDir'], cfg['ericDocDir'], 832 cfg['ericStylesDir'], cfg['ericDocDir'],
820 cfg['ericExamplesDir'], cfg['ericTranslationsDir'], 833 cfg['ericExamplesDir'], cfg['ericTranslationsDir'],
821 cfg['ericTemplatesDir'], 834 cfg['ericTemplatesDir'],
822 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'], 835 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'],
823 cfg['bindir'], cfg['mdir'], 836 cfg['bindir'], cfg['mdir'],
824 cfg['apidir'], apis) 837 cfg['apidir'], apis)
825 copyToFile(fn, config) 838 copyToFile(fn, config)
826 839
827 840
828 def doDependancyChecks(): 841 def doDependancyChecks():
829 """ 842 """
1178 if doCompile: 1191 if doCompile:
1179 print("\nCompiling source files ...") 1192 print("\nCompiling source files ...")
1180 # Hide compile errors (mainly because of Py2/Py3 differences) 1193 # Hide compile errors (mainly because of Py2/Py3 differences)
1181 sys.stdout = io.StringIO() 1194 sys.stdout = io.StringIO()
1182 if distDir: 1195 if distDir:
1183 compileall.compile_dir(sourceDir, 1196 compileall.compile_dir(
1197 sourceDir,
1184 ddir=os.path.join(distDir, modDir, cfg['ericDir']), 1198 ddir=os.path.join(distDir, modDir, cfg['ericDir']),
1185 rx=re.compile(r"DebugClients[\\/]Python[\\/]"), 1199 rx=re.compile(r"DebugClients[\\/]Python[\\/]"),
1186 quiet=True) 1200 quiet=True)
1187 py_compile.compile( 1201 py_compile.compile(
1188 configName, 1202 configName,
1189 dfile=os.path.join(distDir, modDir, "eric5config.py")) 1203 dfile=os.path.join(distDir, modDir, "eric5config.py"))
1190 else: 1204 else:
1191 compileall.compile_dir(sourceDir, 1205 compileall.compile_dir(
1206 sourceDir,
1192 ddir=os.path.join(modDir, cfg['ericDir']), 1207 ddir=os.path.join(modDir, cfg['ericDir']),
1193 rx=re.compile(r"DebugClients[\\/]Python[\\/]"), 1208 rx=re.compile(r"DebugClients[\\/]Python[\\/]"),
1194 quiet=True) 1209 quiet=True)
1195 py_compile.compile(configName, 1210 py_compile.compile(configName,
1196 dfile=os.path.join(modDir, "eric5config.py")) 1211 dfile=os.path.join(modDir, "eric5config.py"))

eric ide

mercurial