install.py

changeset 2577
14296525eff5
parent 2480
30477cebf808
child 2583
92b902f6455e
equal deleted inserted replaced
2576:b984efd69f15 2577:14296525eff5
23 progName = None 23 progName = None
24 currDir = os.getcwd() 24 currDir = os.getcwd()
25 modDir = None 25 modDir = None
26 pyModDir = None 26 pyModDir = None
27 platBinDir = None 27 platBinDir = None
28 scriptsDir = None
28 distDir = None 29 distDir = None
29 apisDir = None 30 apisDir = None
30 doCleanup = True 31 doCleanup = True
31 doCompile = True 32 doCompile = True
32 cfg = {} 33 cfg = {}
85 """ 86 """
86 Display a usage message and exit. 87 Display a usage message and exit.
87 88
88 @param rcode the return code passed back to the calling process. 89 @param rcode the return code passed back to the calling process.
89 """ 90 """
90 global progName, platBinDir, modDir, distDir, apisDir, macAppBundleName 91 global progName, scriptsDir, modDir, distDir, apisDir, macAppBundleName
91 global macPythonExe 92 global macPythonExe
92 93
93 print() 94 print()
94 print("Usage:") 95 print("Usage:")
95 if sys.platform == "darwin": 96 if sys.platform == "darwin":
107 if apisDir: 108 if apisDir:
108 print(" (default: {0})".format(apisDir)) 109 print(" (default: {0})".format(apisDir))
109 else: 110 else:
110 print(" (no default value)") 111 print(" (no default value)")
111 print(" -b dir where the binaries will be installed") 112 print(" -b dir where the binaries will be installed")
112 print(" (default: {0})".format(platBinDir)) 113 print(" (default: {0})".format(scriptsDir))
113 print(" -d dir where eric5 python files will be installed") 114 print(" -d dir where eric5 python files will be installed")
114 print(" (default: {0})".format(modDir)) 115 print(" (default: {0})".format(modDir))
115 print(" -f file configuration file naming the various installation paths") 116 print(" -f file configuration file naming the various installation paths")
116 if not sys.platform.startswith("win"): 117 if not sys.platform.startswith("win"):
117 print(" -i dir temporary install prefix") 118 print(" -i dir temporary install prefix")
138 139
139 def initGlobals(): 140 def initGlobals():
140 """ 141 """
141 Sets the values of globals that need more than a simple assignment. 142 Sets the values of globals that need more than a simple assignment.
142 """ 143 """
143 global platBinDir, modDir, pyModDir, apisDir 144 global platBinDir, scriptsDir, modDir, pyModDir, apisDir
144 145
145 if sys.platform.startswith("win"): 146 if sys.platform.startswith("win"):
146 platBinDir = sys.exec_prefix 147 platBinDir = sys.exec_prefix
147 if platBinDir.endswith("\\"): 148 if platBinDir.endswith("\\"):
148 platBinDir = platBinDir[:-1] 149 platBinDir = platBinDir[:-1]
150 scriptsDir = os.path.join(platBinDir, "Scripts")
149 else: 151 else:
150 platBinDir = "/usr/local/bin" 152 platBinDir = "/usr/local/bin"
153 scriptsDir = platBinDir
151 154
152 modDir = distutils.sysconfig.get_python_lib(True) 155 modDir = distutils.sysconfig.get_python_lib(True)
153 pyModDir = modDir 156 pyModDir = modDir
154 157
155 try: 158 try:
219 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(pydir, wfile) 222 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(pydir, wfile)
220 else: 223 else:
221 wrapper = \ 224 wrapper = \
222 '''@"{0}\\python" "{1}\\{2}.py"''' \ 225 '''@"{0}\\python" "{1}\\{2}.py"''' \
223 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format( 226 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(
224 platBinDir, pydir, wfile) 227 sys.exec_prefix, pydir, wfile)
225 228
226 # Mac OS X 229 # Mac OS X
227 elif sys.platform == "darwin": 230 elif sys.platform == "darwin":
228 wname = wfile 231 wname = wfile
229 wrapper = \ 232 wrapper = \
310 313
311 def cleanUp(): 314 def cleanUp():
312 """ 315 """
313 Uninstall the old eric files. 316 Uninstall the old eric files.
314 """ 317 """
315 global macAppBundleName 318 global macAppBundleName, platBinDir, scriptsDir
316 319
317 try: 320 try:
318 from eric5config import getConfig 321 from eric5config import getConfig
319 except ImportError: 322 except ImportError:
320 # eric5 wasn't installed previously 323 # eric5 wasn't installed previously
356 "eric5_snap", 359 "eric5_snap",
357 ] 360 ]
358 361
359 try: 362 try:
360 for rem_wname in rem_wnames: 363 for rem_wname in rem_wnames:
361 rwname = wrapperName(getConfig('bindir'), rem_wname) 364 for d in [platBinDir, scriptsDir, getConfig('bindir')]:
362 if os.path.exists(rwname): 365 rwname = wrapperName(d, rem_wname)
363 os.remove(rwname) 366 if os.path.exists(rwname):
367 os.remove(rwname)
364 368
365 # Cleanup our config file(s) 369 # Cleanup our config file(s)
366 for name in ['eric5config.py', 'eric5config.pyc', 'eric5.pth']: 370 for name in ['eric5config.py', 'eric5config.pyc', 'eric5.pth']:
367 e5cfile = os.path.join(pyModDir, name) 371 e5cfile = os.path.join(pyModDir, name)
368 if os.path.exists(e5cfile): 372 if os.path.exists(e5cfile):
679 683
680 def createInstallConfig(): 684 def createInstallConfig():
681 """ 685 """
682 Create the installation config dictionary. 686 Create the installation config dictionary.
683 """ 687 """
684 global modDir, platBinDir, cfg, apisDir 688 global modDir, scriptsDir, cfg, apisDir
685 689
686 ericdir = os.path.join(modDir, "eric5") 690 ericdir = os.path.join(modDir, "eric5")
687 cfg = { 691 cfg = {
688 'ericDir': ericdir, 692 'ericDir': ericdir,
689 'ericPixDir': os.path.join(ericdir, "pixmaps"), 693 'ericPixDir': os.path.join(ericdir, "pixmaps"),
695 'ericExamplesDir': os.path.join(ericdir, "Examples"), 699 'ericExamplesDir': os.path.join(ericdir, "Examples"),
696 'ericTranslationsDir': os.path.join(ericdir, "i18n"), 700 'ericTranslationsDir': os.path.join(ericdir, "i18n"),
697 'ericTemplatesDir': os.path.join(ericdir, "DesignerTemplates"), 701 'ericTemplatesDir': os.path.join(ericdir, "DesignerTemplates"),
698 'ericCodeTemplatesDir': os.path.join(ericdir, 'CodeTemplates'), 702 'ericCodeTemplatesDir': os.path.join(ericdir, 'CodeTemplates'),
699 'ericOthersDir': ericdir, 703 'ericOthersDir': ericdir,
700 'bindir': platBinDir, 704 'bindir': scriptsDir,
701 'mdir': modDir, 705 'mdir': modDir,
702 } 706 }
703 if apisDir: 707 if apisDir:
704 cfg['apidir'] = apisDir 708 cfg['apidir'] = apisDir
705 else: 709 else:
1023 else: 1027 else:
1024 optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:i:") 1028 optlist, args = getopt.getopt(argv[1:], "chxza:b:d:f:i:")
1025 except getopt.GetoptError: 1029 except getopt.GetoptError:
1026 usage() 1030 usage()
1027 1031
1028 global platBinDir 1032 global scriptsDir
1029 1033
1030 depChecks = True 1034 depChecks = True
1031 1035
1032 for opt, arg in optlist: 1036 for opt, arg in optlist:
1033 if opt == "-h": 1037 if opt == "-h":
1034 usage(0) 1038 usage(0)
1035 elif opt == "-a": 1039 elif opt == "-a":
1036 apisDir = arg 1040 apisDir = arg
1037 elif opt == "-b": 1041 elif opt == "-b":
1038 platBinDir = arg 1042 scriptsDir = arg
1039 elif opt == "-d": 1043 elif opt == "-d":
1040 modDir = arg 1044 modDir = arg
1041 elif opt == "-i": 1045 elif opt == "-i":
1042 distDir = os.path.normpath(arg) 1046 distDir = os.path.normpath(arg)
1043 elif opt == "-x": 1047 elif opt == "-x":

eric ide

mercurial