install.py

changeset 3507
b09e10d4f343
parent 3468
869d0b6e1e16
child 3508
4861f0bb3509
equal deleted inserted replaced
3503:2e98a3705f15 3507:b09e10d4f343
33 progLanguages = ["Python", "Ruby", "QSS"] 33 progLanguages = ["Python", "Ruby", "QSS"]
34 sourceDir = "eric" 34 sourceDir = "eric"
35 configName = 'eric5config.py' 35 configName = 'eric5config.py'
36 defaultMacAppBundleName = "eric5.app" 36 defaultMacAppBundleName = "eric5.app"
37 macAppBundleName = "eric5.app" 37 macAppBundleName = "eric5.app"
38 macAppBundlePath = "/Applications"
38 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format( 39 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(
39 sys.exec_prefix) 40 sys.exec_prefix)
40 41
41 # Define blacklisted versions of the prerequisites 42 # Define blacklisted versions of the prerequisites
42 BlackLists = { 43 BlackLists = {
88 """ 89 """
89 Display a usage message and exit. 90 Display a usage message and exit.
90 91
91 @param rcode the return code passed back to the calling process. 92 @param rcode the return code passed back to the calling process.
92 """ 93 """
93 global progName, modDir, distDir, apisDir, macAppBundleName 94 global progName, modDir, distDir, apisDir
94 global macPythonExe 95 global macAppBundleName, macAppBundlePath, macPythonExe
95 96
96 print() 97 print()
97 print("Usage:") 98 print("Usage:")
98 if sys.platform == "darwin": 99 if sys.platform == "darwin":
99 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 100 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
121 print(" -i dir temporary install prefix") 122 print(" -i dir temporary install prefix")
122 print(" (default: {0})".format(distDir)) 123 print(" (default: {0})".format(distDir))
123 if sys.platform == "darwin": 124 if sys.platform == "darwin":
124 print(" -m name name of the Mac app bundle") 125 print(" -m name name of the Mac app bundle")
125 print(" (default: {0})".format(macAppBundleName)) 126 print(" (default: {0})".format(macAppBundleName))
127 print(" -n path path of the directory the Mac app bundle will")
128 print(" be created in")
129 print(" (default: {0}".format(macAppBundlePath))
126 print(" -p python name of the python executable") 130 print(" -p python name of the python executable")
127 print(" (default: {0})".format(macPythonExe)) 131 print(" (default: {0})".format(macPythonExe))
128 print(" -x don't perform dependency checks (use on your own" 132 print(" -x don't perform dependency checks (use on your own"
129 " risk)") 133 " risk)")
130 print(" -c don't cleanup old installation first") 134 print(" -c don't cleanup old installation first")
305 309
306 pdir = os.path.join(cfg['mdir'], "eric5plugins") 310 pdir = os.path.join(cfg['mdir'], "eric5plugins")
307 fname = os.path.join(pdir, "__init__.py") 311 fname = os.path.join(pdir, "__init__.py")
308 if not os.path.exists(fname): 312 if not os.path.exists(fname):
309 if not os.path.exists(pdir): 313 if not os.path.exists(pdir):
310 os.mkdir(pdir, 0o755) 314 os.mkdir(pdir, 0o755)
311 f = open(fname, "w", encoding="utf-8") 315 f = open(fname, "w", encoding="utf-8")
312 f.write( 316 f.write(
313 '''# -*- coding: utf-8 -*- 317 '''# -*- coding: utf-8 -*-
314 318
315 """ 319 """
323 327
324 def cleanUp(): 328 def cleanUp():
325 """ 329 """
326 Uninstall the old eric files. 330 Uninstall the old eric files.
327 """ 331 """
328 global macAppBundleName, platBinDir 332 global macAppBundleName, macAppBundlePath, platBinDir
329 333
330 try: 334 try:
331 from eric5config import getConfig 335 from eric5config import getConfig
332 except ImportError: 336 except ImportError:
333 # eric5 wasn't installed previously 337 # eric5 wasn't installed previously
416 420
417 if sys.platform == "darwin": 421 if sys.platform == "darwin":
418 # delete the Mac app bundle 422 # delete the Mac app bundle
419 if os.path.exists("/Developer/Applications/Eric5"): 423 if os.path.exists("/Developer/Applications/Eric5"):
420 shutil.rmtree("/Developer/Applications/Eric5") 424 shutil.rmtree("/Developer/Applications/Eric5")
421 if os.path.exists("/Applications/" + macAppBundleName): 425 if os.path.exists(
422 shutil.rmtree("/Applications/" + macAppBundleName) 426 os.path.join(macAppBundlePath, macAppBundleName)):
427 shutil.rmtree(
428 os.path.join(macAppBundlePath, macAppBundleName))
423 429
424 except (IOError, OSError) as msg: 430 except (IOError, OSError) as msg:
425 sys.stderr.write( 431 sys.stderr.write(
426 'Error: {0}\nTry install with admin rights.\n'.format(msg)) 432 'Error: {0}\nTry install with admin rights.\n'.format(msg))
427 exit(7) 433 exit(7)
653 Create a Mac application bundle. 659 Create a Mac application bundle.
654 660
655 @param pydir the name of the directory where the Python script will 661 @param pydir the name of the directory where the Python script will
656 eventually be installed (string) 662 eventually be installed (string)
657 """ 663 """
658 global cfg, sourceDir, macAppBundleName, macPythonExe 664 global cfg, sourceDir, macAppBundleName, macPythonExe, macAppBundlePath
659 665
660 dirs = {"contents": "/Applications/{0}/Contents/".format(macAppBundleName), 666 dirs = {
661 "exe": "/Applications/{0}/Contents/MacOS".format(macAppBundleName), 667 "contents": "{0}/{1}/Contents/".format(
662 "icns": "/Applications/{0}/Contents/Resources".format( 668 macAppBundlePath, macAppBundleName),
663 macAppBundleName)} 669 "exe": "{0}/{1}/Contents/MacOS".format(
670 macAppBundlePath, macAppBundleName),
671 "icns": "{0}/{1}/Contents/Resources".format(
672 macAppBundlePath, macAppBundleName)
673 }
664 os.makedirs(dirs["contents"]) 674 os.makedirs(dirs["contents"])
665 os.mkdir(dirs["exe"]) 675 os.mkdirs(dirs["exe"])
666 os.mkdir(dirs["icns"]) 676 os.mkdirs(dirs["icns"])
667 677
668 if macAppBundleName == defaultMacAppBundleName: 678 if macAppBundleName == defaultMacAppBundleName:
669 starter = os.path.join(dirs["exe"], "eric") 679 starter = os.path.join(dirs["exe"], "eric")
670 os.symlink(macPythonExe, starter) 680 os.symlink(macPythonExe, starter)
671 else: 681 else:
754 764
755 def createConfig(): 765 def createConfig():
756 """ 766 """
757 Create a config file with the respective config entries. 767 Create a config file with the respective config entries.
758 """ 768 """
759 global cfg, sourceDir 769 global cfg, sourceDir, macAppBundlePath
760 770
761 apis = [] 771 apis = []
762 for progLanguage in progLanguages: 772 for progLanguage in progLanguages:
763 for apiName in glob.glob( 773 for apiName in glob.glob(
764 os.path.join(sourceDir, "APIs", progLanguage, "*.api")): 774 os.path.join(sourceDir, "APIs", progLanguage, "*.api")):
792 """ 'ericOthersDir': r'{11}',\n""" 802 """ 'ericOthersDir': r'{11}',\n"""
793 """ 'bindir': r'{12}',\n""" 803 """ 'bindir': r'{12}',\n"""
794 """ 'mdir': r'{13}',\n""" 804 """ 'mdir': r'{13}',\n"""
795 """ 'apidir': r'{14}',\n""" 805 """ 'apidir': r'{14}',\n"""
796 """ 'apis': {15},\n""" 806 """ 'apis': {15},\n"""
807 """ 'macAppBundlePath': {16},\n"""
808 """ 'macAppBundleName': {17},\n"""
797 """}}\n""" 809 """}}\n"""
798 """\n""" 810 """\n"""
799 """def getConfig(name):\n""" 811 """def getConfig(name):\n"""
800 """ '''\n""" 812 """ '''\n"""
801 """ Module function to get a configuration value.\n""" 813 """ Module function to get a configuration value.\n"""
806 """ return _pkg_config[name]\n""" 818 """ return _pkg_config[name]\n"""
807 """ except KeyError:\n""" 819 """ except KeyError:\n"""
808 """ pass\n""" 820 """ pass\n"""
809 """\n""" 821 """\n"""
810 """ raise AttributeError('"{{0}}" is not a valid configuration""" 822 """ raise AttributeError('"{{0}}" is not a valid configuration"""
811 """ value'.format(name))\n""").format( 823 """ value'.format(name))\n"""
824 ).format(
812 cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'], 825 cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'],
813 cfg['ericDTDDir'], cfg['ericCSSDir'], 826 cfg['ericDTDDir'], cfg['ericCSSDir'],
814 cfg['ericStylesDir'], cfg['ericDocDir'], 827 cfg['ericStylesDir'], cfg['ericDocDir'],
815 cfg['ericExamplesDir'], cfg['ericTranslationsDir'], 828 cfg['ericExamplesDir'], cfg['ericTranslationsDir'],
816 cfg['ericTemplatesDir'], 829 cfg['ericTemplatesDir'],
817 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'], 830 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'],
818 cfg['bindir'], cfg['mdir'], 831 cfg['bindir'], cfg['mdir'],
819 cfg['apidir'], apis) 832 cfg['apidir'], apis,
833 macAppBundlePath, macAppBundleName,
834 )
820 copyToFile(fn, config) 835 copyToFile(fn, config)
821 836
822 837
823 def doDependancyChecks(): 838 def doDependancyChecks():
824 """ 839 """
1060 """ 1075 """
1061 import getopt 1076 import getopt
1062 1077
1063 # Parse the command line. 1078 # Parse the command line.
1064 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir 1079 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
1065 global sourceDir, configName, macAppBundleName, macPythonExe 1080 global sourceDir, configName
1081 global macAppBundlePath, macAppBundleName, macPythonExe
1066 1082
1067 if sys.version_info > (3, 9, 9) or sys.version_info < (3, 0, 0): 1083 if sys.version_info > (3, 9, 9) or sys.version_info < (3, 0, 0):
1068 print('Sorry, eric5 requires Python 3 for running.') 1084 print('Sorry, eric5 requires Python 3 for running.')
1069 exit(5) 1085 exit(5)
1070 1086
1115 exit(6) 1131 exit(6)
1116 except: 1132 except:
1117 cfg = {} 1133 cfg = {}
1118 elif opt == "-m": 1134 elif opt == "-m":
1119 macAppBundleName = arg 1135 macAppBundleName = arg
1136 elif opt == "-n":
1137 macAppBundlePath = arg
1120 elif opt == "-p": 1138 elif opt == "-p":
1121 macPythonExe = arg 1139 macPythonExe = arg
1122 1140
1123 installFromSource = not os.path.isdir(sourceDir) 1141 installFromSource = not os.path.isdir(sourceDir)
1124 if installFromSource: 1142 if installFromSource:

eric ide

mercurial