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 = \ |
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): |
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) |