install.py

branch
maintenance
changeset 6693
3629d88ae235
parent 6664
50c9c1c9cf30
child 6760
448de556dd34
--- a/install.py	Thu Jan 10 14:23:49 2019 +0100
+++ b/install.py	Sat Feb 02 11:12:54 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"
@@ -1229,6 +1237,16 @@
     shutilCopy(os.path.join(sourceDir, "pixmaps", "eric_2.icns"),
                os.path.join(dirs["icns"], "eric.icns"))
     
+    if os.path.exists(os.path.join("eric", "UI", "Info.py")):
+        # Installing from archive
+        from eric.UI.Info import Version, CopyrightShort
+    elif os.path.exists(os.path.join("UI", "Info.py")):
+        # Installing from source tree
+        from UI.Info import Version, CopyrightShort
+    else:
+        Version = "Unknown"
+        CopyrightShort = "(c) 2002 - 2019 Detlev Offenbach"
+    
     copyToFile(
         os.path.join(dirs["contents"], "Info.plist"),
         '''<?xml version="1.0" encoding="UTF-8"?>\n'''
@@ -1241,7 +1259,7 @@
         '''    <key>CFBundleIconFile</key>\n'''
         '''    <string>eric.icns</string>\n'''
         '''    <key>CFBundleInfoDictionaryVersion</key>\n'''
-        '''    <string>1.0</string>\n'''
+        '''    <string>{1}</string>\n'''
         '''    <key>CFBundleName</key>\n'''
         '''    <string>{0}</string>\n'''
         '''    <key>CFBundleDisplayName</key>\n'''
@@ -1249,13 +1267,18 @@
         '''    <key>CFBundlePackageType</key>\n'''
         '''    <string>APPL</string>\n'''
         '''    <key>CFBundleSignature</key>\n'''
-        '''    <string>????</string>\n'''
+        '''    <string>ERIC-IDE</string>\n'''
         '''    <key>CFBundleVersion</key>\n'''
-        '''    <string>1.0</string>\n'''
+        '''    <string>{1}</string>\n'''
+        '''    <key>CFBundleGetInfoString</key>\n'''
+        '''    <string>{1}, {2}</string>\n'''
         '''    <key>CFBundleIdentifier</key>\n'''
         '''    <string>org.python-projects.eric-ide</string>\n'''
         '''</dict>\n'''
-        '''</plist>\n'''.format(macAppBundleName.replace(".app", "")))
+        '''</plist>\n'''.format(
+            macAppBundleName.replace(".app", ""),
+            Version.split(None, 1)[0],
+            CopyrightShort))
 
 
 def createInstallConfig():
@@ -1472,10 +1495,14 @@
         try:
             from PyQt5 import QtWebEngineWidgets    # __IGNORE_WARNING__
         except ImportError as msg:
-            installed = pipInstall(
-                "PyQtWebEngine",
-                "PyQtWebEngine could not be detected.\nError: {0}".format(msg)
-            )
+            from PyQt5.QtCore import PYQT_VERSION
+            if PYQT_VERSION >= 0x50c00:
+                # PyQt 5.12 separated QtWebEngine into a separate wheel
+                installed = pipInstall(
+                    "PyQtWebEngine",
+                    "PyQtWebEngine could not be detected.\nError: {0}"
+                    .format(msg)
+                )
     
     try:
         if pyqtVariant == "PyQt4":
@@ -1571,9 +1598,9 @@
     print("Qt Version: {0}".format(qVersion().strip()))
     if qtMajor < 4 or \
         (qtMajor == 4 and qtMinor < 8) or \
-            (qtMajor == 5 and qtMinor < 3):
+            (qtMajor == 5 and qtMinor < 6):
         print('Sorry, you must have Qt version 4.8.0 or better or')
-        print('5.3.0 or better.')
+        print('5.6.0 or better.')
         exit(2)
     
     # check version of sip
@@ -1627,7 +1654,7 @@
             (major == 4 and minor < 10) or \
                 (major == 5 and minor < 3):
             print('Sorry, you must have PyQt 4.10.0 or better or')
-            print('PyQt 5.3.0 or better or'
+            print('PyQt 5.6.0 or better or'
                   ' a recent snapshot release.')
             exit(4)
         # check for blacklisted versions
@@ -1860,7 +1887,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 '
@@ -1933,8 +1960,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