scripts/install.py

branch
eric7-maintenance
changeset 10272
7ae72d1df070
parent 10222
1146cc8fbf5d
parent 10264
f06151820839
child 10349
df7edc29cbfb
diff -r 3a99ac054b39 -r 7ae72d1df070 scripts/install.py
--- a/scripts/install.py	Thu Oct 05 10:06:49 2023 +0200
+++ b/scripts/install.py	Tue Oct 31 09:22:17 2023 +0100
@@ -54,6 +54,7 @@
 configName = "eric7config.py"
 defaultMacAppBundleName = "eric7.app"
 defaultMacAppBundlePath = "/Applications"
+defaultMacUserAppBundlePath = os.path.expanduser("~/Applications")
 defaultMacPythonExe = "{0}/Resources/Python.app/Contents/MacOS/Python".format(
     sys.exec_prefix
 )
@@ -198,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")
@@ -238,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):
     """
@@ -669,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):
@@ -1579,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
@@ -2270,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