U
    ;qLe0                     @   sj  d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZmZmZ ddlmZ ddlmZmZ ddl m!Z! e!r*ddl"m#Z# ddl$m%Z%m&Z&m'Z' ddl(m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/ ddl0m1Z1 e2e3Z4G dd deZ5G dd dee5Z6G dd de6Z7dS )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)
Downloader)
PipSession)RequirementPreparer)install_req_from_editableinstall_req_from_lineinstall_req_from_req_string)parse_requirements)make_link_collectorpip_self_version_check)MYPY_CHECK_RUNNING)Values)ListOptionalTuple)
WheelCache)TargetPython)RequirementSet)RequirementTracker)TempDirectoryc                       s>   e Zd ZdZ fddZedd Zdd Zdd	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__ t/home/p21-0144/sympy/latex2sympy2solve-back-end/sympyEq/lib/python3.8/site-packages/pip/_internal/cli/req_command.pyr   2   s    zSessionCommandMixin.__init__c                 C   sL   g }t |dds*t |dd}|r*|| t |dd}|rD|| |pJdS )z7Return a list of index urls from user-provided options.no_indexF	index_urlNextra_index_urls)getattrappendextend)clsoptions
index_urlsurlZurlsr$   r$   r%   _get_index_urls7   s    

z#SessionCommandMixin._get_index_urlsc                 C   s0   | j dkr*| | || _ | j dk	s*t| j S )zGet a default-managed session.N)r    enter_context_build_sessionAssertionError)r!   r-   r$   r$   r%   get_default_sessionF   s    
z'SessionCommandMixin.get_default_sessionNc                 C   s   |j rtj|j stt|j r0tj|j dnd |d k	r>|n|j|j| 	|d}|j
rb|j
|_|jrp|j|_
|jsz|r|d k	r|n|j|_|jr|j|jd|_|j |j_|S )Nhttp)cacheretriestrusted_hostsr.   )r5   https)	cache_dirospathisabsr3   r
   joinr7   r8   r0   certverifyclient_certtimeoutproxyproxiesno_inputauthZ	prompting)r!   r-   r7   rB   sessionr$   r$   r%   r2   Q   s,    
z"SessionCommandMixin._build_session)NN)
__name__
__module____qualname____doc__r   classmethodr0   r4   r2   __classcell__r$   r$   r"   r%   r   -   s   
r   c                   @   s   e Zd ZdZdd ZdS )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 |dst|js|jrdS | j|dtd|jd}| t|| W 5 Q R X dS )z
        Do the pip version check if not disabled.

        This overrides the default behavior of not doing the check.
        r&   Nr      )r7   rB   )hasattrr3   disable_pip_version_checkr&   r2   minrB   r   )r!   r-   rG   r$   r$   r%   handle_pip_version_check   s    
z*IndexGroupCommand.handle_pip_version_checkN)rH   rI   rJ   rK   rS   r$   r$   r$   r%   rN   y   s   rN   c                	   @   sF   e Zd ZedddZedddZd	d
 Zedd ZdddZdS )RequirementCommandNc           
      C   sB   t ||jd}| j}	|	dk	s tt|	|j|||j||||j|d
S )zQ
        Create a RequirementPreparer instance for the given parameters.
        )progress_barN)
	build_dirsrc_dirdownload_dirwheel_download_dirbuild_isolationreq_tracker
downloaderfinderrequire_hashesuse_user_site)r	   rU   r<   r3   r   rW   rZ   r^   )
Ztemp_build_dirr-   r[   rG   r]   r_   rX   rY   r\   Ztemp_build_dir_pathr$   r$   r%   make_requirement_preparer   s    z,RequirementCommand.make_requirement_preparerFTto-satisfy-onlyc                 C   s0   t t|j||	d}t| ||||j|||||
d
S )zF
        Create a Resolver instance for the given parameters.
        )isolatedwheel_cache
use_pep517)
preparerr]   make_install_reqr_   ignore_dependenciesignore_installedignore_requires_pythonforce_reinstallupgrade_strategypy_version_info)r   r   isolated_moder   rg   )re   r]   r-   rc   r_   rh   ri   rj   rk   rd   rl   rf   r$   r$   r%   make_resolver   s$    z RequirementCommand.make_resolverc              	   C   sP  |j D ].}t|d||||dD ]}d|_|| qq|D ]*}	t|	d|j|j|d}d|_|| q:|jD ](}	t|	|j|j|d}d|_|| ql|j	D ]0}t||||||jdD ]}d|_|| qq|j
t|j	  }
tdd |
D rd|_|sL|jsL|j	sLd| ji}|jr@td	t|d
|jd ntd| dS )z?
        Marshal cmd line args into a requirement set.
        T)Z
constraintr]   r-   rG   rc   N)rb   rd   rc   )r]   r-   rG   rc   rd   c                 s   s   | ]}|j V  qd S r   )Zhas_hash_options).0reqr$   r$   r%   	<genexpr>  s     z>RequirementCommand.populate_requirement_set.<locals>.<genexpr>namez^You must give at least one requirement to %(name)s (maybe you meant "pip %(name)s %(links)s"?) )linkszLYou must give at least one requirement to %(name)s (see "pip help %(name)s"))constraintsr   Z	is_directZadd_requirementr   rm   rd   	editablesr   requirementsZunnamed_requirementslistvaluesanyr^   rr   
find_linksr   dictr>   )r!   Zrequirement_setargsr-   r]   rG   rc   filenameZ
req_to_addrp   rw   optsr$   r$   r%   populate_requirement_set   sx    
   
  

  

z+RequirementCommand.populate_requirement_setc                 C   s    | j }| }|rt| dS )zE
        Trace basic information about the provided objects.
        N)search_scopeZget_formatted_locationsloggerinfo)r]   r   	locationsr$   r$   r%   trace_basic_info&  s    z#RequirementCommand.trace_basic_infoc                 C   s4   t ||d}td|j|j|j|d}tj|||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)allow_yankedformat_controlallow_all_prereleasesprefer_binaryri   )link_collectorselection_prefstarget_python)r   r   r   prer   r   create)r!   r-   rG   r   ri   r   r   r$   r$   r%   _build_package_finder2  s    z(RequirementCommand._build_package_finder)NN)NFTFFra   NN)NN)	rH   rI   rJ   staticmethodr`   rn   r   r   r   r$   r$   r$   r%   rT      s(              $F
  rT   )8rK   loggingr;   	functoolsr   Zpip._internal.cli.base_commandr   Z!pip._internal.cli.command_contextr   pip._internal.exceptionsr   "pip._internal.index.package_finderr   Zpip._internal.legacy_resolver   $pip._internal.models.selection_prefsr   Zpip._internal.network.downloadr	   Zpip._internal.network.sessionr
   Z pip._internal.operations.preparer   Zpip._internal.req.constructorsr   r   r   Zpip._internal.req.req_filer   !pip._internal.self_outdated_checkr   r   pip._internal.utils.typingr   optparser   typingr   r   r   Zpip._internal.cacher   "pip._internal.models.target_pythonr   Zpip._internal.req.req_setr   Zpip._internal.req.req_trackerr   Zpip._internal.utils.temp_dirr   	getLoggerrH   r   r   rN   rT   r$   r$   r$   r%   <module>   s8   
L