scripts/install.py

changeset 7453
54431a52b7f2
parent 7448
29b54296cf8c
child 7503
b17672e6812d
child 7519
0e93f5167e71
equal deleted inserted replaced
7452:32b5c4a9fb17 7453:54431a52b7f2
20 import shutil 20 import shutil
21 import fnmatch 21 import fnmatch
22 import subprocess 22 import subprocess
23 import time 23 import time
24 import io 24 import io
25 import json
25 26
26 # Define the globals. 27 # Define the globals.
27 progName = None 28 progName = None
28 currDir = os.getcwd() 29 currDir = os.getcwd()
29 modDir = None 30 modDir = None
1305 ok = (exitCode == 0) 1306 ok = (exitCode == 0)
1306 1307
1307 return ok 1308 return ok
1308 1309
1309 1310
1311 def isPipOutdated():
1312 """
1313 Check, if pip is outdated.
1314
1315 @return flag indicating an outdated pip
1316 @rtype bool
1317 """
1318 try:
1319 pipOut = subprocess.check_output([
1320 sys.executable, "-m", "pip", "list", "--outdated",
1321 "--format=json"
1322 ])
1323 pipOut = pipOut.decode()
1324 except (OSError, subprocess.CalledProcessError):
1325 pipOut = "[]" # default empty list
1326 try:
1327 jsonList = json.loads(pipOut)
1328 except Exception:
1329 jsonList = []
1330 for package in jsonList:
1331 if isinstance(package, dict) and package["name"] == "pip":
1332 print("'pip' is outdated (installed {0}, available {1})".format(
1333 package["version"], package["latest_version"]
1334 ))
1335 return True
1336
1337 return False
1338
1339
1310 def updatePip(): 1340 def updatePip():
1311 """ 1341 """
1312 Update the installed pip package. 1342 Update the installed pip package.
1313 """ 1343 """
1314 global yes2All 1344 global yes2All
1328 Perform some dependency checks. 1358 Perform some dependency checks.
1329 """ 1359 """
1330 print('Checking dependencies') 1360 print('Checking dependencies')
1331 1361
1332 # update pip first even if we don't need to install anything 1362 # update pip first even if we don't need to install anything
1333 updatePip() 1363 if isPipOutdated():
1334 print("\n\n") 1364 updatePip()
1365 print("\n")
1335 1366
1336 # perform dependency checks 1367 # perform dependency checks
1337 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3])) 1368 print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3]))
1338 if sys.version_info < (3, 5, 0): 1369 if sys.version_info < (3, 5, 0):
1339 print('Sorry, you must have Python 3.5.0 or higher.') 1370 print('Sorry, you must have Python 3.5.0 or higher.')

eric ide

mercurial