install.py

branch
Py2 comp.
changeset 3515
1b8381afe38f
parent 3178
f25fc1364c88
parent 3510
31d7e522ecb2
child 3539
0c2dc1446ebf
equal deleted inserted replaced
3506:d85fadb263a0 3515:1b8381afe38f
40 distDir = None 40 distDir = None
41 apisDir = None 41 apisDir = None
42 doCleanup = True 42 doCleanup = True
43 doCompile = True 43 doCompile = True
44 cfg = {} 44 cfg = {}
45 progLanguages = ["Python", "Ruby"] 45 progLanguages = ["Python", "Ruby", "QSS"]
46 sourceDir = "eric" 46 sourceDir = "eric"
47 configName = 'eric5config.py' 47 configName = 'eric5config.py'
48 defaultMacAppBundleName = "eric5.app" 48 defaultMacAppBundleName = "eric5.app"
49 macAppBundleName = "eric5.app" 49 macAppBundleName = "eric5.app"
50 macAppBundlePath = "/Applications"
50 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format( 51 macPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(
51 sys.exec_prefix) 52 sys.exec_prefix)
52 53
53 # Define blacklisted versions of the prerequisites 54 # Define blacklisted versions of the prerequisites
54 BlackLists = { 55 BlackLists = {
101 """ 102 """
102 Display a usage message and exit. 103 Display a usage message and exit.
103 104
104 @param rcode the return code passed back to the calling process. 105 @param rcode the return code passed back to the calling process.
105 """ 106 """
106 global progName, modDir, distDir, apisDir, macAppBundleName 107 global progName, modDir, distDir, apisDir
107 global macPythonExe 108 global macAppBundleName, macAppBundlePath, macPythonExe
108 109
109 print() 110 print()
110 print("Usage:") 111 print("Usage:")
111 if sys.platform == "darwin": 112 if sys.platform == "darwin":
112 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" 113 print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
134 print(" -i dir temporary install prefix") 135 print(" -i dir temporary install prefix")
135 print(" (default: {0})".format(distDir)) 136 print(" (default: {0})".format(distDir))
136 if sys.platform == "darwin": 137 if sys.platform == "darwin":
137 print(" -m name name of the Mac app bundle") 138 print(" -m name name of the Mac app bundle")
138 print(" (default: {0})".format(macAppBundleName)) 139 print(" (default: {0})".format(macAppBundleName))
140 print(" -n path path of the directory the Mac app bundle will")
141 print(" be created in")
142 print(" (default: {0}".format(macAppBundlePath))
139 print(" -p python name of the python executable") 143 print(" -p python name of the python executable")
140 print(" (default: {0})".format(macPythonExe)) 144 print(" (default: {0})".format(macPythonExe))
141 print(" -x don't perform dependency checks (use on your own" 145 print(" -x don't perform dependency checks (use on your own"
142 " risk)") 146 " risk)")
143 print(" -c don't cleanup old installation first") 147 print(" -c don't cleanup old installation first")
320 324
321 pdir = os.path.join(cfg['mdir'], "eric5plugins") 325 pdir = os.path.join(cfg['mdir'], "eric5plugins")
322 fname = os.path.join(pdir, "__init__.py") 326 fname = os.path.join(pdir, "__init__.py")
323 if not os.path.exists(fname): 327 if not os.path.exists(fname):
324 if not os.path.exists(pdir): 328 if not os.path.exists(pdir):
325 os.mkdir(pdir, 0o755) 329 os.mkdir(pdir, 0o755)
326 f = open(fname, "w") 330 f = open(fname, "w")
327 f.write( 331 f.write(
328 '''# -*- coding: utf-8 -*- 332 '''# -*- coding: utf-8 -*-
329 333
330 """ 334 """
338 342
339 def cleanUp(): 343 def cleanUp():
340 """ 344 """
341 Uninstall the old eric files. 345 Uninstall the old eric files.
342 """ 346 """
343 global macAppBundleName, platBinDir 347 global macAppBundleName, macAppBundlePath, platBinDir
344 348
345 try: 349 try:
346 from eric5config import getConfig 350 from eric5config import getConfig
347 except ImportError: 351 except ImportError:
348 # eric5 wasn't installed previously 352 # eric5 wasn't installed previously
431 435
432 if sys.platform == "darwin": 436 if sys.platform == "darwin":
433 # delete the Mac app bundle 437 # delete the Mac app bundle
434 if os.path.exists("/Developer/Applications/Eric5"): 438 if os.path.exists("/Developer/Applications/Eric5"):
435 shutil.rmtree("/Developer/Applications/Eric5") 439 shutil.rmtree("/Developer/Applications/Eric5")
440 try:
441 macAppBundlePath = getConfig("macAppBundlePath")
442 macAppBundleName = getConfig("macAppBundleName")
443 except AttributeError:
444 macAppBundlePath = "/Applications"
445 macAppBundleName = "eric5.app"
436 if os.path.exists("/Applications/" + macAppBundleName): 446 if os.path.exists("/Applications/" + macAppBundleName):
437 shutil.rmtree("/Applications/" + macAppBundleName) 447 shutil.rmtree("/Applications/" + macAppBundleName)
448 bundlePath = os.path.join(macAppBundlePath, macAppBundleName)
449 if os.path.exists(bundlePath):
450 shutil.rmtree(bundlePath)
438 451
439 except (IOError, OSError) as msg: 452 except (IOError, OSError) as msg:
440 sys.stderr.write( 453 sys.stderr.write(
441 'Error: {0}\nTry install with admin rights.\n'.format(msg)) 454 'Error: {0}\nTry install with admin rights.\n'.format(msg))
442 exit(7) 455 exit(7)
668 Create a Mac application bundle. 681 Create a Mac application bundle.
669 682
670 @param pydir the name of the directory where the Python script will 683 @param pydir the name of the directory where the Python script will
671 eventually be installed (string) 684 eventually be installed (string)
672 """ 685 """
673 global cfg, sourceDir, macAppBundleName, macPythonExe 686 global cfg, sourceDir, macAppBundleName, macPythonExe, macAppBundlePath
674 687
675 dirs = {"contents": "/Applications/{0}/Contents/".format(macAppBundleName), 688 dirs = {
676 "exe": "/Applications/{0}/Contents/MacOS".format(macAppBundleName), 689 "contents": "{0}/{1}/Contents/".format(
677 "icns": "/Applications/{0}/Contents/Resources".format( 690 macAppBundlePath, macAppBundleName),
678 macAppBundleName)} 691 "exe": "{0}/{1}/Contents/MacOS".format(
692 macAppBundlePath, macAppBundleName),
693 "icns": "{0}/{1}/Contents/Resources".format(
694 macAppBundlePath, macAppBundleName)
695 }
679 os.makedirs(dirs["contents"]) 696 os.makedirs(dirs["contents"])
680 os.mkdir(dirs["exe"]) 697 os.makedirs(dirs["exe"])
681 os.mkdir(dirs["icns"]) 698 os.makedirs(dirs["icns"])
682 699
683 if macAppBundleName == defaultMacAppBundleName: 700 if macAppBundleName == defaultMacAppBundleName:
684 starter = os.path.join(dirs["exe"], "eric") 701 starter = os.path.join(dirs["exe"], "eric")
685 os.symlink(macPythonExe, starter) 702 os.symlink(macPythonExe, starter)
686 else: 703 else:
769 786
770 def createConfig(): 787 def createConfig():
771 """ 788 """
772 Create a config file with the respective config entries. 789 Create a config file with the respective config entries.
773 """ 790 """
774 global cfg, sourceDir 791 global cfg, sourceDir, macAppBundlePath
775 792
776 apis = [] 793 apis = []
777 for progLanguage in progLanguages: 794 for progLanguage in progLanguages:
778 for apiName in glob.glob( 795 for apiName in glob.glob(
779 os.path.join(sourceDir, "APIs", progLanguage, "*.api")): 796 os.path.join(sourceDir, "APIs", progLanguage, "*.api")):
807 """ 'ericOthersDir': r'{11}',\n""" 824 """ 'ericOthersDir': r'{11}',\n"""
808 """ 'bindir': r'{12}',\n""" 825 """ 'bindir': r'{12}',\n"""
809 """ 'mdir': r'{13}',\n""" 826 """ 'mdir': r'{13}',\n"""
810 """ 'apidir': r'{14}',\n""" 827 """ 'apidir': r'{14}',\n"""
811 """ 'apis': {15},\n""" 828 """ 'apis': {15},\n"""
829 """ 'macAppBundlePath': r'{16}',\n"""
830 """ 'macAppBundleName': r'{17}',\n"""
812 """}}\n""" 831 """}}\n"""
813 """\n""" 832 """\n"""
814 """def getConfig(name):\n""" 833 """def getConfig(name):\n"""
815 """ '''\n""" 834 """ '''\n"""
816 """ Module function to get a configuration value.\n""" 835 """ Module function to get a configuration value.\n"""
821 """ return _pkg_config[name]\n""" 840 """ return _pkg_config[name]\n"""
822 """ except KeyError:\n""" 841 """ except KeyError:\n"""
823 """ pass\n""" 842 """ pass\n"""
824 """\n""" 843 """\n"""
825 """ raise AttributeError('"{{0}}" is not a valid configuration""" 844 """ raise AttributeError('"{{0}}" is not a valid configuration"""
826 """ value'.format(name))\n""").format( 845 """ value'.format(name))\n"""
846 ).format(
827 cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'], 847 cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'],
828 cfg['ericDTDDir'], cfg['ericCSSDir'], 848 cfg['ericDTDDir'], cfg['ericCSSDir'],
829 cfg['ericStylesDir'], cfg['ericDocDir'], 849 cfg['ericStylesDir'], cfg['ericDocDir'],
830 cfg['ericExamplesDir'], cfg['ericTranslationsDir'], 850 cfg['ericExamplesDir'], cfg['ericTranslationsDir'],
831 cfg['ericTemplatesDir'], 851 cfg['ericTemplatesDir'],
832 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'], 852 cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'],
833 cfg['bindir'], cfg['mdir'], 853 cfg['bindir'], cfg['mdir'],
834 cfg['apidir'], apis) 854 cfg['apidir'], apis,
855 macAppBundlePath, macAppBundleName,
856 )
835 copyToFile(fn, config) 857 copyToFile(fn, config)
836 858
837 859
838 def doDependancyChecks(): 860 def doDependancyChecks():
839 """ 861 """
1079 """ 1101 """
1080 import getopt 1102 import getopt
1081 1103
1082 # Parse the command line. 1104 # Parse the command line.
1083 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir 1105 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
1084 global sourceDir, configName, macAppBundleName, macPythonExe 1106 global sourceDir, configName
1107 global macAppBundlePath, macAppBundleName, macPythonExe
1085 1108
1086 if sys.version_info < (2, 6, 0) or sys.version_info > (3, 9, 9): 1109 if sys.version_info < (2, 6, 0) or sys.version_info > (3, 9, 9):
1087 print('Sorry, eric5 requires at least Python 2.6 or ' 1110 print('Sorry, eric5 requires at least Python 2.6 or '
1088 'Python 3 for running.') 1111 'Python 3 for running.')
1089 exit(5) 1112 exit(5)
1135 exit(6) 1158 exit(6)
1136 except: 1159 except:
1137 cfg = {} 1160 cfg = {}
1138 elif opt == "-m": 1161 elif opt == "-m":
1139 macAppBundleName = arg 1162 macAppBundleName = arg
1163 elif opt == "-n":
1164 macAppBundlePath = arg
1140 elif opt == "-p": 1165 elif opt == "-p":
1141 macPythonExe = arg 1166 macPythonExe = arg
1142 1167
1143 installFromSource = not os.path.isdir(sourceDir) 1168 installFromSource = not os.path.isdir(sourceDir)
1144 if installFromSource: 1169 if installFromSource:

eric ide

mercurial