Some enhancements to the install and uninstall scripts.

Sun, 24 Jul 2016 16:51:17 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 24 Jul 2016 16:51:17 +0200
changeset 5055
7db1b9496e52
parent 5054
0895e29758cd
child 5059
b619cb765507

Some enhancements to the install and uninstall scripts.

install.py file | annotate | diff | comparison | revisions
uninstall.py file | annotate | diff | comparison | revisions
--- a/install.py	Sun Jul 24 16:50:36 2016 +0200
+++ b/install.py	Sun Jul 24 16:51:17 2016 +0200
@@ -469,10 +469,11 @@
             if os.path.exists(os.path.join(dirName, sourceName + "c")):
                 os.remove(os.path.join(dirName, sourceName + "c"))
     
-    # step 2: delete the __pycache__ directory and all *.pyc files
+    # step 2: delete the __pycache__ directory and all remaining *.pyc files
     if os.path.exists(os.path.join(dirName, "__pycache__")):
         shutil.rmtree(os.path.join(dirName, "__pycache__"))
-    for name in [f for f in dirListing if fnmatch.fnmatch(f, "*.pyc")]:
+    for name in [f for f in os.listdir(dirName)
+                 if fnmatch.fnmatch(f, "*.pyc")]:
         os.remove(os.path.join(dirName, name))
     
     # step 3: descent into subdirectories and delete them if empty
@@ -1477,13 +1478,17 @@
     
     if doCompile:
         print("\nCompiling source files ...")
+        if sys.version_info[0] == 3:
+            skipRe = re.compile(r"DebugClients[\\/]Python[\\/]")
+        else:
+            skipRe = re.compile(r"DebugClients[\\/]Python3[\\/]")
         # 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[\\/]"),
+                rx=skipRe,
                 quiet=True)
             py_compile.compile(
                 configName,
@@ -1492,7 +1497,7 @@
             compileall.compile_dir(
                 sourceDir,
                 ddir=os.path.join(modDir, cfg['ericDir']),
-                rx=re.compile(r"DebugClients[\\/]Python[\\/]"),
+                rx=skipRe,
                 quiet=True)
             py_compile.compile(configName,
                                dfile=os.path.join(modDir, "eric6config.py"))
--- a/uninstall.py	Sun Jul 24 16:50:36 2016 +0200
+++ b/uninstall.py	Sun Jul 24 16:51:17 2016 +0200
@@ -50,11 +50,24 @@
     
     @param rcode result code to report back (integer)
     """
+    global currDir
+    
     # restore the local eric6config.py
     if os.path.exists("eric6config.py.orig"):
         if os.path.exists("eric6config.py"):
             os.remove("eric6config.py")
         os.rename("eric6config.py.orig", "eric6config.py")
+    
+    if sys.platform.startswith("win"):
+        # different meaning of input between Py2 and Py3
+        try:
+            input("Press enter to continue...")
+        except (EOFError, SyntaxError):
+            pass
+    
+    os.chdir(currDir)
+    
+    sys.exit(rcode)
 
 
 def usage(rcode=2):
@@ -345,14 +358,10 @@
         if opt == "-y":
             includePythonVariant = True
     
-    try:
-        uninstallEric()
-    except IOError as msg:
-        sys.stderr.write(
-            'IOError: {0}\nTry uninstall with admin rights.\n'.format(msg))
-    except OSError as msg:
-        sys.stderr.write(
-            'OSError: {0}\nTry uninstall with admin rights.\n'.format(msg))
+    print("\nUninstalling eric6 ...")
+    uninstallEric()
+    print("\nUninstallation complete.")
+    print()
     
     exit(0)
 

eric ide

mercurial