def pip_version_check(session, options):<EOL>
installed_version = get_installed_version("<STR_LIT>")<EOL>if not installed_version:<EOL><INDENT>return<EOL><DEDENT>pip_version = packaging_version.parse(installed_version)<EOL>pypi_version = None<EOL>try:<EOL><INDENT>state = SelfCheckState(cache_dir=options.cache_dir)<EOL>current_time = datetime.datetime.utcnow()<EOL>if "<STR_LIT>" in state.state and "<STR_LIT>" in state.state:<EOL><INDENT>last_check = datetime.datetime.strptime(<EOL>state.state["<STR_LIT>"],<EOL>SELFCHECK_DATE_FMT<EOL>)<EOL>if (current_time - last_check).total_seconds() < <NUM_LIT:7> * <NUM_LIT> * <NUM_LIT> * <NUM_LIT>:<EOL><INDENT>pypi_version = state.state["<STR_LIT>"]<EOL><DEDENT><DEDENT>if pypi_version is None:<EOL><INDENT>finder = PackageFinder(<EOL>find_links=options.find_links,<EOL>index_urls=[options.index_url] + options.extra_index_urls,<EOL>allow_all_prereleases=False,  <EOL>trusted_hosts=options.trusted_hosts,<EOL>session=session,<EOL>)<EOL>all_candidates = finder.find_all_candidates("<STR_LIT>")<EOL>if not all_candidates:<EOL><INDENT>return<EOL><DEDENT>pypi_version = str(<EOL>max(all_candidates, key=lambda c: c.version).version<EOL>)<EOL>state.save(pypi_version, current_time)<EOL><DEDENT>remote_version = packaging_version.parse(pypi_version)<EOL>if (pip_version < remote_version and<EOL>pip_version.base_version != remote_version.base_version and<EOL>was_installed_by_pip('<STR_LIT>')):<EOL><INDENT>if WINDOWS:<EOL><INDENT>pip_cmd = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>pip_cmd = "<STR_LIT>"<EOL><DEDENT>logger.warning(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>pip_version, pypi_version, pip_cmd<EOL>)<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>logger.debug(<EOL>"<STR_LIT>",<EOL>exc_info=True,<EOL>)<EOL><DEDENT>
Check for an update for pip.

    Limit the frequency of checks to once per week. State is stored either in
    the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
    of the pip script path.