37 |
37 |
38 @param rcode the return code passed back to the calling process. |
38 @param rcode the return code passed back to the calling process. |
39 """ |
39 """ |
40 global progName, platBinDir, modDir, distDir, apisDir |
40 global progName, platBinDir, modDir, distDir, apisDir |
41 |
41 |
42 print |
42 print() |
43 print "Usage:" |
43 print("Usage:") |
44 print " %s [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" % (progName) |
44 print(" %s [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" % (progName)) |
45 print "where:" |
45 print("where:") |
46 print " -h display this help message" |
46 print(" -h display this help message") |
47 print " -a dir where the API files will be installed" |
47 print(" -a dir where the API files will be installed") |
48 if apisDir: |
48 if apisDir: |
49 print " (default: %s)" % (apisDir) |
49 print(" (default: %s)" % (apisDir)) |
50 else: |
50 else: |
51 print " (no default value)" |
51 print(" (no default value)") |
52 print " -b dir where the binaries will be installed" |
52 print(" -b dir where the binaries will be installed") |
53 print " (default: %s)" % (platBinDir) |
53 print(" (default: %s)" % (platBinDir)) |
54 print " -d dir where eric4 python files will be installed" |
54 print(" -d dir where eric4 python files will be installed") |
55 print " (default: %s)" % (modDir) |
55 print(" (default: %s)" % (modDir)) |
56 print " -f file configuration file naming the various installation paths" |
56 print(" -f file configuration file naming the various installation paths") |
57 if not sys.platform.startswith("win"): |
57 if not sys.platform.startswith("win"): |
58 print " -i dir temporary install prefix" |
58 print(" -i dir temporary install prefix") |
59 print " (default: %s)" % (distDir) |
59 print(" (default: %s)" % (distDir)) |
60 print " -x don't perform dependency checks (use on your own risk)" |
60 print(" -x don't perform dependency checks (use on your own risk)") |
61 print " -c don't cleanup old installation first" |
61 print(" -c don't cleanup old installation first") |
62 print " -z don't compile the installed python files" |
62 print(" -z don't compile the installed python files") |
63 print |
63 print() |
64 print "The file given to the -f option must be valid Python code defining a" |
64 print("The file given to the -f option must be valid Python code defining a") |
65 print "dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir', 'ericIconDir'," |
65 print("dictionary called 'cfg' with the keys 'ericDir', 'ericPixDir', 'ericIconDir',") |
66 print "'ericDTDDir', 'ericCSSDir', 'ericStylesDir', 'ericDocDir', 'ericExamplesDir'," |
66 print("'ericDTDDir', 'ericCSSDir', 'ericStylesDir', 'ericDocDir', 'ericExamplesDir',") |
67 print "'ericTranslationsDir', 'ericTemplatesDir', 'ericCodeTemplatesDir'," |
67 print("'ericTranslationsDir', 'ericTemplatesDir', 'ericCodeTemplatesDir',") |
68 print "'ericOthersDir','bindir', 'mdir' and 'apidir." |
68 print("'ericOthersDir','bindir', 'mdir' and 'apidir.") |
69 print "These define the directories for the installation of the various parts of"\ |
69 print("These define the directories for the installation of the various parts of"\ |
70 " eric4." |
70 " eric4.") |
71 |
71 |
72 sys.exit(rcode) |
72 sys.exit(rcode) |
73 |
73 |
74 |
74 |
75 def initGlobals(): |
75 def initGlobals(): |
160 |
160 |
161 exec "%s" "%s/%s.py" "$@" |
161 exec "%s" "%s/%s.py" "$@" |
162 ''' % (sys.executable, pydir, wfile) |
162 ''' % (sys.executable, pydir, wfile) |
163 |
163 |
164 copyToFile(wname, wrapper) |
164 copyToFile(wname, wrapper) |
165 os.chmod(wname, 0755) |
165 os.chmod(wname, 0o755) |
166 |
166 |
167 return wname |
167 return wname |
168 |
168 |
169 |
169 |
170 def copyTree(src, dst, filters, excludeDirs=[]): |
170 def copyTree(src, dst, filters, excludeDirs=[]): |
204 |
204 |
205 pdir = os.path.join(cfg['mdir'], "eric4plugins") |
205 pdir = os.path.join(cfg['mdir'], "eric4plugins") |
206 fname = os.path.join(pdir, "__init__.py") |
206 fname = os.path.join(pdir, "__init__.py") |
207 if not os.path.exists(fname): |
207 if not os.path.exists(fname): |
208 if not os.path.exists(pdir): |
208 if not os.path.exists(pdir): |
209 os.mkdir(pdir, 0755) |
209 os.mkdir(pdir, 0o755) |
210 f = open(fname, "wb") |
210 f = open(fname, "w") |
211 f.write(\ |
211 f.write(\ |
212 '''# -*- coding: utf-8 -*- |
212 '''# -*- coding: utf-8 -*- |
213 |
213 |
214 """ |
214 """ |
215 Package containing the global plugins. |
215 Package containing the global plugins. |
306 wnames.append(createPyWrapper(cfg['ericDir'], "eric4-sqlbrowser")) |
306 wnames.append(createPyWrapper(cfg['ericDir'], "eric4-sqlbrowser")) |
307 wnames.append(createPyWrapper(cfg['ericDir'], "eric4")) |
307 wnames.append(createPyWrapper(cfg['ericDir'], "eric4")) |
308 |
308 |
309 # set install prefix, if not None |
309 # set install prefix, if not None |
310 if distDir: |
310 if distDir: |
311 for key in cfg.keys(): |
311 for key in list(cfg.keys()): |
312 cfg[key] = os.path.normpath(distDir + os.sep + cfg[key]) |
312 cfg[key] = os.path.normpath(distDir + os.sep + cfg[key]) |
313 |
313 |
314 try: |
314 try: |
315 # Install the files |
315 # Install the files |
316 # make the install directories |
316 # make the install directories |
317 for key in cfg.keys(): |
317 for key in list(cfg.keys()): |
318 if not os.path.isdir(cfg[key]): |
318 if not os.path.isdir(cfg[key]): |
319 os.makedirs(cfg[key]) |
319 os.makedirs(cfg[key]) |
320 |
320 |
321 # copy the eric4 config file |
321 # copy the eric4 config file |
322 if distDir: |
322 if distDir: |
361 shutil.copy('eric%sLICENSE.GPL3' % os.sep, cfg['ericDir']) |
361 shutil.copy('eric%sLICENSE.GPL3' % os.sep, cfg['ericDir']) |
362 |
362 |
363 # create the global plugins directory |
363 # create the global plugins directory |
364 createGlobalPluginsDir() |
364 createGlobalPluginsDir() |
365 |
365 |
366 except IOError, msg: |
366 except IOError as msg: |
367 sys.stderr.write('IOError: %s\nTry install as root.\n' % msg) |
367 sys.stderr.write('IOError: %s\nTry install as root.\n' % msg) |
368 sys.exit(7) |
368 sys.exit(7) |
369 |
369 |
370 # copy some text files to the doc area |
370 # copy some text files to the doc area |
371 for name in ["LICENSE.GPL3", "THANKS", "changelog"]: |
371 for name in ["LICENSE.GPL3", "THANKS", "changelog"]: |
372 try: |
372 try: |
373 shutil.copy('eric%s%s' % (os.sep, name), cfg['ericDocDir']) |
373 shutil.copy('eric%s%s' % (os.sep, name), cfg['ericDocDir']) |
374 except EnvironmentError: |
374 except EnvironmentError: |
375 print "Could not install 'eric%s%s'." % (os.sep, name) |
375 print("Could not install 'eric%s%s'." % (os.sep, name)) |
376 for name in glob.glob(os.path.join('eric', 'README*.*')): |
376 for name in glob.glob(os.path.join('eric', 'README*.*')): |
377 try: |
377 try: |
378 shutil.copy(name, cfg['ericDocDir']) |
378 shutil.copy(name, cfg['ericDocDir']) |
379 except EnvironmentError: |
379 except EnvironmentError: |
380 print "Could not install 'eric%s%s'." % (os.sep, name) |
380 print("Could not install 'eric%s%s'." % (os.sep, name)) |
381 |
381 |
382 # copy some more stuff |
382 # copy some more stuff |
383 for name in ['default.e4k']: |
383 for name in ['default.e4k']: |
384 try: |
384 try: |
385 shutil.copy('eric%s%s' % (os.sep, name), cfg['ericOthersDir']) |
385 shutil.copy('eric%s%s' % (os.sep, name), cfg['ericOthersDir']) |
386 except EnvironmentError: |
386 except EnvironmentError: |
387 print "Could not install 'eric%s%s'." % (os.sep, name) |
387 print("Could not install 'eric%s%s'." % (os.sep, name)) |
388 |
388 |
389 # install the API file |
389 # install the API file |
390 for progLanguage in progLanguages: |
390 for progLanguage in progLanguages: |
391 apidir = os.path.join(cfg['apidir'], progLanguage.lower()) |
391 apidir = os.path.join(cfg['apidir'], progLanguage.lower()) |
392 if not os.path.exists(apidir): |
392 if not os.path.exists(apidir): |
393 os.makedirs(apidir) |
393 os.makedirs(apidir) |
394 for apiName in glob.glob(os.path.join("eric", "APIs", progLanguage, "*.api")): |
394 for apiName in glob.glob(os.path.join("eric", "APIs", progLanguage, "*.api")): |
395 try: |
395 try: |
396 shutil.copy(apiName, apidir) |
396 shutil.copy(apiName, apidir) |
397 except EnvironmentError: |
397 except EnvironmentError: |
398 print "Could not install '%s'." % apiName |
398 print("Could not install '%s'." % apiName) |
399 |
399 |
400 |
400 |
401 def createInstallConfig(): |
401 def createInstallConfig(): |
402 """ |
402 """ |
403 Create the installation config dictionary. |
403 Create the installation config dictionary. |
488 |
488 |
489 def doDependancyChecks(): |
489 def doDependancyChecks(): |
490 """ |
490 """ |
491 Perform some dependency checks. |
491 Perform some dependency checks. |
492 """ |
492 """ |
493 print 'Checking dependencies' |
493 print('Checking dependencies') |
494 |
494 |
495 # perform dependency checks |
495 # perform dependency checks |
496 if sys.version_info < (2, 6, 0): |
496 if sys.version_info < (2, 6, 0): |
497 print 'Sorry, you must have Python 2.6.0 or higher.' |
497 print('Sorry, you must have Python 2.6.0 or higher.') |
498 sys.exit(5) |
498 sys.exit(5) |
499 if sys.version_info > (2, 9, 9): |
499 if sys.version_info > (2, 9, 9): |
500 print 'Sorry, eric4 requires Python 2 for running.' |
500 print('Sorry, eric4 requires Python 2 for running.') |
501 sys.exit(5) |
501 sys.exit(5) |
502 print "Python Version: %d.%d.%d" % sys.version_info[:3] |
502 print("Python Version: %d.%d.%d" % sys.version_info[:3]) |
503 |
503 |
504 try: |
504 try: |
505 from PyQt4.QtCore import qVersion, PYQT_VERSION |
505 from PyQt4.QtCore import qVersion, PYQT_VERSION |
506 except ImportError, msg: |
506 except ImportError as msg: |
507 print 'Sorry, please install PyQt4.' |
507 print('Sorry, please install PyQt4.') |
508 print 'Error: %s' % msg |
508 print('Error: %s' % msg) |
509 sys.exit(1) |
509 sys.exit(1) |
510 print "Found PyQt" |
510 print("Found PyQt") |
511 |
511 |
512 try: |
512 try: |
513 from PyQt4 import Qsci |
513 from PyQt4 import Qsci |
514 except ImportError, msg: |
514 except ImportError as msg: |
515 print "Sorry, please install QScintilla2 and" |
515 print("Sorry, please install QScintilla2 and") |
516 print "it's PyQt4 wrapper." |
516 print("it's PyQt4 wrapper.") |
517 print 'Error: %s' % msg |
517 print('Error: %s' % msg) |
518 sys.exit(1) |
518 sys.exit(1) |
519 print "Found QScintilla2" |
519 print("Found QScintilla2") |
520 |
520 |
521 # check version of Qt |
521 # check version of Qt |
522 qtMajor = int(qVersion().split('.')[0]) |
522 qtMajor = int(qVersion().split('.')[0]) |
523 qtMinor = int(qVersion().split('.')[1]) |
523 qtMinor = int(qVersion().split('.')[1]) |
524 if qtMajor < 4 or (qtMajor == 4 and qtMinor < 5): |
524 if qtMajor < 4 or (qtMajor == 4 and qtMinor < 5): |
525 print 'Sorry, you must have Qt version 4.5.0 or higher.' |
525 print('Sorry, you must have Qt version 4.5.0 or higher.') |
526 sys.exit(2) |
526 sys.exit(2) |
527 print "Qt Version: %s" % qVersion() |
527 print("Qt Version: %s" % qVersion()) |
528 |
528 |
529 #check version of PyQt |
529 #check version of PyQt |
530 from PyQt4.QtCore import PYQT_VERSION_STR |
530 from PyQt4.QtCore import PYQT_VERSION_STR |
531 pyqtVersion = PYQT_VERSION_STR |
531 pyqtVersion = PYQT_VERSION_STR |
532 # always assume, that snapshots are new enough |
532 # always assume, that snapshots are new enough |
536 (maj, min, pat) = pyqtVersion.split('.') |
536 (maj, min, pat) = pyqtVersion.split('.') |
537 maj = int(maj) |
537 maj = int(maj) |
538 min = int(min) |
538 min = int(min) |
539 pat = int(pat) |
539 pat = int(pat) |
540 if maj < 4 or (maj == 4 and min < 7): |
540 if maj < 4 or (maj == 4 and min < 7): |
541 print 'Sorry, you must have PyQt 4.7.0 or higher or' \ |
541 print('Sorry, you must have PyQt 4.7.0 or higher or' \ |
542 ' a recent snapshot release.' |
542 ' a recent snapshot release.') |
543 sys.exit(3) |
543 sys.exit(3) |
544 print "PyQt Version: ", pyqtVersion |
544 print("PyQt Version: ", pyqtVersion) |
545 |
545 |
546 #check version of QScintilla |
546 #check version of QScintilla |
547 from PyQt4.Qsci import QSCINTILLA_VERSION_STR |
547 from PyQt4.Qsci import QSCINTILLA_VERSION_STR |
548 scintillaVersion = QSCINTILLA_VERSION_STR |
548 scintillaVersion = QSCINTILLA_VERSION_STR |
549 # always assume, that snapshots are new enough |
549 # always assume, that snapshots are new enough |
553 (maj, min, pat) = scintillaVersion.split('.') |
553 (maj, min, pat) = scintillaVersion.split('.') |
554 maj = int(maj) |
554 maj = int(maj) |
555 min = int(min) |
555 min = int(min) |
556 pat = int(pat) |
556 pat = int(pat) |
557 if maj < 2 or (maj == 2 and min < 4): |
557 if maj < 2 or (maj == 2 and min < 4): |
558 print 'Sorry, you must have QScintilla 2.4.0 or higher or' \ |
558 print('Sorry, you must have QScintilla 2.4.0 or higher or' \ |
559 ' a recent snapshot release.' |
559 ' a recent snapshot release.') |
560 sys.exit(4) |
560 sys.exit(4) |
561 print "QScintilla Version: ", QSCINTILLA_VERSION_STR |
561 print("QScintilla Version: ", QSCINTILLA_VERSION_STR) |
562 print "All dependencies ok." |
562 print("All dependencies ok.") |
563 print |
563 print() |
564 |
564 |
565 def compileUiFiles(): |
565 def compileUiFiles(): |
566 """ |
566 """ |
567 Compile the .ui files to Python sources. |
567 Compile the .ui files to Python sources. |
568 """ |
568 """ |
716 if doCleanup: |
716 if doCleanup: |
717 if distDir: |
717 if distDir: |
718 shutil.rmtree(distDir, True) |
718 shutil.rmtree(distDir, True) |
719 else: |
719 else: |
720 cleanUp() |
720 cleanUp() |
721 except IOError, msg: |
721 except IOError as msg: |
722 sys.stderr.write('IOError: %s\nTry install as root.\n' % msg) |
722 sys.stderr.write('IOError: %s\nTry install as root.\n' % msg) |
723 |
723 |
724 # Create a config file and delete the default one |
724 # Create a config file and delete the default one |
725 createConfig() |
725 createConfig() |
726 |
726 |
727 # Compile .ui files |
727 # Compile .ui files |
728 print "Compiling user interface files..." |
728 print("Compiling user interface files...") |
729 compileUiFiles() |
729 compileUiFiles() |
730 |
730 |
731 if doCompile: |
731 if doCompile: |
732 print "\nCompiling source files..." |
732 print("\nCompiling source files...") |
733 if distDir: |
733 if distDir: |
734 compileall.compile_dir("eric", |
734 compileall.compile_dir("eric", |
735 ddir = os.path.join(distDir, modDir, cfg['ericDir']), |
735 ddir = os.path.join(distDir, modDir, cfg['ericDir']), |
736 rx = re.compile("Python3"), |
736 rx = re.compile("Python3"), |
737 quiet = True) |
737 quiet = True) |
742 ddir = os.path.join(modDir, cfg['ericDir']), |
742 ddir = os.path.join(modDir, cfg['ericDir']), |
743 rx = re.compile("Python3"), |
743 rx = re.compile("Python3"), |
744 quiet = True) |
744 quiet = True) |
745 py_compile.compile("eric4config.py", |
745 py_compile.compile("eric4config.py", |
746 dfile = os.path.join(modDir, "eric4config.py")) |
746 dfile = os.path.join(modDir, "eric4config.py")) |
747 print "\nInstalling eric4 ..." |
747 print("\nInstalling eric4 ...") |
748 installEric() |
748 installEric() |
749 print "\nInstallation complete." |
749 print("\nInstallation complete.") |
750 print |
750 print() |
751 |
751 |
752 # check PyXML version and output a message for broken PyXML (< 0.8.6) |
752 # check PyXML version and output a message for broken PyXML (< 0.8.6) |
753 try: |
753 try: |
754 import _xmlplus |
754 import _xmlplus |
755 v = _xmlplus.version_info |
755 v = _xmlplus.version_info |
756 if v < (0, 8, 6): |
756 if v < (0, 8, 6): |
757 from eric4.patch_pyxml import isPatched, patchPyXML |
757 from .eric4.patch_pyxml import isPatched, patchPyXML |
758 if not isPatched(): |
758 if not isPatched(): |
759 print "NOTE:" |
759 print("NOTE:") |
760 print " Found PyXML %d.%d.%d, which needs a patch to work correctly" % \ |
760 print(" Found PyXML %d.%d.%d, which needs a patch to work correctly" % \ |
761 (v[0], v[1], v[2]) |
761 (v[0], v[1], v[2])) |
762 print " with foreign characters. Please see 'README-PyXML.txt' for" |
762 print(" with foreign characters. Please see 'README-PyXML.txt' for") |
763 print " details." |
763 print(" details.") |
764 res = raw_input(" Shall pyXML be patched now (y/n)? ") |
764 res = input(" Shall pyXML be patched now (y/n)? ") |
765 if res in ["Y", "y"]: |
765 if res in ["Y", "y"]: |
766 patchPyXML() |
766 patchPyXML() |
767 except ImportError: |
767 except ImportError: |
768 pass |
768 pass |
769 |
769 |
777 (maj, min, pat) = pyqtVersion.split('.') |
777 (maj, min, pat) = pyqtVersion.split('.') |
778 maj = int(maj) |
778 maj = int(maj) |
779 min = int(min) |
779 min = int(min) |
780 pat = int(pat) |
780 pat = int(pat) |
781 if min < 5: |
781 if min < 5: |
782 print |
782 print() |
783 print "You have to patch PyQt QNetworkAccessManager." |
783 print("You have to patch PyQt QNetworkAccessManager.") |
784 print "See the patches directory for details." |
784 print("See the patches directory for details.") |
785 |
785 |
786 print |
786 print() |
787 if sys.platform.startswith("win"): |
787 if sys.platform.startswith("win"): |
788 raw_input("Press enter to continue...") |
788 input("Press enter to continue...") |
789 |
789 |
790 |
790 |
791 if __name__ == "__main__": |
791 if __name__ == "__main__": |
792 try: |
792 try: |
793 main(sys.argv) |
793 main(sys.argv) |
794 except SystemExit: |
794 except SystemExit: |
795 raise |
795 raise |
796 except: |
796 except: |
797 print \ |
797 print("""An internal error occured. Please report all the output of the program, |
798 """An internal error occured. Please report all the output of the program, |
|
799 including the following traceback, to eric5-bugs@eric-ide.python-projects.org. |
798 including the following traceback, to eric5-bugs@eric-ide.python-projects.org. |
800 """ |
799 """) |
801 raise |
800 raise |