Extended install script to mark more files with Python variant markers and added the '--noapis' switch to suppress API files installation. 5_5_x

Thu, 27 Nov 2014 19:48:04 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 27 Nov 2014 19:48:04 +0100
branch
5_5_x
changeset 3944
3fa14b95871e
parent 3941
f8a9af3d8b56
child 3945
3bd92b662b7e

Extended install script to mark more files with Python variant markers and added the '--noapis' switch to suppress API files installation.

eric5.desktop file | annotate | diff | comparison | revisions
eric5_webbrowser.desktop file | annotate | diff | comparison | revisions
install.py file | annotate | diff | comparison | revisions
uninstall.py file | annotate | diff | comparison | revisions
--- a/eric5.desktop	Tue Nov 25 19:31:28 2014 +0100
+++ b/eric5.desktop	Thu Nov 27 19:48:04 2014 +0100
@@ -3,7 +3,7 @@
 Type=Application
 Exec=eric5@MARKER@
 MimeType=text/x-python;
-Icon=eric
+Icon=eric@MARKER@
 Terminal=false
 Name=eric5
 Name[de]=eric5
--- a/eric5_webbrowser.desktop	Tue Nov 25 19:31:28 2014 +0100
+++ b/eric5_webbrowser.desktop	Thu Nov 27 19:48:04 2014 +0100
@@ -3,7 +3,7 @@
 Type=Application
 Exec=eric5_webbrowser@MARKER@
 MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;
-Icon=ericWeb
+Icon=ericWeb@MARKER@
 Terminal=false
 Name=eric5 Web Browser
 Name[de]=eric5 Web Browser
--- a/install.py	Tue Nov 25 19:31:28 2014 +0100
+++ b/install.py	Thu Nov 27 19:48:04 2014 +0100
@@ -39,6 +39,7 @@
 platBinDir = None
 distDir = None
 apisDir = None
+installApis = True
 doCleanup = True
 doCompile = True
 includePythonVariant = False
@@ -133,6 +134,7 @@
         print("              (default: {0})".format(apisDir))
     else:
         print("              (no default value)")
+    print("    --noapis  don't install API files")
     print("    -b dir    where the binaries will be installed")
     print("              (default: {0})".format(platBinDir))
     print("    -d dir    where eric5 python files will be installed")
