scripts/install.py

changeset 7453
54431a52b7f2
parent 7448
29b54296cf8c
child 7503
b17672e6812d
child 7519
0e93f5167e71
--- a/scripts/install.py	Tue Mar 10 19:32:39 2020 +0100
+++ b/scripts/install.py	Wed Mar 11 19:25:20 2020 +0100
@@ -22,6 +22,7 @@
 import subprocess
 import time
 import io
+import json
 
 # Define the globals.
 progName = None
@@ -1307,6 +1308,35 @@
     return ok
 
 
+def isPipOutdated():
+    """
+    Check, if pip is outdated.
+    
+    @return flag indicating an outdated pip
+    @rtype bool
+    """
+    try:
+        pipOut = subprocess.check_output([
+            sys.executable, "-m", "pip", "list", "--outdated",
+            "--format=json"
+        ])
+        pipOut = pipOut.decode()
+    except (OSError, subprocess.CalledProcessError):
+        pipOut = "[]"       # default empty list
+    try:
+        jsonList = json.loads(pipOut)
+    except Exception:
+        jsonList = []
+    for package in jsonList:
+        if isinstance(package, dict) and package["name"] == "pip":
+            print("'pip' is outdated (installed {0}, available {1})".format(
+                package["version"], package["latest_version"]
+            ))
+            return True
+    
+    return False
+
+
 def updatePip():
     """
     Update the installed pip package.
@@ -1330,8 +1360,9 @@
     print('Checking dependencies')
     
     # update pip first even if we don't need to install anything
-    updatePip()
-    print("\n\n")
+    if isPipOutdated():
+        updatePip()
+        print("\n")
     
     # perform dependency checks
     print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3]))

eric ide

mercurial