install.py

changeset 433
988006cb898f
parent 390
daa7c6ae6248
child 441
dec3dd52411a
equal deleted inserted replaced
432:497e188ee86e 433:988006cb898f
48 """ 48 """
49 global progName, platBinDir, modDir, distDir, apisDir 49 global progName, platBinDir, modDir, distDir, apisDir
50 50
51 print() 51 print()
52 print("Usage:") 52 print("Usage:")
53 print(" %s [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" % (progName)) 53 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"\
54 .format(progName))
54 print("where:") 55 print("where:")
55 print(" -h display this help message") 56 print(" -h display this help message")
56 print(" -a dir where the API files will be installed") 57 print(" -a dir where the API files will be installed")
57 if apisDir: 58 if apisDir:
58 print(" (default: %s)" % (apisDir)) 59 print(" (default: {0})".format(apisDir))
59 else: 60 else:
60 print(" (no default value)") 61 print(" (no default value)")
61 print(" -b dir where the binaries will be installed") 62 print(" -b dir where the binaries will be installed")
62 print(" (default: %s)" % (platBinDir)) 63 print(" (default: {0})".format(platBinDir))
63 print(" -d dir where eric5 python files will be installed") 64 print(" -d dir where eric5 python files will be installed")
64 print(" (default: %s)" % (modDir)) 65 print(" (default: {0})".format(modDir))
65 print(" -f file configuration file naming the various installation paths") 66 print(" -f file configuration file naming the various installation paths")
66 if not sys.platform.startswith("win"): 67 if not sys.platform.startswith("win"):
67 print(" -i dir temporary install prefix") 68 print(" -i dir temporary install prefix")
68 print(" (default: %s)" % (distDir)) 69 print(" (default: {0})".format(distDir))
69 print(" -x don't perform dependency checks (use on your own risk)") 70 print(" -x don't perform dependency checks (use on your own risk)")
70 print(" -c don't cleanup old installation first") 71 print(" -c don't cleanup old installation first")
71 print(" -z don't compile the installed python files") 72 print(" -z don't compile the installed python files")
72 print() 73 print()
73 print("The file given to the -f option must be valid Python code defining a") 74 print("The file given to the -f option must be valid Python code defining a")
147 """ 148 """
148 # all kinds of Windows systems 149 # all kinds of Windows systems
149 if sys.platform.startswith("win"): 150 if sys.platform.startswith("win"):
150 wname = wfile + ".bat" 151 wname = wfile + ".bat"
151 wrapper = \ 152 wrapper = \
152 '''@"%s\\pythonw" "%s\\%s.py" %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 153 '''@"{0}\\pythonw" "{1}\\{2}.py" %1 %2 %3 %4 %5 %6 %7 %8 %9
153 ''' % (platBinDir, pydir, wfile) 154 '''.format(platBinDir, pydir, wfile)
154 155
155 # Mac OS X 156 # Mac OS X
156 elif sys.platform == "darwin": 157 elif sys.platform == "darwin":
157 wname = wfile 158 wname = wfile
158 wrapper = \ 159 wrapper = \
159 '''#!/bin/sh 160 '''#!/bin/sh
160 161
161 exec "%s/bin/pythonw3" "%s/%s.py" "$@" 162 exec "{0}/bin/pythonw3" "{1}/{2}.py" "$@"
162 ''' % (sys.exec_prefix, pydir, wfile) 163 '''.format(sys.exec_prefix, pydir, wfile)
163 164
164 # *nix systems 165 # *nix systems
165 else: 166 else:
166 wname = wfile 167 wname = wfile
167 wrapper = \ 168 wrapper = \
168 '''#!/bin/sh 169 '''#!/bin/sh
169 170
170 exec "%s" "%s/%s.py" "$@" 171 exec "{0}" "{1}/{2}.py" "$@"
171 ''' % (sys.executable, pydir, wfile) 172 '''.format(sys.executable, pydir, wfile)
172 173
173 copyToFile(wname, wrapper) 174 copyToFile(wname, wrapper)
174 os.chmod(wname, 0o755) 175 os.chmod(wname, 0o755)
175 176
176 return wname 177 return wname
344 if os.path.exists('eric5config.pyc'): 345 if os.path.exists('eric5config.pyc'):
345 shutil.copy('eric5config.pyc', modDir) 346 shutil.copy('eric5config.pyc', modDir)
346 347
347 # copy the various parts of eric5 348 # copy the various parts of eric5
348 copyTree('eric', cfg['ericDir'], ['*.py', '*.pyc', '*.pyo', '*.pyw'], 349 copyTree('eric', cfg['ericDir'], ['*.py', '*.pyc', '*.pyo', '*.pyw'],
349 ['eric%sExamples' % os.sep]) 350 ['eric{0}Examples'.format(os.sep)])
350 copyTree('eric', cfg['ericDir'], ['*.rb'], 351 copyTree('eric', cfg['ericDir'], ['*.rb'],
351 ['eric%sExamples' % os.sep]) 352 ['eric{0}Examples'.format(os.sep)])
352 copyTree('eric%sPlugins' % os.sep, '%s%sPlugins' % (cfg['ericDir'], os.sep), 353 copyTree('eric{0}Plugins'.format(os.sep),
354 '{0}{1}Plugins'.format(cfg['ericDir'], os.sep),
353 ['*.png', '*.style']) 355 ['*.png', '*.style'])
354 copyTree('eric%sDocumentation' % os.sep, cfg['ericDocDir'], ['*.html', '*.qch']) 356 copyTree('eric{0}Documentation'.format(os.sep), cfg['ericDocDir'],
355 copyTree('eric%sDTDs' % os.sep, cfg['ericDTDDir'], ['*.dtd']) 357 ['*.html', '*.qch'])
356 copyTree('eric%sCSSs' % os.sep, cfg['ericCSSDir'], ['*.css']) 358 copyTree('eric{0}DTDs'.format(os.sep), cfg['ericDTDDir'], ['*.dtd'])
357 copyTree('eric%sStyles' % os.sep, cfg['ericStylesDir'], ['*.qss']) 359 copyTree('eric{0}CSSs'.format(os.sep), cfg['ericCSSDir'], ['*.css'])
358 copyTree('eric%si18n' % os.sep, cfg['ericTranslationsDir'], ['*.qm']) 360 copyTree('eric{0}Styles'.format(os.sep), cfg['ericStylesDir'], ['*.qss'])
359 copyTree('eric%sicons' % os.sep, cfg['ericIconDir'], ['*.png', 'LICENSE*.*']) 361 copyTree('eric{0}i18n'.format(os.sep), cfg['ericTranslationsDir'], ['*.qm'])
360 copyTree('eric%spixmaps' % os.sep, cfg['ericPixDir'], ['*.png', '*.xpm', '*.ico']) 362 copyTree('eric{0}icons'.format(os.sep), cfg['ericIconDir'],
361 copyTree('eric%sDesignerTemplates' % os.sep, cfg['ericTemplatesDir'], ['*.tmpl']) 363 ['*.png', 'LICENSE*.*'])
362 copyTree('eric%sCodeTemplates' % os.sep, cfg['ericCodeTemplatesDir'], ['*.tmpl']) 364 copyTree('eric{0}pixmaps'.format(os.sep), cfg['ericPixDir'],
363 copyTree('eric%sExamples' % os.sep, cfg['ericExamplesDir'], 365 ['*.png', '*.xpm', '*.ico'])
364 ['*.py', '*.pyc', '*.pyo']) 366 copyTree('eric{0}DesignerTemplates'.format(os.sep), cfg['ericTemplatesDir'],
367 ['*.tmpl'])
368 copyTree('eric{0}CodeTemplates'.format(os.sep), cfg['ericCodeTemplatesDir'],
369 ['*.tmpl'])
370 copyTree('eric{0}Examples'.format(os.sep), cfg['ericExamplesDir'],
371 ['*.py', '*.pyc', '*.pyo'])
365 372
366 # copy the wrappers 373 # copy the wrappers
367 for wname in wnames: 374 for wname in wnames:
368 shutil.copy(wname, cfg['bindir']) 375 shutil.copy(wname, cfg['bindir'])
369 376
370 # copy the license file 377 # copy the license file
371 shutil.copy('eric%sLICENSE.GPL3' % os.sep, cfg['ericDir']) 378 shutil.copy('eric{0}LICENSE.GPL3'.format(os.sep), cfg['ericDir'])
372 379
373 # create the global plugins directory 380 # create the global plugins directory
374 createGlobalPluginsDir() 381 createGlobalPluginsDir()
375 382
376 except IOError as msg: 383 except IOError as msg:
377 sys.stderr.write('IOError: %s\nTry install as root.\n' % msg) 384 sys.stderr.write('IOError: {0}\nTry install as root.\n'.format(msg))
378 exit(7) 385 exit(7)
379 386
380 except OSError as msg: 387 except OSError as msg:
381 sys.stderr.write('OSError: %s\nTry install with admin rights.\n' % msg) 388 sys.stderr.write('OSError: {0}\nTry install with admin rights.\n'.format(msg))
382 exit(7) 389 exit(7)
383 390
384 # copy some text files to the doc area 391 # copy some text files to the doc area
385 for name in ["LICENSE.GPL3", "THANKS", "changelog"]: 392 for name in ["LICENSE.GPL3", "THANKS", "changelog"]:
386 try: 393 try:
387 shutil.copy('eric%s%s' % (os.sep, name), cfg['ericDocDir']) 394 shutil.copy('eric{0}{1}'.format(os.sep, name), cfg['ericDocDir'])
388 except EnvironmentError: 395 except EnvironmentError:
389 print("Could not install 'eric%s%s'." % (os.sep, name)) 396 print("Could not install 'eric{0}{1}'.".format(os.sep, name))
390 for name in glob.glob(os.path.join('eric', 'README*.*')): 397 for name in glob.glob(os.path.join('eric', 'README*.*')):
391 try: 398 try:
392 shutil.copy(name, cfg['ericDocDir']) 399 shutil.copy(name, cfg['ericDocDir'])
393 except EnvironmentError: 400 except EnvironmentError:
394 print("Could not install 'eric%s%s'." % (os.sep, name)) 401 print("Could not install 'eric{0}{1}'.".format(os.sep, name))
395 402
396 # copy some more stuff 403 # copy some more stuff
397 for name in ['default.e4k']: 404 for name in ['default.e4k']:
398 try: 405 try:
399 shutil.copy('eric%s%s' % (os.sep, name), cfg['ericOthersDir']) 406 shutil.copy('eric{0}{1}'.format(os.sep, name), cfg['ericOthersDir'])
400 except EnvironmentError: 407 except EnvironmentError:
401 print("Could not install 'eric%s%s'." % (os.sep, name)) 408 print("Could not install 'eric{0}{1}'.".format(os.sep, name))
402 409
403 # install the API file 410 # install the API file
404 for progLanguage in progLanguages: 411 for progLanguage in progLanguages:
405 apidir = os.path.join(cfg['apidir'], progLanguage.lower()) 412 apidir = os.path.join(cfg['apidir'], progLanguage.lower())
406 if not os.path.exists(apidir): 413 if not os.path.exists(apidir):
407 os.makedirs(apidir) 414 os.makedirs(apidir)
408 for apiName in glob.glob(os.path.join("eric", "APIs", progLanguage, "*.api")): 415 for apiName in glob.glob(os.path.join("eric", "APIs", progLanguage, "*.api")):
409 try: 416 try:
410 shutil.copy(apiName, apidir) 417 shutil.copy(apiName, apidir)
411 except EnvironmentError: 418 except EnvironmentError:
412 print("Could not install '%s'." % apiName) 419 print("Could not install '{0}'.".format(apiName))
413 if progLanguage == "Python": 420 if progLanguage == "Python":
414 # copy Python3 API files to the same destination 421 # copy Python3 API files to the same destination
415 for apiName in glob.glob(os.path.join("eric", "APIs", "Python3", "*.api")): 422 for apiName in glob.glob(os.path.join("eric", "APIs", "Python3", "*.api")):
416 try: 423 try:
417 shutil.copy(apiName, apidir) 424 shutil.copy(apiName, apidir)
418 except EnvironmentError: 425 except EnvironmentError:
419 print("Could not install '%s'." % apiName) 426 print("Could not install '{0}'.".format(apiName))
420 427
421 # create menu entry for Linux systems 428 # create menu entry for Linux systems
422 if sys.platform.startswith("linux"): 429 if sys.platform.startswith("linux"):
423 if distDir: 430 if distDir:
424 shutil.copy(os.path.join("eric", "icons", "default", "eric.png"), 431 shutil.copy(os.path.join("eric", "icons", "default", "eric.png"),
482 # 489 #
483 # This module contains the configuration of the individual eric5 installation 490 # This module contains the configuration of the individual eric5 installation
484 # 491 #
485 492
486 _pkg_config = { 493 _pkg_config = {
487 'ericDir' : r'%s', 494 'ericDir' : r'{0}',
488 'ericPixDir' : r'%s', 495 'ericPixDir' : r'{1}',
489 'ericIconDir' : r'%s', 496 'ericIconDir' : r'{2}',
490 'ericDTDDir' : r'%s', 497 'ericDTDDir' : r'{3}',
491 'ericCSSDir' : r'%s', 498 'ericCSSDir' : r'{4}',
492 'ericStylesDir' : r'%s', 499 'ericStylesDir' : r'{5}',
493 'ericDocDir' : r'%s', 500 'ericDocDir' : r'{6}',
494 'ericExamplesDir' : r'%s', 501 'ericExamplesDir' : r'{7}',
495 'ericTranslationsDir' : r'%s', 502 'ericTranslationsDir' : r'{8}',
496 'ericTemplatesDir' : r'%s', 503 'ericTemplatesDir' : r'{9}',
497 'ericCodeTemplatesDir' : r'%s', 504 'ericCodeTemplatesDir' : r'{10}',
498 'ericOthersDir' : r'%s', 505 'ericOthersDir' : r'{11}',
499 'bindir' : r'%s', 506 'bindir' : r'{12}',
500 'mdir' : r'%s', 507 'mdir' : r'{13}',
501 'apidir' : r'%s', 508 'apidir' : r'{14}',
502 'apis' : %s, 509 'apis' : {15},
503 } 510 }
504 511
505 def getConfig(name): 512 def getConfig(name):
506 ''' 513 '''
507 Module function to get a configuration value. 514 Module function to get a configuration value.
511 try: 518 try:
512 return _pkg_config[name] 519 return _pkg_config[name]
513 except KeyError: 520 except KeyError:
514 pass 521 pass
515 522
516 raise AttributeError('"%%s" is not a valid configuration value' %% name) 523 raise AttributeError('"{{0}}" is not a valid configuration value'.format(name))
517 """ % (cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'], 524 """.format(cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'],
518 cfg['ericDTDDir'], cfg['ericCSSDir'], 525 cfg['ericDTDDir'], cfg['ericCSSDir'],
519 cfg['ericStylesDir'], cfg['ericDocDir'], 526 cfg['ericStylesDir'], cfg['ericDocDir'],
520 cfg['ericExamplesDir'], cfg['ericTranslationsDir'], 527 cfg['ericExamplesDir'], cfg['ericTranslationsDir'],
521 cfg['ericTemplatesDir'], 528 cfg['ericTemplatesDir'],
522 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'], 529 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'],
523 cfg['bindir'], cfg['mdir'], 530 cfg['bindir'], cfg['mdir'],
524 cfg['apidir'], apis) 531 cfg['apidir'], apis)
525 copyToFile(fn, config) 532 copyToFile(fn, config)
526 533
527 def doDependancyChecks(): 534 def doDependancyChecks():
528 """ 535 """
529 Perform some dependency checks. 536 Perform some dependency checks.
535 print('Sorry, you must have Python 3.1.0 or higher.') 542 print('Sorry, you must have Python 3.1.0 or higher.')
536 exit(5) 543 exit(5)
537 if sys.version_info > (3, 9, 9): 544 if sys.version_info > (3, 9, 9):
538 print('Sorry, eric5 requires Python 3 for running.') 545 print('Sorry, eric5 requires Python 3 for running.')
539 exit(5) 546 exit(5)
540 print("Python Version: %d.%d.%d" % sys.version_info[:3]) 547 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3]))
541 548
542 try: 549 try:
543 from PyQt4.QtCore import qVersion 550 from PyQt4.QtCore import qVersion
544 except ImportError as msg: 551 except ImportError as msg:
545 print('Sorry, please install PyQt4.') 552 print('Sorry, please install PyQt4.')
546 print('Error: %s' % msg) 553 print('Error: {0}'.format(msg))
547 exit(1) 554 exit(1)
548 print("Found PyQt") 555 print("Found PyQt")
549 556
550 try: 557 try:
551 from PyQt4 import Qsci 558 from PyQt4 import Qsci
552 except ImportError as msg: 559 except ImportError as msg:
553 print("Sorry, please install QScintilla2 and") 560 print("Sorry, please install QScintilla2 and")
554 print("it's PyQt4 wrapper.") 561 print("it's PyQt4 wrapper.")
555 print('Error: %s' % msg) 562 print('Error: {0}'.format(msg))
556 exit(1) 563 exit(1)
557 print("Found QScintilla2") 564 print("Found QScintilla2")
558 565
559 # check version of Qt 566 # check version of Qt
560 qtMajor = int(qVersion().split('.')[0]) 567 qtMajor = int(qVersion().split('.')[0])
561 qtMinor = int(qVersion().split('.')[1]) 568 qtMinor = int(qVersion().split('.')[1])
562 if qtMajor < 4 or (qtMajor == 4 and qtMinor < 5): 569 if qtMajor < 4 or (qtMajor == 4 and qtMinor < 5):
563 print('Sorry, you must have Qt version 4.5.0 or higher.') 570 print('Sorry, you must have Qt version 4.5.0 or higher.')
564 exit(2) 571 exit(2)
565 print("Qt Version: %s" % qVersion()) 572 print("Qt Version: {0}".format(qVersion()))
566 573
567 #check version of PyQt 574 #check version of PyQt
568 from PyQt4.QtCore import PYQT_VERSION_STR 575 from PyQt4.QtCore import PYQT_VERSION_STR
569 pyqtVersion = PYQT_VERSION_STR 576 pyqtVersion = PYQT_VERSION_STR
570 # always assume, that snapshots are new enough 577 # always assume, that snapshots are new enough
678 685
679 @param py_dir suggested name of the directory (string) 686 @param py_dir suggested name of the directory (string)
680 @param py_file suggested name for the compile source file (string) 687 @param py_file suggested name for the compile source file (string)
681 @return tuple of directory name (string) and source file name (string) 688 @return tuple of directory name (string) and source file name (string)
682 """ 689 """
683 return py_dir, "Ui_%s" % py_file 690 return py_dir, "Ui_{0}".format(py_file)
684 691
685 compileUiDir("eric", True, pyName) 692 compileUiDir("eric", True, pyName)
686 693
687 def main(argv): 694 def main(argv):
688 """ 695 """
729 doCompile = False 736 doCompile = False
730 elif opt == "-f": 737 elif opt == "-f":
731 try: 738 try:
732 exec(compile(open(arg).read(), arg, 'exec'), globals()) 739 exec(compile(open(arg).read(), arg, 'exec'), globals())
733 if len(cfg) != configLength: 740 if len(cfg) != configLength:
734 print("The configuration dictionary in '%s' is incorrect. Aborting"\ 741 print("The configuration dictionary in '{0}' is incorrect. Aborting"\
735 % arg) 742 .format(arg))
736 exit(6) 743 exit(6)
737 except: 744 except:
738 cfg = {} 745 cfg = {}
739 746
740 if len(cfg) == 0: 747 if len(cfg) == 0:
755 if distDir: 762 if distDir:
756 shutil.rmtree(distDir, True) 763 shutil.rmtree(distDir, True)
757 else: 764 else:
758 cleanUp() 765 cleanUp()
759 except IOError as msg: 766 except IOError as msg:
760 sys.stderr.write('IOError: %s\nTry install as root.\n' % msg) 767 sys.stderr.write('IOError: {0}\nTry install as root.\n'.format(msg))
761 768
762 # Create a config file and delete the default one 769 # Create a config file and delete the default one
763 createConfig() 770 createConfig()
764 771
765 # Compile .ui files 772 # Compile .ui files
793 v = _xmlplus.version_info 800 v = _xmlplus.version_info
794 if v < (0, 8, 6): 801 if v < (0, 8, 6):
795 from eric5.patch_pyxml import isPatched, patchPyXML 802 from eric5.patch_pyxml import isPatched, patchPyXML
796 if not isPatched(): 803 if not isPatched():
797 print("NOTE:") 804 print("NOTE:")
798 print(" Found PyXML %d.%d.%d, which needs a patch to work correctly" % \ 805 print(" Found PyXML {0:d}.{1:d}.{2:d}, which needs a patch "
799 (v[0], v[1], v[2])) 806 "to work correctly".format(v[0], v[1], v[2]))
800 print(" with foreign characters. Please see 'README-PyXML.txt' for") 807 print(" with foreign characters. Please see 'README-PyXML.txt' for")
801 print(" details.") 808 print(" details.")
802 res = input(" Shall pyXML be patched now (y/n)? ") 809 res = input(" Shall pyXML be patched now (y/n)? ")
803 if res in ["Y", "y"]: 810 if res in ["Y", "y"]:
804 patchPyXML() 811 patchPyXML()

eric ide

mercurial