6 # This is the install script for eric5. |
6 # This is the install script for eric5. |
7 |
7 |
8 """ |
8 """ |
9 Installation script for the eric5 IDE and all eric5 related tools. |
9 Installation script for the eric5 IDE and all eric5 related tools. |
10 """ |
10 """ |
|
11 |
|
12 from __future__ import unicode_literals |
|
13 from __future__ import print_function |
|
14 try: |
|
15 import cStringIO as io |
|
16 import sip |
|
17 sip.setapi('QString', 2) |
|
18 sip.setapi('QVariant', 2) |
|
19 sip.setapi('QTextStream', 2) |
|
20 except (ImportError): |
|
21 import io # __IGNORE_WARNING__ |
11 |
22 |
12 import sys |
23 import sys |
13 import os |
24 import os |
14 import re |
25 import re |
15 import compileall |
26 import compileall |
16 import py_compile |
27 import py_compile |
17 import glob |
28 import glob |
18 import shutil |
29 import shutil |
19 import fnmatch |
30 import fnmatch |
20 import distutils.sysconfig |
31 import distutils.sysconfig |
|
32 import codecs |
21 |
33 |
22 # Define the globals. |
34 # Define the globals. |
23 progName = None |
35 progName = None |
24 currDir = os.getcwd() |
36 currDir = os.getcwd() |
25 modDir = None |
37 modDir = None |
186 Copy a string to a file. |
199 Copy a string to a file. |
187 |
200 |
188 @param name the name of the file. |
201 @param name the name of the file. |
189 @param text the contents to copy to the file. |
202 @param text the contents to copy to the file. |
190 """ |
203 """ |
191 f = open(name, "w", encoding="utf-8") |
204 f = open(name, "w") |
|
205 if sys.version_info[0] == 2: |
|
206 text = codecs.encode(text, "utf-8") |
192 f.write(text) |
207 f.write(text) |
193 f.close() |
208 f.close() |
194 |
209 |
195 |
210 |
196 def wrapperName(dname, wfile): |
211 def wrapperName(dname, wfile): |
310 pdir = os.path.join(cfg['mdir'], "eric5plugins") |
325 pdir = os.path.join(cfg['mdir'], "eric5plugins") |
311 fname = os.path.join(pdir, "__init__.py") |
326 fname = os.path.join(pdir, "__init__.py") |
312 if not os.path.exists(fname): |
327 if not os.path.exists(fname): |
313 if not os.path.exists(pdir): |
328 if not os.path.exists(pdir): |
314 os.mkdir(pdir, 0o755) |
329 os.mkdir(pdir, 0o755) |
315 f = open(fname, "w", encoding="utf-8") |
330 f = open(fname, "w") |
316 f.write( |
331 f.write( |
317 '''# -*- coding: utf-8 -*- |
332 '''# -*- coding: utf-8 -*- |
318 |
333 |
319 """ |
334 """ |
320 Package containing the global plugins. |
335 Package containing the global plugins. |
847 Perform some dependency checks. |
862 Perform some dependency checks. |
848 """ |
863 """ |
849 print('Checking dependencies') |
864 print('Checking dependencies') |
850 |
865 |
851 # perform dependency checks |
866 # perform dependency checks |
852 if sys.version_info < (3, 1, 0): |
867 if sys.version_info < (2, 6, 0): |
|
868 print('Sorry, you must have Python 2.6.0 or higher or ' |
|
869 'Python 3.1.0 or higher.') |
|
870 exit(5) |
|
871 elif sys.version_info < (3, 1, 0) and sys.version_info[0] == 3: |
853 print('Sorry, you must have Python 3.1.0 or higher.') |
872 print('Sorry, you must have Python 3.1.0 or higher.') |
854 exit(5) |
873 exit(5) |
855 if sys.version_info > (3, 9, 9): |
874 if sys.version_info > (3, 9, 9): |
856 print('Sorry, eric5 requires Python 3 for running.') |
875 print('Sorry, eric5 requires Python 3 for running.') |
857 exit(5) |
876 exit(5) |
858 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3])) |
877 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3])) |
859 |
878 |
860 try: |
879 try: |
861 import xml.etree # __IGNORE_WARNING__ |
880 import xml.etree # __IGNORE_WARNING__ |
862 except ImportError as msg: |
881 except ImportError as msg: |
863 print('Your Python3 installation is missing the XML module.') |
882 print('Your Python installation is missing the XML module.') |
864 print('Please install it and try again.') |
883 print('Please install it and try again.') |
865 exit(5) |
884 exit(5) |
866 |
885 |
867 try: |
886 try: |
868 from PyQt4.QtCore import qVersion |
887 from PyQt4.QtCore import qVersion |
1085 # Parse the command line. |
1104 # Parse the command line. |
1086 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir |
1105 global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir |
1087 global sourceDir, configName |
1106 global sourceDir, configName |
1088 global macAppBundlePath, macAppBundleName, macPythonExe |
1107 global macAppBundlePath, macAppBundleName, macPythonExe |
1089 |
1108 |
1090 if sys.version_info > (3, 9, 9) or sys.version_info < (3, 0, 0): |
1109 if sys.version_info < (2, 6, 0) or sys.version_info > (3, 9, 9): |
1091 print('Sorry, eric5 requires Python 3 for running.') |
1110 print('Sorry, eric5 requires at least Python 2.6 or ' |
|
1111 'Python 3 for running.') |
1092 exit(5) |
1112 exit(5) |
1093 |
1113 |
1094 progName = os.path.basename(argv[0]) |
1114 progName = os.path.basename(argv[0]) |
1095 |
1115 |
1096 if os.path.dirname(argv[0]): |
1116 if os.path.dirname(argv[0]): |
1192 # step 2: compile the forms |
1212 # step 2: compile the forms |
1193 compileUiFiles() |
1213 compileUiFiles() |
1194 |
1214 |
1195 if doCompile: |
1215 if doCompile: |
1196 print("\nCompiling source files ...") |
1216 print("\nCompiling source files ...") |
|
1217 # Hide compile errors (mainly because of Py2/Py3 differences) |
|
1218 sys.stdout = io.StringIO() |
1197 if distDir: |
1219 if distDir: |
1198 compileall.compile_dir( |
1220 compileall.compile_dir( |
1199 sourceDir, |
1221 sourceDir, |
1200 ddir=os.path.join(distDir, modDir, cfg['ericDir']), |
1222 ddir=os.path.join(distDir, modDir, cfg['ericDir']), |
1201 rx=re.compile( |
1223 rx=re.compile(r"DebugClients[\\/]Python[\\/]"), |
1202 r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"), |
|
1203 quiet=True) |
1224 quiet=True) |
1204 py_compile.compile( |
1225 py_compile.compile( |
1205 configName, |
1226 configName, |
1206 dfile=os.path.join(distDir, modDir, "eric5config.py")) |
1227 dfile=os.path.join(distDir, modDir, "eric5config.py")) |
1207 else: |
1228 else: |
1208 compileall.compile_dir( |
1229 compileall.compile_dir( |
1209 sourceDir, |
1230 sourceDir, |
1210 ddir=os.path.join(modDir, cfg['ericDir']), |
1231 ddir=os.path.join(modDir, cfg['ericDir']), |
1211 rx=re.compile( |
1232 rx=re.compile(r"DebugClients[\\/]Python[\\/]"), |
1212 r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"), |
|
1213 quiet=True) |
1233 quiet=True) |
1214 py_compile.compile(configName, |
1234 py_compile.compile(configName, |
1215 dfile=os.path.join(modDir, "eric5config.py")) |
1235 dfile=os.path.join(modDir, "eric5config.py")) |
|
1236 sys.stdout = sys.__stdout__ |
1216 print("\nInstalling eric5 ...") |
1237 print("\nInstalling eric5 ...") |
1217 res = installEric() |
1238 res = installEric() |
1218 |
1239 |
1219 # do some cleanup |
1240 # do some cleanup |
1220 try: |
1241 try: |