Modified the install script to allow parallel installation for Python2 and Python3. 5_5_x

Wed, 19 Nov 2014 18:53:41 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 19 Nov 2014 18:53:41 +0100
branch
5_5_x
changeset 3932
a909b9212f59
parent 3930
2968e0bfcaea
child 3934
8e2b5bdd6bf3

Modified the install script to allow parallel installation for Python2 and Python3.

eric5.appdata.xml file | annotate | diff | comparison | revisions
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.appdata.xml	Tue Nov 18 19:03:48 2014 +0100
+++ b/eric5.appdata.xml	Wed Nov 19 18:53:41 2014 +0100
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- Copyright 2013 First Lastname <your@email.com> -->
 <application>
- <id type="desktop">eric5.desktop</id>
+ <id type="desktop">eric5@MARKER@.desktop</id>
  <metadata_license>CC-BY-3.0</metadata_license>
  <project_license>GPL-3.0+</project_license>
- <name>eric5</name>
+ <name>eric5@MARKER@</name>
  <summary>Integrated Development Environment for Python</summary>
  <description>
   <p>
--- a/eric5.desktop	Tue Nov 18 19:03:48 2014 +0100
+++ b/eric5.desktop	Wed Nov 19 18:53:41 2014 +0100
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Version=1.0
 Type=Application
-Exec=eric5
+Exec=eric5@MARKER@
 MimeType=text/x-python;
 Icon=eric
 Terminal=false
--- a/eric5_webbrowser.desktop	Tue Nov 18 19:03:48 2014 +0100
+++ b/eric5_webbrowser.desktop	Wed Nov 19 18:53:41 2014 +0100
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Version=1.0
 Type=Application
-Exec=eric5_webbrowser
+Exec=eric5_webbrowser@MARKER@
 MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;
 Icon=ericWeb
 Terminal=false
--- a/install.py	Tue Nov 18 19:03:48 2014 +0100
+++ b/install.py	Wed Nov 19 18:53:41 2014 +0100
@@ -217,6 +217,26 @@
     f.close()
 
 
+def copyDesktopFile(src, dst, marker):
+    """
+    Modify a desktop file and write it to its destination.
+    
+    @param src source file name (string)
+    @param dst destination file name (string)
+    @param marker marker to be used (string)
+    """
+    f = open(src, "r")
+    text = f.read()
+    f.close()
+    
+    text = text.replace("@MARKER@", marker)
+    
+    f = open(dst, "w")
+    f.write(text)
+    f.close()
+    os.chmod(dst, 0o644)
+
+
 def wrapperName(dname, wfile):
     """
     Create the platform specific name for the wrapper script.
@@ -407,10 +427,17 @@
     # 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/applications/eric5.desktop",
-                     "/usr/share/appdata/eric5.appdata.xml",
-                     "/usr/share/pixmaps/ericWeb.png",
-                     "/usr/share/applications/eric5_webbrowser.desktop"]:
+                     "/usr/share/pixmaps/ericWeb.png"]:
+            if os.path.exists(name):
+                os.remove(name)
+        if includePythonVariant:
+            marker = PythonMarkers[sys.version_info.major]
+        else:
+            marker = ""
+        for name in ["/usr/share/applications/eric5" + marker + ".desktop",
+                     "/usr/share/appdata/eric5" + marker + ".appdata.xml",
+                     "/usr/share/applications/eric5_webbrowser" + marker + 
+                     ".desktop"]:
             if os.path.exists(name):
                 os.remove(name)
     
@@ -487,7 +514,7 @@
                         os.remove(apiname)
                 for apiname in glob.glob(
                         os.path.join(apidir, progLanguage.lower(), "*.bas")):
-                    if os.path.basename(apiname) != "eric6.bas":
+                    if os.path.basename(apiname) != "eric5.bas":
                         os.remove(apiname)
         except AttributeError:
             pass
@@ -536,6 +563,7 @@
     @return result code (integer)
     """
     global distDir, doCleanup, cfg, progLanguages, sourceDir, configName
+    global includePythonVariant
     
     # Create the platform specific wrappers.
     wnames = []
@@ -704,6 +732,11 @@
     
     # create menu entry for Linux systems
     if sys.platform.startswith("linux"):
