install.py

branch
Py2 comp.
changeset 2677
3d4277929fb3
parent 2525
8b507a9a2d40
parent 2634
8bd79dfb48a5
child 2680
110ac646a3a0
equal deleted inserted replaced
2670:e60ea6cb8e11 2677:3d4277929fb3
87 """ 87 """
88 Display a usage message and exit. 88 Display a usage message and exit.
89 89
90 @param rcode the return code passed back to the calling process. 90 @param rcode the return code passed back to the calling process.
91 """ 91 """
92 global progName, platBinDir, modDir, distDir, apisDir, macAppBundleName 92 global progName, modDir, distDir, apisDir, macAppBundleName
93 global macPythonExe 93 global macPythonExe
94 94
95 print() 95 print()
96 print("Usage:") 96 print("Usage:")
97 if sys.platform == "darwin": 97 if sys.platform == "darwin":
152 platBinDir = "/usr/local/bin" 152 platBinDir = "/usr/local/bin"
153 153
154 modDir = distutils.sysconfig.get_python_lib(True) 154 modDir = distutils.sysconfig.get_python_lib(True)
155 pyModDir = modDir 155 pyModDir = modDir
156 156
157 try: 157 pyqtDataDir = os.path.join(modDir, "PyQt4")
158 from PyQt4 import pyqtconfig 158 if os.path.exists(os.path.join(pyqtDataDir, "qsci")):
159 pyqtDataDir = pyqtconfig._pkg_config["pyqt_mod_dir"] 159 # it's the installer
160 if os.path.exists(os.path.join(pyqtDataDir, "qsci")): 160 qtDataDir = pyqtDataDir
161 # it's the installer 161 else:
162 qtDataDir = pyqtDataDir 162 try:
163 else: 163 from PyQt4.QtCore import QLibraryInfo
164 qtDataDir = pyqtconfig._pkg_config["qt_data_dir"] 164 qtDataDir = QLibraryInfo.location(QLibraryInfo.DataPath)
165 except (AttributeError, ImportError): 165 except ImportError:
166 qtDataDir = None 166 qtDataDir = None
167 if qtDataDir: 167 if qtDataDir:
168 apisDir = os.path.join(qtDataDir, "qsci", "api") 168 apisDir = os.path.join(qtDataDir, "qsci", "api")
169 else: 169 else:
170 apisDir = None 170 apisDir = None
171 171
213 if sys.platform.startswith("win"): 213 if sys.platform.startswith("win"):
214 wname = wfile + ".bat" 214 wname = wfile + ".bat"
215 if isGuiScript: 215 if isGuiScript:
216 wrapper = \ 216 wrapper = \
217 '''@echo off\n''' \ 217 '''@echo off\n''' \
218 '''set PYDIR=%~dp0\n''' \ 218 '''start "" "{2}\\pythonw.exe"''' \
219 '''start "" "%PYDIR%\\pythonw.exe"''' \
220 ''' "{0}\\{1}.pyw"''' \ 219 ''' "{0}\\{1}.pyw"''' \
221 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(pydir, wfile) 220 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(pydir, wfile, sys.exec_prefix)
222 else: 221 else:
223 wrapper = \ 222 wrapper = \
224 '''@"{0}\\python" "{1}\\{2}.py"''' \ 223 '''@"{0}\\python" "{1}\\{2}.py"''' \
225 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format( 224 ''' %1 %2 %3 %4 %5 %6 %7 %8 %9\n'''.format(
226 platBinDir, pydir, wfile) 225 sys.exec_prefix, pydir, wfile)
227 226
228 # Mac OS X 227 # Mac OS X
229 elif sys.platform == "darwin": 228 elif sys.platform == "darwin":
229 pyexec = "{0}/bin/pythonw3".format(sys.exec_prefix)
230 if not os.path.exists(pyexec):
231 pyexec = "{0}/bin/python3".format(sys.exec_prefix)
230 wname = wfile 232 wname = wfile
231 wrapper = \ 233 wrapper = \
232 '''#!/bin/sh 234 '''#!/bin/sh
233 235
234 exec "{0}/bin/pythonw3" "{1}/{2}.py" "$@" 236 exec "{0}" "{1}/{2}.py" "$@"
235 '''.format(sys.exec_prefix, pydir, wfile) 237 '''.format(pyexec, pydir, wfile)
236 238
237 # *nix systems 239 # *nix systems
238 else: 240 else:
239 wname = wfile 241 wname = wfile
240 wrapper = \ 242 wrapper = \
312 314
313 def cleanUp(): 315 def cleanUp():
314 """ 316 """
315 Uninstall the old eric files. 317 Uninstall the old eric files.
316 """ 318 """
317 global macAppBundleName 319 global macAppBundleName, platBinDir
318 320
319 try: 321 try:
320 from eric5config import getConfig 322 from eric5config import getConfig
321 except ImportError: 323 except ImportError:
322 # eric5 wasn't installed previously 324 # eric5 wasn't installed previously
358 "eric5_snap", 360 "eric5_snap",
359 ] 361 ]
360 362
361 try: 363 try:
362 for rem_wname in rem_wnames: 364 for rem_wname in rem_wnames:
363 rwname = wrapperName(getConfig('bindir'), rem_wname) 365 for d in [platBinDir, getConfig('bindir')]:
364 if os.path.exists(rwname): 366 rwname = wrapperName(d, rem_wname)
365 os.remove(rwname) 367 if os.path.exists(rwname):
368 os.remove(rwname)
366 369
367 # Cleanup our config file(s) 370 # Cleanup our config file(s)
368 for name in ['eric5config.py', 'eric5config.pyc', 'eric5.pth']: 371 for name in ['eric5config.py', 'eric5config.pyc', 'eric5.pth']:
369 e5cfile = os.path.join(pyModDir, name) 372 e5cfile = os.path.join(pyModDir, name)
370 if os.path.exists(e5cfile): 373 if os.path.exists(e5cfile):
1083 os.remove(configName) 1086 os.remove(configName)
1084 except EnvironmentError: 1087 except EnvironmentError:
1085 pass 1088 pass
1086 1089
1087 # cleanup old installation 1090 # cleanup old installation
1091 print("Cleaning up old installation ...")
1088 try: 1092 try:
1089 if doCleanup: 1093 if doCleanup:
1090 if distDir: 1094 if distDir:
1091 shutil.rmtree(distDir, True) 1095 shutil.rmtree(distDir, True)
1092 else: 1096 else:
1094 except (IOError, OSError) as msg: 1098 except (IOError, OSError) as msg:
1095 sys.stderr.write('Error: {0}\nTry install as root.\n'.format(msg)) 1099 sys.stderr.write('Error: {0}\nTry install as root.\n'.format(msg))
1096 exit(7) 1100 exit(7)
1097 1101
1098 # Create a config file and delete the default one 1102 # Create a config file and delete the default one
1103 print("\nCreating configuration file ...")
1099 createConfig() 1104 createConfig()
1100 1105
1101 # Compile .ui files 1106 # Compile .ui files
1102 print("Compiling user interface files...") 1107 print("\nCompiling user interface files ...")
1103 # step 1: remove old Ui_*.py files 1108 # step 1: remove old Ui_*.py files
1104 for root, _, files in os.walk(sourceDir): 1109 for root, _, files in os.walk(sourceDir):
1105 for file in [f for f in files if fnmatch.fnmatch(f, 'Ui_*.py')]: 1110 for file in [f for f in files if fnmatch.fnmatch(f, 'Ui_*.py')]:
1106 os.remove(os.path.join(root, file)) 1111 os.remove(os.path.join(root, file))
1107 # step 2: compile the forms 1112 # step 2: compile the forms
1108 compileUiFiles() 1113 compileUiFiles()
1109 1114
1110 if doCompile: 1115 if doCompile:
1111 print("\nCompiling source files...") 1116 print("\nCompiling source files ...")
1112 if distDir: 1117 if distDir:
1113 compileall.compile_dir(sourceDir, 1118 compileall.compile_dir(sourceDir,
1114 ddir=os.path.join(distDir, modDir, cfg['ericDir']), 1119 ddir=os.path.join(distDir, modDir, cfg['ericDir']),
1115 rx=re.compile(r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"), 1120 rx=re.compile(r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"),
1116 quiet=True) 1121 quiet=True)

eric ide

mercurial