eric7/UI/upgrader.py

branch
eric7
changeset 8972
54816b8f740f
parent 8970
188ff9ce8657
child 8994
3bebd76dc6ea
--- a/eric7/UI/upgrader.py	Sat Mar 05 18:10:28 2022 +0100
+++ b/eric7/UI/upgrader.py	Sun Mar 06 19:53:19 2022 +0100
@@ -11,46 +11,31 @@
 the requested packages and will restart eric.
 """
 
-import os
 import subprocess
 import sys
 import time
 
-from eric7config import getConfig
+
+_pyqtPackages = [
+    "pyqt6", "pyqt6-sip", "pyqt6-webengine", "pyqt6-charts",
+    "pyqt6-qscintilla", "pyqt6-qt6", "pyqt6-webengine-qt6",
+    "pyqt6-charts-qt6"
+]
+_ericPackages = ["eric-ide"]
 
 
-def upgradePyQt():
+def doUpgrade(packages):
     """
-    Function to upgrade the PyQt packages via pip.
-    
-    @return flag indicating a successful installation
-    @rtype bool
-    """
-    pyqtPackages = [
-        "pyqt6", "pyqt6-sip", "pyqt6-webengine", "pyqt6-charts",
-        "pyqt6-qscintilla", "pyqt6-qt6", "pyqt6-webengine-qt6",
-        "pyqt6-charts-qt6"
-    ]
+    Function to upgrade the given packages via pip.
     
-    exitCode = subprocess.run(                  # secok
-        [sys.executable, "-m", "pip", "install", "--prefer-binary",
-         "--upgrade"] + pyqtPackages
-    ).returncode
-    ok = (exitCode == 0)
-    
-    return ok
-
-
-def upgradeEric():
-    """
-    Function to upgrade the eric-ide package via pip.
-    
+    @param packages list of packages to be upgraded
+    @type list of str
     @return flag indicating a successful installation
     @rtype bool
     """
     exitCode = subprocess.run(                  # secok
         [sys.executable, "-m", "pip", "install", "--prefer-binary",
-         "--upgrade", "eric-ide"]
+         "--upgrade"] + packages
     ).returncode
     ok = (exitCode == 0)
     
@@ -84,18 +69,17 @@
     ericStartArgs = sys.argv[ddindex + 1:]
     if not ericStartArgs:
         # create default start arguments
-        ericStartArgs = [
-            os.path.join(getConfig("ericDir"), "eric7.py"),
-            "--start-session",
-        ]
+        ericStartArgs = ["-m", "eric7", "--start-session"]
     
     upgraderArgs = sys.argv[1:ddindex]
     
     # now perform the upgrade and start eric, if it was successful
     if upgraderArgs[0] == "--pyqt":
-        ok = upgradePyQt()
+        ok = doUpgrade(_pyqtPackages)
     elif upgraderArgs[0] == "--eric":
-        ok = upgradeEric()
+        ok = doUpgrade(_ericPackages)
+    elif upgraderArgs[0] == "--ericpyqt":
+        ok = doUpgrade(_ericPackages + _pyqtPackages)
     else:
         ok = False
     

eric ide

mercurial