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(): |
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: |
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 |
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() |