install.py

branch
Py2 comp.
changeset 2680
110ac646a3a0
parent 2677
3d4277929fb3
child 2791
a9577f248f04
equal deleted inserted replaced
2679:122a9ffdeefb 2680:110ac646a3a0
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 11
12 from __future__ import unicode_literals # __IGNORE_WARNING__ 12 from __future__ import unicode_literals # __IGNORE_WARNING__
13 from __future__ import print_function # __IGNORE_WARNING__
14 try:
15 import io
16 except (ImportError):
17 import StringIO as io
13 18
14 import sys 19 import sys
15 import os 20 import os
16 import re 21 import re
17 import compileall 22 import compileall
18 import py_compile 23 import py_compile
19 import glob 24 import glob
20 import shutil 25 import shutil
21 import fnmatch 26 import fnmatch
22 import distutils.sysconfig 27 import distutils.sysconfig
28 import codecs
23 29
24 # Define the globals. 30 # Define the globals.
25 progName = None 31 progName = None
26 currDir = os.getcwd() 32 currDir = os.getcwd()
27 modDir = None 33 modDir = None
71 Exit the install script. 77 Exit the install script.
72 """ 78 """
73 global currDir 79 global currDir
74 80
75 if sys.platform.startswith("win"): 81 if sys.platform.startswith("win"):
82 # different meaning of input between Py2 and Py3
76 try: 83 try:
77 input("Press enter to continue...") 84 input("Press enter to continue...")
78 except EOFError: 85 except (EOFError, SyntaxError):
79 pass 86 pass
80 87
81 os.chdir(currDir) 88 os.chdir(currDir)
82 89
83 sys.exit(rcode) 90 sys.exit(rcode)
175 Copy a string to a file. 182 Copy a string to a file.
176 183
177 @param name the name of the file. 184 @param name the name of the file.
178 @param text the contents to copy to the file. 185 @param text the contents to copy to the file.
179 """ 186 """
180 f = open(name, "w", encoding="utf-8") 187 f = open(name, "w")
181 f.write(text) 188 f.write(codecs.encode(text, "utf-8"))
182 f.close() 189 f.close()
183 190
184 191
185 def wrapperName(dname, wfile): 192 def wrapperName(dname, wfile):
186 """ 193 """
297 pdir = os.path.join(cfg['mdir'], "eric5plugins") 304 pdir = os.path.join(cfg['mdir'], "eric5plugins")
298 fname = os.path.join(pdir, "__init__.py") 305 fname = os.path.join(pdir, "__init__.py")
299 if not os.path.exists(fname): 306 if not os.path.exists(fname):
300 if not os.path.exists(pdir): 307 if not os.path.exists(pdir):
301 os.mkdir(pdir, 0o755) 308 os.mkdir(pdir, 0o755)
302 f = open(fname, "w", encoding="utf-8") 309 f = open(fname, "w")
303 f.write( 310 f.write(
304 '''# -*- coding: utf-8 -*- 311 '''# -*- coding: utf-8 -*-
305 312
306 """ 313 """
307 Package containing the global plugins. 314 Package containing the global plugins.
781 Perform some dependency checks. 788 Perform some dependency checks.
782 """ 789 """
783 print('Checking dependencies') 790 print('Checking dependencies')
784 791
785 # perform dependency checks 792 # perform dependency checks
786 if sys.version_info < (3, 1, 0): 793 if sys.version_info < (2, 6, 0):
794 print('Sorry, you must have Python 2.6.0 or higher or Python 3.1.0 or higher.')
795 exit(5)
796 elif sys.version_info < (3, 1, 0):
787 print('Sorry, you must have Python 3.1.0 or higher.') 797 print('Sorry, you must have Python 3.1.0 or higher.')
788 exit(5) 798 exit(5)
789 if sys.version_info > (3, 9, 9): 799 if sys.version_info > (3, 9, 9):
790 print('Sorry, eric5 requires Python 3 for running.') 800 print('Sorry, eric5 requires Python 3 for running.')
791 exit(5) 801 exit(5)
792 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3])) 802 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3]))
793 803
794 try: 804 try:
795 import xml.etree # __IGNORE_WARNING__ 805 import xml.etree # __IGNORE_WARNING__
796 except ImportError as msg: 806 except ImportError as msg:
797 print('Your Python3 installation is missing the XML module.') 807 print('Your Python installation is missing the XML module.')
798 print('Please install it and try again.') 808 print('Please install it and try again.')
799 exit(5) 809 exit(5)
800 810
801 try: 811 try:
802 from PyQt4.QtCore import qVersion 812 from PyQt4.QtCore import qVersion
1112 # step 2: compile the forms 1122 # step 2: compile the forms
1113 compileUiFiles() 1123 compileUiFiles()
1114 1124
1115 if doCompile: 1125 if doCompile:
1116 print("\nCompiling source files ...") 1126 print("\nCompiling source files ...")
1127 # Hide compile errors (mainly because of Py2/Py3 differences)
1128 sys.stdout = io.StringIO()
1117 if distDir: 1129 if distDir:
1118 compileall.compile_dir(sourceDir, 1130 compileall.compile_dir(sourceDir,
1119 ddir=os.path.join(distDir, modDir, cfg['ericDir']), 1131 ddir=os.path.join(distDir, modDir, cfg['ericDir']),
1120 rx=re.compile(r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"), 1132 rx=re.compile(r"DebugClients[\\/]Python[\\/]"),
1121 quiet=True) 1133 quiet=True)
1122 py_compile.compile(configName, 1134 py_compile.compile(configName,
1123 dfile=os.path.join(distDir, modDir, "eric5config.py")) 1135 dfile=os.path.join(distDir, modDir, "eric5config.py"))
1124 else: 1136 else:
1125 compileall.compile_dir(sourceDir, 1137 compileall.compile_dir(sourceDir,
1126 ddir=os.path.join(modDir, cfg['ericDir']), 1138 ddir=os.path.join(modDir, cfg['ericDir']),
1127 rx=re.compile(r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"), 1139 rx=re.compile(r"DebugClients[\\/]Python[\\/]"),
1128 quiet=True) 1140 quiet=True)
1129 py_compile.compile(configName, 1141 py_compile.compile(configName,
1130 dfile=os.path.join(modDir, "eric5config.py")) 1142 dfile=os.path.join(modDir, "eric5config.py"))
1143 sys.stdout = sys.__stdout__
1131 print("\nInstalling eric5 ...") 1144 print("\nInstalling eric5 ...")
1132 res = installEric() 1145 res = installEric()
1133 1146
1134 # do some cleanup 1147 # do some cleanup
1135 try: 1148 try:

eric ide

mercurial