scripts/install.py

branch
eric7-maintenance
changeset 10534
783d835d7fe4
parent 10460
3b34efa2857c
parent 10525
e2b37b8ae403
child 10616
4aa36fcd4a30
--- a/scripts/install.py	Mon Jan 01 11:11:21 2024 +0100
+++ b/scripts/install.py	Wed Jan 31 09:13:13 2024 +0100
@@ -17,6 +17,7 @@
 import getpass
 import glob
 import importlib
+import importlib.util
 import io
 import json
 import os
@@ -68,13 +69,13 @@
 installInfo = {}
 installCwd = ""
 
-# Define blacklisted versions of the prerequisites
-BlackLists = {
+# Define blocklisted versions of the prerequisites
+BlockLists = {
     "sip": [],
     "PyQt6": [],
     "QScintilla2": [],
 }
-PlatformsBlackLists = {
+PlatformsBlockLists = {
     "freebsd": {
         "sip": [],
         "PyQt6": [],
@@ -474,6 +475,7 @@
         "eric7_hexeditor",
         "eric7_iconeditor",
         "eric7_ide",
+        "eric7_mpy",
         "eric7_pdf",
         "eric7_pip",
         "eric7_plugininstall",
@@ -581,9 +583,12 @@
             "/usr/share/metainfo/eric7.appdata.xml",
             "/usr/share/applications/eric7_browser.desktop",
             "/usr/share/applications/eric7_ide.desktop",
+            "/usr/share/applications/eric7_mpy.desktop",
             "/usr/share/icons/eric.png",
+            "/usr/share/icons/ericMPy.png",
             "/usr/share/icons/ericWeb.png",
             "/usr/share/pixmaps/eric.png",
+            "/usr/share/pixmaps/ericMPy.png",
             "/usr/share/pixmaps/ericWeb.png",
             # obsolete entries below
             "/usr/share/applications/eric7.desktop",
@@ -597,9 +602,12 @@
             "~/.local/share/metainfo/eric7.appdata.xml",
             "~/.local/share/applications/eric7_browser.desktop",
             "~/.local/share/applications/eric7_ide.desktop",
+            "~/.local/share/applications/eric7_mpy.desktop",
             "~/.local/share/icons/eric.png",
+            "~/.local/share/icons/ericMPy.png",
             "~/.local/share/icons/ericWeb.png",
             "~/.local/share/pixmaps/eric.png",
+            "~/.local/share/pixmaps/ericMPy.png",
             "~/.local/share/pixmaps/ericWeb.png",
             # obsolete entries below
             "~/.local/share/applications/eric7.desktop",
@@ -718,6 +726,7 @@
         "eric7_hexeditor",
         "eric7_iconeditor",
         "eric7_ide",
+        "eric7_mpy",
         "eric7_pdf",
         "eric7_pip",
         "eric7_plugininstall",
@@ -936,52 +945,54 @@
     dataSourceDir = os.path.join(eric7SourceDir, "data", "linux")
 
     if distDir:
+        # create directories first
+        for directory in (
+            os.path.normpath(os.path.join(distDir, name))
+            for name in (
+                "usr/share/icons",
+                "usr/share/icons/hicolor/48x48/apps",
+                "usr/share/applications",
+                "usr/share/metainfo",
+                "usr/share/appdata",
+            )
+        ):
+            if not os.path.exists(directory):
+                os.makedirs(directory)
+
         dst = os.path.normpath(os.path.join(distDir, "usr/share/icons"))
-        if not os.path.exists(dst):
-            os.makedirs(dst)
-        shutilCopy(
-            os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"),
-            os.path.join(dst, "eric.png"),
-        )
-        shutilCopy(
-            os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
-            os.path.join(dst, "ericWeb.png"),
-        )
+        for icon in ("eric_icon.png", "ericMPy48_icon.png", "ericWeb48_icon.png"):
+            shutilCopy(
+                os.path.join(eric7SourceDir, "pixmaps", icon),
+                os.path.join(dst, icon.replace("_icon", "").replace("48", "")),
+            )
 
         dst = os.path.normpath(
             os.path.join(distDir, "usr/share/icons/hicolor/48x48/apps")
         )
-        if not os.path.exists(dst):
-            os.makedirs(dst)
-        shutilCopy(
-            os.path.join(eric7SourceDir, "pixmaps", "eric48_icon.png"),
-            os.path.join(dst, "eric.png"),
-        )
-        shutilCopy(
-            os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
-            os.path.join(dst, "ericWeb.png"),
-        )
+        for icon in ("eric48_icon.png", "ericMPy48_icon.png", "ericWeb48_icon.png"):
+            shutilCopy(
+                os.path.join(eric7SourceDir, "pixmaps", icon),
+                os.path.join(dst, icon.replace("48_icon", "")),
+            )
 
         dst = os.path.normpath(os.path.join(distDir, "usr/share/applications"))
-        if not os.path.exists(dst):
-            os.makedirs(dst)
-        copyDesktopFile(
-            os.path.join(dataSourceDir, "eric7_ide.desktop.in"),
-            os.path.join(dst, "eric7_ide.desktop"),
-        )
-        copyDesktopFile(
-            os.path.join(dataSourceDir, "eric7_browser.desktop.in"),
-            os.path.join(dst, "eric7_browser.desktop"),
-        )
+        for desktop in ("eric7_ide", "eric7_browser", "eric7_mpy"):
+            copyDesktopFile(
+                os.path.join(dataSourceDir, desktop + ".desktop.in"),
+                os.path.join(dst, desktop + ".desktop"),
+            )
 
-        dst = os.path.normpath(os.path.join(distDir, "usr/share/metainfo"))
-        if not os.path.exists(dst):
-            os.makedirs(dst)
-        copyAppStreamFile(
-            os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
-            os.path.join(dst, "eric7.appdata.xml"),
-        )
+        for dst in (
+            os.path.normpath(os.path.join(distDir, "usr/share/metainfo")),
+            os.path.normpath(os.path.join(distDir, "usr/share/appdata")),
+        ):
+            copyAppStreamFile(
+                os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
+                os.path.join(dst, "eric7.appdata.xml"),
+            )
+
     elif os.getuid() == 0:
+        # eric meta data
         shutilCopy(
             os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"),
             "/usr/share/icons/eric.png",
@@ -1004,6 +1015,22 @@
                 os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
                 "/usr/share/appdata/eric7.appdata.xml",
             )
+
+        # eric MicroPython meta data
+        shutilCopy(
+            os.path.join(eric7SourceDir, "pixmaps", "ericMPy48_icon.png"),
+            "/usr/share/icons/ericMPy.png",
+        )
+        shutilCopy(
+            os.path.join(eric7SourceDir, "pixmaps", "ericMPy48_icon.png"),
+            "/usr/share/icons/hicolor/48x48/apps/ericMPy.png",
+        )
+        copyDesktopFile(
+            os.path.join(dataSourceDir, "eric7_mpy.desktop.in"),
+            "/usr/share/applications/eric7_mpy.desktop",
+        )
+
+        # eric web browser meta data
         shutilCopy(
             os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
             "/usr/share/icons/ericWeb.png",
@@ -1016,6 +1043,7 @@
             os.path.join(dataSourceDir, "eric7_browser.desktop.in"),
             "/usr/share/applications/eric7_browser.desktop",
         )
+
     elif os.getuid() >= 1000:
         # it is assumed, that user ids start at 1000
         localPath = os.path.join(os.path.expanduser("~"), ".local", "share")
@@ -1032,7 +1060,9 @@
         ]:
             if not os.path.isdir(directory):
                 os.makedirs(directory)
+
         # now copy the files
+        # eric meta data
         shutilCopy(
             os.path.join(eric7SourceDir, "pixmaps", "eric_icon.png"),
             os.path.join(localPath, "icons", "eric.png"),
@@ -1053,6 +1083,22 @@
             os.path.join(dataSourceDir, "eric7.appdata.xml.in"),
             os.path.join(localPath, "appdata", "eric7.appdata.xml"),
         )
+
+        # eric MicroPython meta data
+        shutilCopy(
+            os.path.join(eric7SourceDir, "pixmaps", "ericMPy48_icon.png"),
+            os.path.join(localPath, "icons", "ericMPy.png"),
+        )
+        shutilCopy(
+            os.path.join(eric7SourceDir, "pixmaps", "ericMPy48_icon.png"),
+            os.path.join(localPath, "icons/hicolor/48x48/apps", "ericMPy.png"),
+        )
+        copyDesktopFile(
+            os.path.join(dataSourceDir, "eric7_mpy.desktop.in"),
+            os.path.join(localPath, "applications", "eric7_mpy.desktop"),
+        )
+
+        # eric web browser meta data
         shutilCopy(
             os.path.join(eric7SourceDir, "pixmaps", "ericWeb48_icon.png"),
             os.path.join(localPath, "icons", "ericWeb.png"),
@@ -1737,15 +1783,15 @@
         print("Alternatively you may install all of them with:")
         print("    {0} install-dependencies.py --all".format(sys.executable))
 
-    # determine the platform dependent black list
+    # determine the platform dependent block list
     if sys.platform.startswith(("win", "cygwin")):
-        PlatformBlackLists = PlatformsBlackLists["windows"]
+        PlatformBlockLists = PlatformsBlockLists["windows"]
     elif sys.platform.startswith("linux"):
-        PlatformBlackLists = PlatformsBlackLists["linux"]
+        PlatformBlockLists = PlatformsBlockLists["linux"]
     elif sys.platform.startswith("freebsd"):
-        PlatformBlackLists = PlatformsBlackLists["freebsd"]
+        PlatformBlockLists = PlatformsBlockLists["freebsd"]
     else:
-        PlatformBlackLists = PlatformsBlackLists["mac"]
+        PlatformBlockLists = PlatformsBlockLists["mac"]
 
     print("\nVersion Information")
     print("-------------------")
@@ -1779,8 +1825,8 @@
                     )
                 )
                 exit(3)
-            # check for blacklisted versions
-            for vers in BlackLists["sip"] + PlatformBlackLists["sip"]:
+            # check for blocklisted versions
+            for vers in BlockLists["sip"] + PlatformBlockLists["sip"]:
                 if vers == sip.SIP_VERSION:
                     print(
                         "Sorry, sip version {0} is not compatible with eric.".format(
@@ -1805,8 +1851,8 @@
                 )
             )
             exit(4)
-        # check for blacklisted versions
-        for vers in BlackLists["PyQt6"] + PlatformBlackLists["PyQt6"]:
+        # check for blocklisted versions
+        for vers in BlockLists["PyQt6"] + PlatformBlockLists["PyQt6"]:
             if vers == PYQT_VERSION:
                 print(
                     "Sorry, PyQt version {0} is not compatible with eric.".format(
@@ -1834,8 +1880,8 @@
                 )
             )
             exit(5)
-        # check for blacklisted versions
-        for vers in BlackLists["QScintilla2"] + PlatformBlackLists["QScintilla2"]:
+        # check for blocklisted versions
+        for vers in BlockLists["QScintilla2"] + PlatformBlockLists["QScintilla2"]:
             if vers == QSCINTILLA_VERSION:
                 print(
                     "Sorry, QScintilla2 version {0} is not compatible with"
@@ -2071,6 +2117,11 @@
             os.path.join(cfg["ericPixDir"], "eric7.ico"),
         ),
         (
+            "eric7 MicroPython (Python {0}.{1}).lnk",
+            os.path.join(cfg["bindir"], "eric7_mpy.cmd"),
+            os.path.join(cfg["ericPixDir"], "ericMPy48.ico"),
+        ),
+        (
             "eric7 Browser (Python {0}.{1}).lnk",
             os.path.join(cfg["bindir"], "eric7_browser.cmd"),
             os.path.join(cfg["ericPixDir"], "ericWeb48.ico"),

eric ide

mercurial