Given a requirement and optional version returns a (version, releasedate)
    tuple. Defaults to the latest version. Prints to stdout if verbose is True.
    Optional response argument is the response from PyPI to be used for
    asyncronous lookups.
482936
def get_version_and_release_date(requirement, version=None,
                                 verbose=False, response=None):
    
    try:
        if not response:
            url = get_pypi_url(requirement, version)
            response = requests.get(url)

        # see if the url is 404'ing because it has been redirected
        if response.status_code == 404:
            root_url = url.rpartition('/')[0]
            res = requests.head(root_url)
            if res.status_code == 301:
                new_location = res.headers['location'] + '/json'
                response = requests.get(new_location)

        response = response.json()
    except requests.HTTPError:
        if version:
            if verbose:
                print('{} ({}) isn\'t available on PyPI '
                      'anymore!'.format(requirement, version))
        else:
            if verbose:
                print('{} isn\'t on PyPI. Check that the project '
                      'still exists!'.format(requirement))
        return None, None
    except ValueError:
        if verbose:
            print('Decoding the JSON response for {} ({}) '
                  'failed'.format(requirement, version))
        return None, None

    try:
        if version:
            if version in response['releases']:
                release_date = response['releases'][version][0]['upload_time']
            else:
                return None, None
        else:
            version = response['info'].get('stable_version')

            if not version:
                versions = {
                    v: parse_version(v) for v in response['releases'].keys()
                    if not parse_version(v).is_prerelease()
                }

                # if we still don't have a version, let's pick up a prerelease one
                if not versions:
                    versions = {
                        v: parse_version(v) for v in response['releases'].keys()
                    }

                if versions:
                    version = max(versions.items(), key=operator.itemgetter(1))[0]
                    release_date = (
                        response['releases'][str(version)][0]['upload_time']
                    )
                else:
                    return None, None

        return version, datetime.fromtimestamp(time.mktime(
            time.strptime(release_date, '%Y-%m-%dT%H:%M:%S')
        ))
    except IndexError:
        if verbose:
            print('{} ({}) didn\'t return a date property'.format(requirement,
                                                                  version))
        return None, None
311740
def fetch(self):
        
        params = values.of({})

        payload = self._version.fetch(
            'GET',
            self._uri,
            params=params,
        )

        return FunctionVersionInstance(
            self._version,
            payload,
            service_sid=self._solution['service_sid'],
            function_sid=self._solution['function_sid'],
            sid=self._solution['sid'],
        )
572517
def get_version():
    
    if not os.path.exists(VERSION_FILE):
        raise VersionNotFound(VERSION_FILE + " does not exist")
    fp = open(VERSION_FILE, "r")
    vline = None
    for x in fp.readlines():
        x = x.rstrip()
        if not x:
            continue
        if not x.startswith("__version__"):
            continue

        vline = x.split('=')[1]
        break
    if not vline:
        raise VersionNotFound("version file present but has no contents")

    return vline.strip().rstrip().replace("'", '')
871662
def update_req(req):
    """"""

    if not req.name:
        return req, None

    info = get_package_info(req.name)

    if info['info'].get('_pypi_hidden'):
        print('{} is hidden on PyPI and will not be updated.'.format(req))
        return req, None

    if _is_pinned(req) and _is_version_range(req):
        print('{} is pinned to a range and will not be updated.'.format(req))
        return req, None

    newest_version = _get_newest_version(info)
    current_spec = next(iter(req.specifier)) if req.specifier else None
    current_version = current_spec.version if current_spec else None
    new_spec = Specifier(u'=={}'.format(newest_version))
    if not current_spec or current_spec._spec != new_spec._spec:
        req.specifier = new_spec
        update_info = (
            req.name,
            current_version,
            newest_version)
        return req, update_info
    return req, None
