Check whether module==version is available on pypi
174700
def pypi_module_version_is_available(module, version):
    ""
    # returns True/False (or None if failed to execute the check)

    # using a hack that when passing "module==" w/ no version number to pip
    # it "fails" and returns all the available versions in stderr
    try:
        cmd = f"pip install {module}=="
        result = subprocess.run(cmd.split(), shell=False, check=False,
                                stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    except Exception as e:
        print(f"Error: {e}")
        return None
    else:
        if result.returncode == 1 and result.stderr:
            output = result.stderr.decode('utf-8')
            return True if version in output else False
        else:
            print(f"Some error in {cmd}")
            return None
345271
def package_has_version_file(package_name):
    
    version_file_path = helpers.package_file_path('_version.py', package_name)
    return os.path.isfile(version_file_path)
1043936
def check_pypi(self):
        """"""
        for dist in get_installed_distributions():
            name = dist.project_name
            if name in self.reqs.keys():
                self.reqs[name]["dist"] = dist

        pypi = ServerProxy("https://pypi.python.org/pypi")
        for name, req in list(self.reqs.items()):
            if req["url"]:
                continue  # skipping github packages.
            elif "dist" in req:
                dist = req["dist"]
                dist_version = LooseVersion(dist.version)
                available = pypi.package_releases(req["pip_req"].name, True) or pypi.package_releases(req["pip_req"].name.replace('-', '_'), True)
                available_version = self._available_version(dist_version, available)

                if not available_version:
                    msg = self.style.WARN("release is not on pypi (check capitalization and/or --extra-index-url)")
                elif self.options['show_newer'] and dist_version > available_version:
                    msg = self.style.INFO("{0} available (newer installed)".format(available_version))
                elif available_version > dist_version:
                    msg = self.style.INFO("{0} available".format(available_version))
                else:
                    msg = "up to date"
                    del self.reqs[name]
                    continue
                pkg_info = self.style.BOLD("{dist.project_name} {dist.version}".format(dist=dist))
            else:
                msg = "not installed"
                pkg_info = name
            self.stdout.write("{pkg_info:40} {msg}".format(pkg_info=pkg_info, msg=msg))
            del self.reqs[name]
453260
def check_version(expected_version):
    

    with open(os.path.join(root_folder, 'VERSION'), 'r') as version_file:
        version = version_file.read().strip()

    if version != expected_version:
        raise EnvironmentError("Version mismatch during release, expected={}, found={}"
                               .format(expected_version, version))
246922
def get_library_version(module_name):
    
    try:
        module = importlib.import_module('luma.' + module_name)
        if hasattr(module, '__version__'):
            return module.__version__
        else:
            return None
    except ImportError:
        return None
1340990
def EnsurePythonVersion(self, major, minor):
        """"""
        if sys.version_info < (major, minor):
            v = sys.version.split()[0]
            print("Python %d.%d or greater required, but you have Python %s" %(major,minor,v))
            sys.exit(2)
542581
def _get_version():
    '''
    
    '''
    version_string = __salt__['cmd.run'](
        [_check_pkgin(), '-v'],
        output_loglevel='trace')
    if version_string is None:
        # Dunno why it would, but...
        return False

    version_match = VERSION_MATCH.search(version_string)
    if not version_match:
        return False

    return version_match.group(1).split('.')
355209
def check_python_version():
    """"""
    python_major, python_minor = sys.version_info[:2]

    if python_major != 2 or python_minor != 7:
        sys.stderr.write("pyGenClean requires python 2.7")
        sys.exit(1)
1360628
def _version_checker(module, minver):
    
    # We could use LooseVersion, but distutils imports imp which is deprecated
    version_regexp = r'[a-z]?((?:\d|\.)+\d+)(?:\.dev[0-9]+)?'
    version_tags = re.match(version_regexp, module.__version__)
    if not version_tags:
        return False
    version_tags = version_tags.group(1).split(".")
    version_tags = tuple(int(x) for x in version_tags)
    return version_tags >= minver
1263319
def check(self):
        """"""
        return programs.is_module_installed(self.modname,
                                            self.required_version,
                                            self.installed_version)
155635
def get_version():
    """"""
    version = 'Not installed.'

    try:
        version = pkg_resources.get_distribution(__package__).version
    except pkg_resources.DistributionNotFound:
        pass

    return version
538836
def check_version(version: str):
    
    code_version = parse_version(__version__)
    given_version = parse_version(version)
    check_condition(code_version[0] == given_version[0],
                    "Given release version (%s) does not match release code version (%s)" % (version, __version__))
    check_condition(code_version[1] == given_version[1],
                    "Given major version (%s) does not match major code version (%s)" % (version, __version__))
680358
def _check_version():
    """"""
    from ._config import APP_NAME

    if VersionCache.load(APP_NAME).is_fresh:
        return

    from pkg_resources import parse_version
    from renku.version import __version__

    version = parse_version(__version__)
    allow_prereleases = version.is_prerelease

    latest_version = find_latest_version(
        'renku', allow_prereleases=allow_prereleases
    )

    if version < latest_version:
        click.secho(
            'You are using renku version {version}, however version '
            '{latest_version} is available.\n'
            'You should consider upgrading ...'.format(
                version=__version__,
                latest_version=latest_version,
            ),
            fg='yellow',
            bold=True,
        )

    VersionCache(pypi_version=str(latest_version)).dump(APP_NAME)
219862
def check_version():
    
    if sys.version_info[0:3] == PYTHON_VERSION_INFO[0:3]:
        return

    sys.exit(
        ansi.error() + ' your virtual env points to the wrong python version. '
                       'This is likely because you used a python installer that clobbered '
                       'the system installation, which breaks virtualenv creation. '
                       'To fix, check this symlink, and delete the installation of python '
                       'that it is brokenly pointing to, then delete the virtual env itself '
                       'and rerun lore install: ' + os.linesep + os.linesep + BIN_PYTHON +
        os.linesep
    )
965945
def check_update_available(self):
        
        # Don't perform any check for development versions
        if 'dev' in self.version:
            return (False, latest_release)

        # Filter releases
        if is_stable_version(self.version):
            releases = [r for r in self.releases if is_stable_version(r)]
        else:
            releases = [r for r in self.releases
                        if not is_stable_version(r) or r in self.version]

        latest_release = releases[-1]

        return (check_version(self.version, latest_release, '<'),
                latest_release)
331332
function findModuleVersion(modulePath, load) {
  if (modulePath) {
    var pjson = path.join(modulePath, 'package.json');
    if (fs.existsSync(pjson)) {
      return load(pjson).version;
    }
  }
  return process.version;
}
678888
def get_version_from_module(module):
    """"""
    if module is not None:
        # Setup.py will not pass in a module, but creating __version__ from
        # __init__ will.
        module = str(module).split('.', 1)[0]
        try:
            package = pkg_resources.get_distribution(module)
            return package.version
        except pkg_resources.DistributionNotFound:
            # So there you have it the module is not installed.
            pass