@@ -569,7 +571,7 @@
     @return result code (integer)
     """
     global distDir, doCleanup, cfg, progLanguages, sourceDir, configName
-    global includePythonVariant
+    global includePythonVariant, installApis
     
     # Create the platform specific wrappers.
     wnames = []
@@ -694,47 +696,49 @@
                 os.sep, name, sourceDir))
     
     # install the API file
-    from PyQt4.QtCore import qVersion
-    for progLanguage in progLanguages:
-        apidir = os.path.join(cfg['apidir'], progLanguage.lower())
-        if not os.path.exists(apidir):
-            os.makedirs(apidir)
-        for apiName in glob.glob(os.path.join(sourceDir, "APIs",
-                                              progLanguage, "*.api")):
-            try:
-                shutilCopy(apiName, apidir)
-            except EnvironmentError:
-                print("Could not install '{0}'.".format(apiName))
-        for apiName in glob.glob(os.path.join(sourceDir, "APIs",
-                                              progLanguage, "*.bas")):
-            try:
-                shutilCopy(apiName, apidir)
-            except EnvironmentError:
-                print("Could not install '{0}'.".format(apiName))
-        if progLanguage == "Python":
-            # copy Python3 API files to the same destination
+    if installApis:
+        for progLanguage in progLanguages:
+            apidir = os.path.join(cfg['apidir'], progLanguage.lower())
+            if not os.path.exists(apidir):
+                os.makedirs(apidir)
             for apiName in glob.glob(os.path.join(sourceDir, "APIs",
-                                                  "Python3", "*.api")):
+                                                  progLanguage, "*.api")):
                 try:
                     shutilCopy(apiName, apidir)
                 except EnvironmentError:
                     print("Could not install '{0}'.".format(apiName))
             for apiName in glob.glob(os.path.join(sourceDir, "APIs",
-                                                  "Python3", "*.bas")):
+                                                  progLanguage, "*.bas")):
                 try:
-                    if os.path.basename(apiName).startswith("PyQt4"):
-                        # only install the PyQt4 file matching the Qt version
-                        if os.path.splitext(apiName)[0].endswith(
-                                qVersion().split(".")[0]):
-                            shutilCopy(apiName,
-                                       os.path.join(apidir, "PyQt4.bas"))
-                        continue
-                    if os.path.exists(os.path.join(
-                        apidir, os.path.basename(
-                            apiName.replace(".bas", ".api")))):
-                        shutilCopy(apiName, apidir)
+                    shutilCopy(apiName, apidir)
                 except EnvironmentError:
                     print("Could not install '{0}'.".format(apiName))
+            if progLanguage == "Python":
+                # copy Python3 API files to the same destination
+                for apiName in glob.glob(os.path.join(sourceDir, "APIs",
+                                                      "Python3", "*.api")):
+                    try:
+                        shutilCopy(apiName, apidir)
+                    except EnvironmentError:
+                        print("Could not install '{0}'.".format(apiName))
+                for apiName in glob.glob(os.path.join(sourceDir, "APIs",
+                                                      "Python3", "*.bas")):
+                    try:
+                        if os.path.basename(apiName).startswith("PyQt4"):
+                            # only install the PyQt4 file matching the
+                            #  Qt version
+                            from PyQt4.QtCore import qVersion
+                            if os.path.splitext(apiName)[0].endswith(
+                                    qVersion().split(".")[0]):
+                                shutilCopy(apiName,
+                                           os.path.join(apidir, "PyQt4.bas"))
+                            continue
+                        if os.path.exists(os.path.join(
+                            apidir, os.path.basename(
+                                apiName.replace(".bas", ".api")))):
+                            shutilCopy(apiName, apidir)
+                    except EnvironmentError:
+                        print("Could not install '{0}'.".format(apiName))
     
     # create menu entry for Linux systems
     if sys.platform.startswith("linux"):
@@ -749,10 +753,10 @@
                 os.makedirs(dst)
             shutilCopy(
                 os.path.join(sourceDir, "icons", "default", "eric.png"),
-                os.path.join(dst, "eric.png"))
+                os.path.join(dst, "eric" + marker + ".png"))
             shutilCopy(
                 os.path.join(sourceDir, "icons", "default", "ericWeb48.png"),
-                os.path.join(dst, "ericWeb.png"))
+                os.path.join(dst, "ericWeb" + marker + ".png"))
             dst = os.path.normpath(
                 os.path.join(distDir, "usr/share/applications"))
             if not os.path.exists(dst):
@@ -775,7 +779,7 @@
         elif os.getuid() == 0:
             shutilCopy(os.path.join(
                 sourceDir, "icons", "default", "eric.png"),
-                "/usr/share/pixmaps/eric.png")
+                "/usr/share/pixmaps/eric" + marker + ".png")
             copyDesktopFile(
                 os.path.join(sourceDir, "eric5.desktop"),
                 "/usr/share/applications/eric5" + marker + ".desktop",
@@ -787,7 +791,7 @@
                     marker)
             shutilCopy(os.path.join(
                 sourceDir, "icons", "default", "ericWeb48.png"),
-                "/usr/share/pixmaps/ericWeb.png")
+                "/usr/share/pixmaps/ericWeb" + marker + ".png")
             copyDesktopFile(
                 os.path.join(sourceDir, "eric5_webbrowser.desktop"),
                 "/usr/share/applications/eric5_webbrowser" + marker +
@@ -1243,6 +1247,8 @@
     global progName, modDir, doCleanup, doCompile, distDir, cfg, apisDir
     global sourceDir, configName, includePythonVariant
     global macAppBundlePath, macAppBundleName, macPythonExe
+    global installApis
+    
     
     if sys.version_info < (2, 6, 0) or sys.version_info > (3, 9, 9):
         print('Sorry, eric5 requires at least Python 2.6 or '
@@ -1258,11 +1264,14 @@
 
     try:
         if sys.platform.startswith("win"):
-            optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:")
+            optlist, args = getopt.getopt(
+                argv[1:], "chxyza:b:d:f:", ["help", "noapis"])
         elif sys.platform == "darwin":
-            optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:i:m:n:p:")
+            optlist, args = getopt.getopt(
+                argv[1:], "chxyza:b:d:f:i:m:n:p:", ["help", "noapis"])
         else:
-            optlist, args = getopt.getopt(argv[1:], "chxyza:b:d:f:i:")
+            optlist, args = getopt.getopt(
+                argv[1:], "chxyza:b:d:f:i:", ["help", "noapis"])
     except getopt.GetoptError:
         usage()
 
@@ -1304,6 +1313,8 @@
             macAppBundlePath = arg
         elif opt == "-p":
             macPythonExe = arg
+        elif "--noapis":
+            installApis = False
     
     installFromSource = not os.path.isdir(sourceDir)
     if installFromSource:
--- a/uninstall.py	Tue Nov 25 19:31:28 2014 +0100
+++ b/uninstall.py	Thu Nov 27 19:48:04 2014 +0100
@@ -100,10 +100,6 @@
     
     # Remove the menu entry for Linux systems
     if sys.platform.startswith("linux") and os.getuid() == 0:
-        for name in ["/usr/share/pixmaps/eric.png",
-                     "/usr/share/pixmaps/ericWeb.png"]:
-            if os.path.exists(name):
-                os.remove(name)
         if includePythonVariant:
             marker = PythonMarkers[sys.version_info.major]
         else:
@@ -111,7 +107,9 @@
         for name in ["/usr/share/applications/eric5" + marker + ".desktop",
                      "/usr/share/appdata/eric5" + marker + ".appdata.xml",
                      "/usr/share/applications/eric5_webbrowser" + marker + 
-                     ".desktop"]:
+                     ".desktop",
+                     "/usr/share/pixmaps/eric" + marker + ".png",
+                     "/usr/share/pixmaps/ericWeb" + marker + ".png"]:
             if os.path.exists(name):
                 os.remove(name)
     

eric ide

mercurial