scripts/install.py

branch
eric7
changeset 10264
f06151820839
parent 10261
fa560567d555
child 10272
7ae72d1df070
child 10300
60e8f2175b3b
--- a/scripts/install.py	Sun Oct 29 12:19:47 2023 +0100
+++ b/scripts/install.py	Sun Oct 29 15:50:37 2023 +0100
@@ -53,10 +53,8 @@
 eric7SourceDir = ""
 configName = "eric7config.py"
 defaultMacAppBundleName = "eric7.app"
-if os.getuid() == 0:
-    defaultMacAppBundlePath = "/Applications"
-else:
-    defaultMacAppBundlePath = os.path.expanduser("~/Applications")
+defaultMacAppBundlePath = "/Applications"
+defaultMacUserAppBundlePath = os.path.expanduser("~/Applications")
 defaultMacPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(
     sys.exec_prefix
 )
@@ -201,7 +199,7 @@
     Module function to set the values of globals that need more than a
     simple assignment.
     """
-    global platBinDir, modDir, pyModDir, apisDir
+    global platBinDir, modDir, pyModDir, apisDir, macAppBundlePath
 
     if sys.platform.startswith(("win", "cygwin")):
         platBinDir = sysconfig.get_path("scripts")
@@ -241,6 +239,12 @@
             qtDataDir = None
     apisDir = os.path.join(qtDataDir, "qsci", "api") if qtDataDir else None
 
+    if sys.platform == "darwin":
+        if os.getuid() == 0:
+            macAppBundlePath = defaultMacAppBundlePath
+        else:
+            macAppBundlePath = defaultMacUserAppBundlePath
+
 
 def copyToFile(name, text):
     """
@@ -672,10 +676,15 @@
         macAppBundlePath = getConfig("macAppBundlePath")
         macAppBundleName = getConfig("macAppBundleName")
     except AttributeError:
-        macAppBundlePath = defaultMacAppBundlePath
+        macAppBundlePath = (
+            defaultMacAppBundlePath
+            if os.getpid() == 0
+            else defaultMacUserAppBundlePath
+        )
         macAppBundleName = defaultMacAppBundleName
     for bundlePath in [
         os.path.join(defaultMacAppBundlePath, macAppBundleName),
+        os.path.join(defaultMacUserAppBundlePath, macAppBundleName),
         os.path.join(macAppBundlePath, macAppBundleName),
     ]:
         if os.path.exists(bundlePath):
@@ -1582,7 +1591,7 @@
     }
 
     try:
-        isSudo = os.getuid() == 0 and sys.platform != "darwin"
+        isSudo = os.getuid() == 0
         # disregard sudo installs on macOS
     except AttributeError:
         isSudo = False
@@ -2273,11 +2282,11 @@
                     )
                     print("ERROR: {0}".format(str(exc)))
                     cfg = {}
-        elif opt == "-m":
+        elif opt == "-m" and sys.platform == "darwin":
             macAppBundleName = arg
-        elif opt == "-n":
+        elif opt == "-n" and sys.platform == "darwin":
             macAppBundlePath = arg
-        elif opt == "-p":
+        elif opt == "-p" and sys.platform == "darwin":
             macPythonExe = arg
         elif opt == "--no-apis":
             installApis = False

eric ide

mercurial