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