U .ec, @ sX d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z ddl mZ ddlm Z dd lmZ dd lmZ ddlmZ ddlmZmZmZ dd lmZ ddlmZmZ ddlmZ ddlm Z e r"ddl!m"Z" ddl#m$Z$m%Z%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z, ddl-m.Z. ddl/m0Z0 G dd deZ1G dd dee1Z2G dd de2Z3dS )a Contains the Command base classes that depend on PipSession. The classes in this module are in a separate module so the commands not needing download / PackageFinder capability don't unnecessarily import the PackageFinder machinery and all its vendored dependencies, etc. N)partial)Command)CommandContextMixIn)CommandError) PackageFinder)Resolver)SelectionPreferences) PipSession)RequirementPreparer)install_req_from_editableinstall_req_from_lineinstall_req_from_req_string)parse_requirements)make_link_collectorpip_self_version_check)normalize_path)MYPY_CHECK_RUNNING)Values)ListOptionalTuple) WheelCache)TargetPython)RequirementSet)RequirementTracker) TempDirectoryc s> e Zd ZdZ fddZedd Zdd Zdd d Z Z S )SessionCommandMixinzE A class mixin for command classes needing _build_session(). c s t t| d | _d S )N)superr __init___session)self __class__ A/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.pyr 2 s zSessionCommandMixin.__init__c C sL g }t |dds*t |dd}|r*|| t |dd}|rD|| |pJdS )z7Return a list of index urls from user-provided options.no_indexFZ index_urlNZextra_index_urls)getattrappendextend)clsoptions index_urlsZurlZurlsr# r# r$ _get_index_urls6 s z#SessionCommandMixin._get_index_urlsc C s" | j dkr| | || _ | j S )zGet a default-managed session.N)r enter_context_build_session)r r* r# r# r$ get_default_sessionD s z'SessionCommandMixin.get_default_sessionNc C s t |jrttj|jdnd |d k r*|n|j|j| |d}|j rN|j |_ |jr\|j|_ |jsf|rz|d k rr|n|j|_|j r|j |j d|_|j |j_|S )Nhttp)cacheretries trusted_hostsr+ )r0 Zhttps)r cache_dirr ospathjoinr2 r3 r, ZcertZverifyZclient_certtimeoutproxyZproxiesZno_inputZauthZ prompting)r r* r2 r8 sessionr# r# r$ r. K s* z"SessionCommandMixin._build_session)NN) __name__ __module____qualname____doc__r classmethodr, r/ r. __classcell__r# r# r! r$ r - s r c @ s e Zd ZdZdd ZdS )IndexGroupCommandz Abstract base class for commands with the index_group options. This also corresponds to the commands that permit the pip version check. c C sT t |dst|js|jrdS | j|dtd|jd}| t|| W 5 Q R X dS )z Do the pip version check if not disabled. This overrides the default behavior of not doing the check. r% Nr )r2 r8 )hasattrAssertionErrorZdisable_pip_version_checkr% r. minr8 r )r r* r: r# r# r$ handle_pip_version_checkz s z*IndexGroupCommand.handle_pip_version_checkN)r; r<