scripts/install.py

branch
maintenance
changeset 7503
b17672e6812d
parent 7362
028bf21bb5a2
parent 7453
54431a52b7f2
child 7560
343db73c4842
equal deleted inserted replaced
7438:7ece94219310 7503:b17672e6812d
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
1340 def updatePip():
1341 """
1342 Update the installed pip package.
1343 """
1344 global yes2All
1345
1346 if yes2All:
1347 answer = "y"
1348 else:
1349 print("Shall 'pip' be updated (recommended)? (Y/n)", end=" ")
1350 answer = input()
1351 if answer in ("", "Y", "y"):
1352 subprocess.call(
1353 [sys.executable, "-m", "pip", "install", "--upgrade", "pip"])
1354
1355
1310 def doDependancyChecks(): 1356 def doDependancyChecks():
1311 """ 1357 """
1312 Perform some dependency checks. 1358 Perform some dependency checks.
1313 """ 1359 """
1314 print('Checking dependencies') 1360 print('Checking dependencies')
1361
1362 # update pip first even if we don't need to install anything
1363 if isPipOutdated():
1364 updatePip()
1365 print("\n")
1315 1366
1316 # perform dependency checks 1367 # perform dependency checks
1317 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]))
1318 if sys.version_info < (3, 5, 0): 1369 if sys.version_info < (3, 5, 0):
1319 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