1341584
def get_version(package, url_pattern=URL_PATTERN):
    """"""
    req = requests.get(url_pattern.format(package=package))
    version = parse('0')
    if req.status_code == requests.codes.ok:
        # j = json.loads(req.text.encode(req.encoding))
        j = req.json()
        releases = j.get('releases', [])
        for release in releases:
            ver = parse(release)
            if not ver.is_prerelease:
                version = max(version, ver)
    return version
484654
def require(*requirements, **kwargs):
    
    # TODO: require(*requirements, none_on_failure=False) is not supported by Python 2
    none_on_failure = kwargs.get('none_on_failure', False)

    def inner(f):
        @functools.wraps(f)
        def wrapper(*args, **kwargs):
            for req in requirements:
                if none_on_failure:
                    if not getattr(req, 'is_available'):
                        return None
                else:
                    getattr(req, 'require')()
            return f(*args, **kwargs)
        return wrapper
    return inner
492570
def check_options(options, parser):
    
    if not options.get('release_environment', None):
        print("release environment is required")
        parser.print_help()
        return os.EX_USAGE

    return 0
747982
def check_requirements(self, reqs):
        # type: (Iterable[str]) -> Tuple[Set[Tuple[str, str]], Set[str]]
        
        missing = set()
        conflicting = set()
        if reqs:
            ws = WorkingSet(self._lib_dirs)
            for req in reqs:
                try:
                    if ws.find(Requirement.parse(req)) is None:
                        missing.add(req)
                except VersionConflict as e:
                    conflicting.add((str(e.args[0].as_requirement()),
                                     str(e.args[1])))
        return conflicting, missing
349087
def get_repo_version(url):
    
    response = requests.get(url)
    if response.status_code == 404:
        return None
    else:
        return response.text.replace('\n', '')
7893
def as_tuple(ireq):
    

    if not is_pinned_requirement(ireq):
        raise TypeError("Expected a pinned InstallRequirement, got {}".format(ireq))

    name = key_from_req(ireq.req)
    version = first(ireq.specifier._specs)._spec[1]
    extras = tuple(sorted(ireq.extras))
    return name, version, extras
582354
def version(self):
		
		lines = iter(self._invoke('version').splitlines())
		version = next(lines).strip()
		return self._parse_version(version)
272219
def _get_uploaded_versions_warehouse(project_name, index_url, requests_verify=True):
    
    url = '/'.join((index_url, project_name, 'json'))
    response = requests.get(url, verify=requests_verify)
    if response.status_code == 200:
        return response.json()['releases'].keys()
    return None
1195261
def validate_pypi_opts(opt_parser):
    

    (options, remaining_args) = opt_parser.parse_args()
    options_pkg_specs = [ options.versions_available,
            options.query_metadata_pypi,
            options.show_download_links,
            options.browse_website,
            options.fetch,
            options.show_deps,
            ]
    for pkg_spec in options_pkg_specs:
        if pkg_spec:
            return pkg_spec
1226922
def _require_min_api_version(self, version):
    
    actual_version = self._get_resource_root().version
    version = max(version, self._api_version())
    if actual_version < version:
      raise Exception("API version %s is required but %s is in use."
          % (version, actual_version))
846417
def version
      v = KJess::Request::Version.new
      r = send_recv( v )
      return r.version if Response::Version === r
      raise KJess::ProtocolError, "Unexpected Response from VERSION command"
    end
1358451
def _get_uploaded_versions_pypicloud(project_name, index_url, requests_verify=True):
    
    api_url = index_url
    for suffix in ('/pypi', '/pypi/', '/simple', '/simple/'):
        if api_url.endswith(suffix):
            api_url = api_url[:len(suffix) * -1] + '/api/package'
            break
    url = '/'.join((api_url, project_name))
    response = requests.get(url, verify=requests_verify)
    if response.status_code == 200:
        return [p['version'] for p in response.json()['packages']]
    return None
14911
def map_version(self, requirement, local_version):
        
        if isinstance(self._versions_map, dict):
            version = self._versions_map.get(requirement, {}).get(
                local_version, local_version)
        else:
            version = self._versions_map(requirement, local_version)
        return version