+        if includePythonVariant:
+            marker = PythonMarkers[sys.version_info.major]
+        else:
+            marker = ""
+    
         if distDir:
             dst = os.path.normpath(os.path.join(distDir, "usr/share/pixmaps"))
             if not os.path.exists(dst):
@@ -718,31 +751,42 @@
                 os.path.join(distDir, "usr/share/applications"))
             if not os.path.exists(dst):
                 os.makedirs(dst)
-            shutilCopy(os.path.join(sourceDir, "eric5.desktop"), dst)
-            shutilCopy(os.path.join(sourceDir, "eric5_webbrowser.desktop"),
-                       dst)
+            copyDesktopFile(os.path.join(sourceDir, "eric5.desktop"),
+                            os.path.join(dst, "eric5" + marker + ".desktop"),
+                            marker)
+            copyDesktopFile(
+                os.path.join(sourceDir, "eric5_webbrowser.desktop"),
+                os.path.join(dst, "eric5_webbrowser" + marker + ".desktop"),
+                marker)
             dst = os.path.normpath(
                 os.path.join(distDir, "usr/share/appdata"))
             if not os.path.exists(dst):
                 os.makedirs(dst)
-            shutilCopy(os.path.join(sourceDir, "eric5.appdata.xml"), dst)
+            copyDesktopFile(
+                os.path.join(sourceDir, "eric5.appdata.xml"),
+                os.path.join(dst, "eric5" + marker + ".appdata.xml"),
+                marker)
         elif os.getuid() == 0:
             shutilCopy(os.path.join(
                 sourceDir, "icons", "default", "eric.png"),
                 "/usr/share/pixmaps/eric.png")
-            shutilCopy(os.path.join(
-                sourceDir, "eric5.desktop"),
-                "/usr/share/applications")
+            copyDesktopFile(
+                os.path.join(sourceDir, "eric5.desktop"),
+                "/usr/share/applications/eric5" + marker + ".desktop",
+                marker)
             if os.path.exists("/usr/share/appdata"):
-                shutilCopy(os.path.join(
-                    sourceDir, "eric5.appdata.xml"),
-                    "/usr/share/appdata")
+                copyDesktopFile(
+                    os.path.join(sourceDir, "eric5.appdata.xml"),
+                    "/usr/share/appdata/eric5" + marker + ".appdata.xml",
+                    marker)
             shutilCopy(os.path.join(
                 sourceDir, "icons", "default", "ericWeb48.png"),
                 "/usr/share/pixmaps/ericWeb.png")
-            shutilCopy(os.path.join(
-                sourceDir, "eric5_webbrowser.desktop"),
-                "/usr/share/applications")
+            copyDesktopFile(
+                os.path.join(sourceDir, "eric5_webbrowser.desktop"),
+                "/usr/share/applications/eric5_webbrowser" + marker +
+                ".desktop",
+                marker)
     
     # Create a Mac application bundle
     if sys.platform == "darwin":
--- a/uninstall.py	Tue Nov 18 19:03:48 2014 +0100
+++ b/uninstall.py	Wed Nov 19 18:53:41 2014 +0100
@@ -101,10 +101,17 @@
     # 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/applications/eric5.desktop",
-                     "/usr/share/appdata/eric5.appdata.xml",
-                     "/usr/share/pixmaps/ericWeb.png",
-                     "/usr/share/applications/eric5_webbrowser.desktop"]:
+                     "/usr/share/pixmaps/ericWeb.png"]:
+            if os.path.exists(name):
+                os.remove(name)
+        if includePythonVariant:
+            marker = PythonMarkers[sys.version_info.major]
+        else:
+            marker = ""
+        for name in ["/usr/share/applications/eric5" + marker + ".desktop",
+                     "/usr/share/appdata/eric5" + marker + ".appdata.xml",
+                     "/usr/share/applications/eric5_webbrowser" + marker + 
+                     ".desktop"]:
             if os.path.exists(name):
                 os.remove(name)
     
@@ -180,7 +187,7 @@
                     os.remove(apiname)
             for apiname in glob.glob(
                     os.path.join(apidir, progLanguage.lower(), "*.bas")):
-                if os.path.basename(apiname) != "eric6.bas":
+                if os.path.basename(apiname) != "eric5.bas":
                     os.remove(apiname)
         
         if sys.platform == "darwin":

eric ide

mercurial