Every line of 'pip check version of module' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
463 @conf 464 def check_python_module(conf, module_name, condition=''): 465 """ 466 Check if the selected python interpreter can import the given python module:: 467 468 def configure(conf): 469 conf.check_python_module('pygccxml') 470 conf.check_python_module('re', condition="ver > num(2, 0, 4) and ver <= num(3, 0, 0)") 471 472 :param module_name: module 473 :type module_name: string 474 """ 475 msg = 'Python module %s' % module_name 476 if condition: 477 msg = '%s (%s)' % (msg, condition) 478 conf.start_msg(msg) 479 try: 480 ret = conf.cmd_and_log(conf.env['PYTHON'] + ['-c', PYTHON_MODULE_TEMPLATE % module_name]) 481 except Exception: 482 conf.end_msg(False) 483 conf.fatal('Could not find the python module %r' % module_name) 484 485 ret = ret.strip() 486 if condition: 487 conf.end_msg(ret) 488 if ret == 'unknown version': 489 conf.fatal('Could not check the %s version' % module_name) 490 491 from distutils.version import LooseVersion 492 def num(*k): 493 if isinstance(k[0], int): 494 return LooseVersion('.'.join([str(x) for x in k])) 495 else: 496 return LooseVersion(k[0]) 497 d = {'num': num, 'ver': LooseVersion(ret)} 498 ev = eval(condition, {}, d) 499 if not ev: 500 conf.fatal('The %s version does not satisfy the requirements' % module_name) 501 else: 502 if ret == 'unknown version': 503 conf.end_msg(True) 504 else: 505 conf.end_msg(ret)
53 def CheckVersion(given, required, name): 54 """ For a given set of versions str *required* and str *given*, 55 where version are usually separated by dots, print whether for 56 the module str *name* the required verion is met or not. 57 """ 58 try: 59 req = LooseVersion(required) 60 giv = LooseVersion(given) 61 except: 62 print(" WARNING: Could not verify version of "+name+".") 63 return 64 if req > giv: 65 print(" WARNING: You are using "+name+" v. "+given+\ 66 " | Required: "+name+" "+ required) 67 else: 68 print(" OK: "+name+" v. "+given+" | "+required+" required")
43 def check_pyinstaller_version(): 44 """Using is_module_satisfies() for pyinstaller fails when 45 installed using 'pip install develop.zip' command 46 (PyInstaller Issue #2802).""" 47 # Example version string for dev version of pyinstaller: 48 # > 3.3.dev0+g5dc9557c 49 version = PyInstaller.__version__ 50 match = re.search(r"^\d+\.\d+(\.\d+)?", version) 51 if not (match.group(0) >= PYINSTALLER_MIN_VERSION): 52 raise SystemExit("Error: pyinstaller %s or higher is required" % PYINSTALLER_MIN_VERSION)
25 def require_module(*modules): 26 27 commands = list(missing_requirements(*modules)) 28 29 if commands: 30 31 print("Update in progress: pip install %s --user" % " ".join(commands)) 32 33 if pip.running_under_virtualenv(): 34 pip.main(["install"] + commands) 35 else: 36 pip.main(["install", "--user"] + commands)
62 def _get_version(module: types.ModuleType) -> packaging.version.Version: 63 version = packaging.version.Version(getattr(module, "__version__", None)) 64 65 if version is None: 66 raise ImportError("Can't determine version for {}".format(module.__name__)) 67 68 return version
18 def check_python(version): 19 required_version = tuple(int(i) for i in version.split('.')) 20 actual_version = sys.version_info[:2] 21 22 assert actual_version >= required_version, ( 23 'Must use at least Python %s but have version %d.%d' % 24 (version, actual_version[0], actual_version[1]))
146 @staticmethod 147 def python_version(): 148 """ 149 :return: python version object 150 """ 151 import sys 152 # version.major, version.minor, version.micro 153 return sys.version_info
282 def check_python_version(): 283 if sys.version_info < (3, 5): 284 stderr.write("DistAlgo requires Python version 3.5 or newer.\n") 285 return False 286 else: 287 return True