def _build_session(self, options, retries=None, timeout=None): session = PipSession( cache=(normalize_path(os.path.join(options.cache_dir, "http")) if options.cache_dir else None), retries=retries if retries is not None else options.retries, insecure_hosts=options.trusted_hosts, ) # Handle custom ca-bundles from the user if options.cert: session.verify = options.cert # Handle SSL client certificate if options.client_cert: session.cert = options.client_cert # Handle timeouts if options.timeout or timeout: session.timeout = (timeout if timeout is not None else options.timeout) # Handle configured proxies if options.proxy: session.proxies = { "http": options.proxy, "https": options.proxy, } # Determine if we can prompt the user for authentication or not session.auth.prompting = not options.no_input return session
def _build_session(options, retries=None, timeout=None): session = PipSession( cache=( normalize_path(os.path.join(options.get('cache_dir'), 'http')) if options.get('cache_dir') else None ), retries=retries if retries is not None else options.get('retries'), insecure_hosts=options.get('trusted_hosts'), ) # Handle custom ca-bundles from the user if options.get('cert'): session.verify = options.get('cert') # Handle SSL client certificate if options.get('client_cert'): session.cert = options.get('client_cert') # Handle timeouts if options.get('timeout') or timeout: session.timeout = ( timeout if timeout is not None else options.get('timeout') ) # Handle configured proxies if options.get('proxy'): session.proxies = { 'http': options.get('proxy'), 'https': options.get('proxy'), } # Determine if we can prompt the user for authentication or not session.auth.prompting = not options.get('no_input') return session
def _build_session(self, options, retries=None, timeout=None): session = PipSession( cache=( normalize_path(os.path.join(options.cache_dir, "http")) if options.cache_dir else None ), retries=retries if retries is not None else options.retries, insecure_hosts=options.trusted_hosts, ) # Handle custom ca-bundles from the user if options.cert: session.verify = options.cert # Handle SSL client certificate if options.client_cert: session.cert = options.client_cert # Handle timeouts if options.timeout or timeout: session.timeout = ( timeout if timeout is not None else options.timeout ) # Handle configured proxies if options.proxy: session.proxies = { "http": options.proxy, "https": options.proxy, } # Determine if we can prompt the user for authentication or not session.auth.prompting = not options.no_input return session
def _get_requirements_and_latest( filename, force=False, minor=[], patch=[], pre=[], index_urls=[], verify=None): """Parse a requirements file and get latest version for each requirement. Yields a tuple of (original line, InstallRequirement instance, spec_versions, latest_version). :param filename: Path to a requirements.txt file. :param force: Force getting latest version even for packages without a version specified. :param minor: List of packages to only update minor and patch versions, never major. :param patch: List of packages to only update patch versions, never minor or major. :param pre: List of packages to allow updating to pre-release versions. :param index_urls: List of base URLs of the Python Package Index. :param verify: Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to None. """ session = PipSession() if verify: session.verify = verify finder = PackageFinder( session=session, find_links=[], index_urls=index_urls or [PyPI.simple_url], ) _, content = get_file_content(filename, session=session) for line_number, line, orig_line in yield_lines(content): line = req_file.COMMENT_RE.sub('', line) line = line.strip() req = parse_requirement_line(line, filename, line_number, session, finder) if req is None or req.name is None or req_file.SCHEME_RE.match(req.name): yield (orig_line, None, None, None) continue spec_ver = current_version(req) if spec_ver or force: latest_ver = latest_version(req, spec_ver, session, finder, minor=minor, patch=patch, pre=pre) yield (orig_line, req, spec_ver, latest_ver)