install.py

branch
Py2 comp.
changeset 2680
110ac646a3a0
parent 2677
3d4277929fb3
child 2791
a9577f248f04
diff -r 122a9ffdeefb -r 110ac646a3a0 install.py
--- a/install.py	Thu May 30 15:33:23 2013 +0200
+++ b/install.py	Thu May 30 18:52:46 2013 +0200
@@ -10,6 +10,11 @@
 """
 
 from __future__ import unicode_literals    # __IGNORE_WARNING__
+from __future__ import print_function    # __IGNORE_WARNING__
+try:
+    import io
+except (ImportError):
+    import StringIO as io
 
 import sys
 import os
@@ -20,6 +25,7 @@
 import shutil
 import fnmatch
 import distutils.sysconfig
+import codecs
 
 # Define the globals.
 progName = None
@@ -73,9 +79,10 @@
     global currDir
     
     if sys.platform.startswith("win"):
+        # different meaning of input between Py2 and Py3
         try:
             input("Press enter to continue...")
-        except EOFError:
+        except (EOFError, SyntaxError):
             pass
     
     os.chdir(currDir)
@@ -177,8 +184,8 @@
     @param name the name of the file.
     @param text the contents to copy to the file.
     """
-    f = open(name, "w", encoding="utf-8")
-    f.write(text)
+    f = open(name, "w")
+    f.write(codecs.encode(text, "utf-8"))
     f.close()
 
 
@@ -299,7 +306,7 @@
     if not os.path.exists(fname):
         if not os.path.exists(pdir):
             os.mkdir(pdir,  0o755)
-        f = open(fname, "w", encoding="utf-8")
+        f = open(fname, "w")
         f.write(
 '''# -*- coding: utf-8 -*-
 
@@ -783,7 +790,10 @@
     print('Checking dependencies')
     
     # perform dependency checks
-    if sys.version_info < (3, 1, 0):
+    if sys.version_info < (2, 6, 0):
+        print('Sorry, you must have Python 2.6.0 or higher or Python 3.1.0 or higher.')
+        exit(5)
+    elif sys.version_info < (3, 1, 0):
         print('Sorry, you must have Python 3.1.0 or higher.')
         exit(5)
     if sys.version_info > (3, 9, 9):
@@ -794,7 +804,7 @@
     try:
         import xml.etree            # __IGNORE_WARNING__
     except ImportError as msg:
-        print('Your Python3 installation is missing the XML module.')
+        print('Your Python installation is missing the XML module.')
         print('Please install it and try again.')
         exit(5)
     
@@ -1114,20 +1124,23 @@
     
     if doCompile:
         print("\nCompiling source files ...")
+        # Hide compile errors (mainly because of Py2/Py3 differences)
+        sys.stdout = io.StringIO()
         if distDir:
             compileall.compile_dir(sourceDir,
                 ddir=os.path.join(distDir, modDir, cfg['ericDir']),
-                rx=re.compile(r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"),
+                rx=re.compile(r"DebugClients[\\/]Python[\\/]"),
                 quiet=True)
             py_compile.compile(configName,
                                dfile=os.path.join(distDir, modDir, "eric5config.py"))
         else:
             compileall.compile_dir(sourceDir,
                 ddir=os.path.join(modDir, cfg['ericDir']),
-                rx=re.compile(r"DebugClients[\\/]Python[\\/]|UtilitiesPython2[\\/]"),
+                rx=re.compile(r"DebugClients[\\/]Python[\\/]"),
                 quiet=True)
             py_compile.compile(configName,
                                dfile=os.path.join(modDir, "eric5config.py"))
+        sys.stdout = sys.__stdout__
     print("\nInstalling eric5 ...")
     res = installEric()
     

eric ide

mercurial