U ��.ec,�@sXdZddlZddlmZddlmZddlmZddlm Z ddl m Z ddl m Z dd lmZdd lmZdd lmZdd lmZmZmZdd lmZddlmZmZddlmZddlm 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/m0Z0Gdd�de�Z1Gdd�dee1�Z2Gdd�de2�Z3dS)aContains 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_editable�install_req_from_line�install_req_from_req_string)�parse_requirements)�make_link_collector�pip_self_version_check)�normalize_path)�MYPY_CHECK_RUNNING)�Values)�List�Optional�Tuple)� WheelCache)� TargetPython)�RequirementSet)�RequirementTracker)� TempDirectorycs>eZdZdZ�fdd�Zedd��Zdd�Zd d d �Z�Z S) �SessionCommandMixinzE A class mixin for command classes needing _build_session(). cstt|���d|_dS)N)�superr�__init__�_session)�self�� __class__��A/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.pyr2szSessionCommandMixin.__init__cCsLg}t|dd�s*t|dd�}|r*|�|�t|dd�}|rD|�|�|pJdS)z7Return a list of index urls from user-provided options.�no_indexFZ index_urlNZextra_index_urls)�getattr�append�extend)�cls�options� index_urlsZurlZurlsr#r#r$�_get_index_urls6s     z#SessionCommandMixin._get_index_urlscCs"|jdkr|�|�|��|_|jS)zGet a default-managed session.N)r� enter_context�_build_session)r r*r#r#r$�get_default_sessionDs z'SessionCommandMixin.get_default_sessionNcCs�t|jrttj�|jd��nd|dk r*|n|j|j|�|�d�}|j rN|j |_ |j r\|j |_ |j sf|rz|dk rr|n|j |_ |j r�|j |j d�|_|j |j_|S)N�http)�cache�retries� trusted_hostsr+)r0Zhttps)r � cache_dirr�os�path�joinr2r3r,ZcertZverifyZ client_cert�timeout�proxyZproxiesZno_inputZauthZ prompting)r r*r2r8�sessionr#r#r$r.Ks*��  �� z"SessionCommandMixin._build_session)NN) �__name__� __module__� __qualname__�__doc__r� classmethodr,r/r.� __classcell__r#r#r!r$r-s   rc@seZdZdZdd�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 CsTt|d�st�|js|jrdS|j|dtd|j�d�}|�t||�W5QRXdS)z� Do the pip version check if not disabled. This overrides the default behavior of not doing the check. r%Nr�)r2r8)�hasattr�AssertionErrorZdisable_pip_version_checkr%r.�minr8r)r r*r:r#r#r$�handle_pip_version_checkzs  �z*IndexGroupCommand.handle_pip_version_checkN)r;r<r=r>rFr#r#r#r$rArsrAc @s:eZdZed dd��Zeddd��Zd d �Zdd d �ZdS)�RequirementCommandNc Cs.|j}|dk st�t||j|||j|j|d�S)zQ Create a RequirementPreparer instance for the given parameters. N)Z build_dir�src_dir� download_dir�wheel_download_dir� progress_bar�build_isolation� req_tracker)r6rDr rHrKrL)Ztemp_build_dirr*rMrIrJZtemp_build_dir_pathr#r#r$�make_requirement_preparer�s  �z,RequirementCommand.make_requirement_preparerFT�to-satisfy-onlyc Cs2tt|j|| d�} t|||| ||j|||| | d� S)zF Create a Resolver instance for the given parameters. )�isolated� wheel_cache� use_pep517) �preparerr:�finder�make_install_req� use_user_site�ignore_dependencies�ignore_installed�ignore_requires_python�force_reinstall�upgrade_strategy�py_version_info)rr � isolated_moderrW) rSr:rTr*rQrVrXrYrZr[rRr\rUr#r#r$� make_resolver�s&��z RequirementCommand.make_resolverc Cs,|jD].}t|d||||d�D]}d|_|�|�qq|D]*} t| d|j|j|d�}d|_|�|�q:|jD](} t| |j|j|d�}d|_|�|�ql|j D]0}t||||||jd�D]}d|_|�|�q�q�|j |_ |�s(|j�s(|j �s(d|j i} |j �rt dt| d�|j �d ���n t d | ��dS) z? Marshal cmd line args into a requirement set. T)Z constraintrTr*r:rQN)rPrRrQ)rTr*r:rQrR�namez^You must give at least one requirement to %(name)s (maybe you meant "pip %(name)s %(links)s"?)� )ZlinkszLYou must give at least one requirement to %(name)s (see "pip help %(name)s"))Z constraintsrZ is_directZadd_requirementr r]rRZ editablesr Z requirementsZrequire_hashesr_Z find_linksr�dictr7) r Zrequirement_set�argsr*rTr:rQ�filenameZ req_to_addZreqZoptsr#r#r$�populate_requirement_set�sn � �  �  �  ����z+RequirementCommand.populate_requirement_setcCs4t||d�}td|j|j|j|d�}tj|||d�S)z� Create a package finder appropriate to this requirement command. :param ignore_requires_python: Whether to ignore incompatible "Requires-Python" values in links. Defaults to False. )r*T)Z allow_yanked�format_controlZallow_all_prereleases� prefer_binaryrY)�link_collector�selection_prefs� target_python)rrreZprerfrZcreate)r r*r:rirYrgrhr#r#r$�_build_package_finders ��z(RequirementCommand._build_package_finder)NN)NFTFFrONN)NN)r;r<r=� staticmethodrNr^rdrjr#r#r#r$rG�s$� � &G�rG)4r>r5� functoolsrZpip._internal.cli.base_commandrZ!pip._internal.cli.command_contextrZpip._internal.exceptionsrZpip._internal.indexrZpip._internal.legacy_resolverZ$pip._internal.models.selection_prefsrZpip._internal.network.sessionr Z pip._internal.operations.preparer Zpip._internal.req.constructorsr r r Zpip._internal.req.req_filerZ!pip._internal.self_outdated_checkrrZpip._internal.utils.miscrZpip._internal.utils.typingrZoptparser�typingrrrZpip._internal.cacherZ"pip._internal.models.target_pythonrZpip._internal.req.req_setrZpip._internal.req.req_trackerrZpip._internal.utils.temp_dirrrrArGr#r#r#r$�s4                   E