install.py: updated help texts and added an option (--clean-desktop) to delete the desktop links before installation on Windows.

Sat, 19 Jan 2019 15:58:03 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 19 Jan 2019 15:58:03 +0100
changeset 6663
fe9da2b5d148
parent 6662
0002926e71d3
child 6664
50c9c1c9cf30

install.py: updated help texts and added an option (--clean-desktop) to delete the desktop links before installation on Windows.

install.py file | annotate | diff | comparison | revisions
--- a/install.py	Sat Jan 19 14:31:48 2019 +0100
+++ b/install.py	Sat Jan 19 15:58:03 2019 +0100
@@ -47,6 +47,8 @@
 apisDir = None
 installApis = True
 doCleanup = True
+doCleanDesktopLinks = False
+forceCleanDesktopLinks = False
 doCompile = True
 includePythonVariant = False
 cfg = {}
@@ -141,14 +143,15 @@
     print("Usage:")
     if sys.platform == "darwin":
         print("    {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
-              " [-m name] [-p python] [--pyqt=version]".format(progName))
+              " [-m name] [-n path] [-p python] [--no-apis] [--pyqt=version]"
+              .format(progName))
     elif sys.platform.startswith(("win", "cygwin")):
         print("    {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file]"
-              " [--pyqt=version]"
+              " [--clean-desktop] [--no-apis] [--pyqt=version]"
               .format(progName))
     else:
         print("    {0} [-chxyz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"
-              " [--pyqt=version]"
+              " [--no-apis] [--pyqt=version]"
               .format(progName))
     print("where:")
     print("    -h, --help display this help message")
@@ -157,7 +160,7 @@
         print("               (default: {0})".format(apisDir))
     else:
         print("               (no default value)")
-    print("    --noapis   don't install API files")
+    print("    --no-apis  don't install API files")
     print("    -b dir     where the binaries will be installed")
     print("               (default: {0})".format(platBinDir))
     print("    -d dir     where eric6 python files will be installed")
@@ -176,6 +179,8 @@
         print("    -p python  path of the python executable")
         print("               (default: {0})".format(macPythonExe))
     print("    -c         don't cleanup old installation first")
+    if sys.platform.startswith(("win", "cygwin")):
+        ("    --clean-desktop delete desktop links before installation")
     print("    -x         don't perform dependency checks (use on your own"
           " risk)")
     print("    -y         add the Python variant to the executable names")
@@ -737,6 +742,8 @@
     """
     Clean up the Desktop and Start Menu entries for Windows.
     """
+    global doCleanDesktopLinks, forceCleanDesktopLinks
+    
     try:
         from pywintypes import com_error        # __IGNORE_WARNING__
     except ImportError:
@@ -746,19 +753,20 @@
     regPath = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer" + \
               "\\User Shell Folders"
     
-    # 1. cleanup desktop links
-    regName = "Desktop"
-    desktopEntry = getWinregEntry(regName, regPath)
-    if desktopEntry:
-        desktopFolder = os.path.normpath(os.path.expandvars(desktopEntry))
-        for linkName in windowsDesktopNames():
-            linkPath = os.path.join(desktopFolder, linkName)
-            if os.path.exists(linkPath):
-                try:
-                    os.remove(linkPath)
-                except EnvironmentError:
-                    # maybe restrictions prohibited link removal
-                    print("Could not remove '{0}'.".format(linkPath))
+    if doCleanDesktopLinks or forceCleanDesktopLinks:
+        # 1. cleanup desktop links
+        regName = "Desktop"
+        desktopEntry = getWinregEntry(regName, regPath)
+        if desktopEntry:
+            desktopFolder = os.path.normpath(os.path.expandvars(desktopEntry))
+            for linkName in windowsDesktopNames():
+                linkPath = os.path.join(desktopFolder, linkName)
+                if os.path.exists(linkPath):
+                    try:
+                        os.remove(linkPath)
+                    except EnvironmentError:
+                        # maybe restrictions prohibited link removal
+                        print("Could not remove '{0}'.".format(linkPath))
     
     # 2. cleanup start menu entry
     regName = "Programs"
@@ -1864,7 +1872,7 @@
     global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
     global sourceDir, configName, includePythonVariant
     global macAppBundlePath, macAppBundleName, macPythonExe
-    global pyqtVariant, pyqtOverride, installApis
+    global pyqtVariant, pyqtOverride, installApis, doCleanDesktopLinks
     
     if sys.version_info < (2, 7, 0) or sys.version_info > (3, 9, 9):
         print('Sorry, eric6 requires at least Python 2.7 or '
@@ -1937,8 +1945,10 @@
                 exit(6)
             pyqtVariant = "PyQt{0}".format(arg)
             pyqtOverride = True
-        elif "--noapis":
+        elif opt == "--no-apis":
             installApis = False
+        elif opt == "--clean-desktop":
+            doCleanDesktopLinks = True
     
     infoName = ""
     installFromSource = not os.path.isdir(sourceDir)

eric ide

mercurial