
    i                    4   d Z ddlmZ ddl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 erddlmZ ddlmZ ddlmZ ddlmZ  ej8                  e      Ze	dd       Z G d de      Z 	 	 	 	 	 	 ddZ!ddZ" G d dee       Z#y)a&  
Contains command classes which may interact with an index / the network.

Unlike its sister module, req_command, this module still uses lazy imports
so commands which don't always hit the network (e.g. list w/o --outdated or
--uptodate) don't need waste time importing PipSession and friends.
    )annotationsN)Iterator)	lru_cache)Values)TYPE_CHECKING)certifi)Command)CommandContextMixIn)
SSLContext)NormalizedName
PipSession)UpgradePromptc                 *   	 dd l } 	 ddlm} |j                  | j                        }|j                  t        j                                |S # t        $ r t        j                  d       Y y w xY w# t        $ r t        j                  d       Y y w xY w)Nr   z1Disabling truststore since ssl support is missing)
truststorez5Disabling truststore because platform isn't supported)sslImportErrorloggerwarningpip._vendorr   r   PROTOCOL_TLS_CLIENTload_verify_locationsr   where)r   r   ctxs      R/root/searxng-venv/lib/python3.12/site-packages/pip/_internal/cli/index_command.py_create_truststore_ssl_contextr   #   s    
*
 

 7 7
8Cgmmo.J  JK  NOs"   A A1 A.-A.1BBc                  Z     e Zd ZdZd fdZedd       ZddZ	 	 d		 	 	 	 	 	 	 d
dZ xZ	S )SessionCommandMixinzE
    A class mixin for command classes needing _build_session().
    c                0    t         |           d | _        y )N)super__init___session)self	__class__s    r   r!   zSessionCommandMixin.__init__;   s    +/    c                    g }t        |dd      s t        |dd      }|r|j                  |       t        |dd      }|r|j                  |       |xs d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urlurlss        r   _get_index_urlsz#SessionCommandMixin._get_index_urls?   s_     
w
E2';5C!!#&w 2D9d#!T!r%   c                    | j                   3| j                  | j                  |            | _         | j                   J | j                   S )zGet a default-managed session.)r"   enter_context_build_session)r#   r.   s     r   get_default_sessionz'SessionCommandMixin.get_default_sessionM   sE    ==  ..t/B/B7/KLDM ==,,,}}r%   c           	        ddl m} |j                  }|r!t        j                  j                  |      sJ d|j                  vrt               }nd } ||r t        j                  j                  |d      nd ||n|j                  |j                  |j                  | j                  |      |      }|j                  r|j                  |_        |j                  r|j                  |_        |j                   s|r||n|j                   |_        |j"                  r6|j"                  |j"                  d|_        d|_        |j"                  |_        |j*                   |j,                  _        |j0                  |j,                  _        |S )Nr   r   zlegacy-certszhttp-v2)cacheretriesresume_retriestrusted_hostsr/   ssl_context)httphttpsF)pip._internal.network.sessionr   	cache_dirospathisabsdeprecated_features_enabledr   joinr9   r:   r;   r2   certverifyclient_certtimeoutproxyproxies	trust_env	pip_proxyno_inputauth	promptingkeyring_provider)r#   r.   r9   rI   r   r@   r<   sessions           r   r5   z"SessionCommandMixin._build_sessionW   sC    	=%%	i 888!D!DD8:KK8A"'',,y)4t&2G"11!//++G4#
 <<$\\GN "..GL ??g)0)<g'//GO == GO !&G 'G &-%5%5!5(/(@(@%r%   )returnNone)r.   r   rS   zlist[str] | None)r.   r   rS   r   )NN)r.   r   r9   
int | NonerI   rU   rS   r   )
__name__
__module____qualname____doc__r!   classmethodr2   r6   r5   __classcell__)r$   s   @r   r   r   6   sY    0 " " #"	22 2 	2
 
2r%   r   c                     ddl m}  || |      S )Nr   )pip_self_version_check_fetch)!pip._internal.self_outdated_checkr]   )rR   r.   r]   s      r   _pip_self_version_check_fetchr_      s     O'99r%   c                     ddl m}  ||        y )Nr   )pip_self_version_check_emit)r^   ra   )upgrade_promptra   s     r   _pip_self_version_check_emitrc      s    M/r%   c                  J    e Zd ZdZ	 	 	 	 	 	 ddZej                  dd       Zy)IndexGroupCommandz
    Abstract base class for commands with the index_group options.

    This also corresponds to the commands that permit the pip version check.
    c                f    |j                   r%|j                   j                  |      }|du ry|du ryy)zM
        Determine if pre-releases should be excluded for a package.
        TF)release_controlallows_prereleases)r#   r.   package_nameallow_prereleasess       r   should_exclude_prereleasez+IndexGroupCommand.should_exclude_prerelease   s?     "" ' 7 7 J J< X D("e+ r%   c              #    K   t        |d      sJ |j                  s|j                  rd yd}	 | j                  |dt	        d|j
                              }|5  t        ||      }ddd       	 d 	 t        |       y# 1 sw Y   xY w# t        $ r/ t        j                  d       t        j                  dd	       Y Uw xY w# t        $ r/ t        j                  d       t        j                  dd	       Y yw xY w# 	 t        |       w # t        $ r/ t        j                  d       t        j                  dd	       Y w w xY wxY ww)
z
        Do the pip version check if not disabled.

        This overrides the default behavior of not doing the check.
        r'   Nr      )r9   rI   z6There was an error checking the latest version of pip.zSee below for errorT)exc_info)hasattrdisable_pip_version_checkr'   r5   minrI   r_   	Exceptionr   r   debugrc   )r#   r.   argsrb   rR   s        r   pip_version_checkz#IndexGroupCommand.pip_version_check   s;     w
+++,,0@0@/3
	?))Aw/ * G
  Q!>w!PQ	CC,^<Q Q 	?NNSTLL.L>	?  CWX2TBCC,^< CWX2TBCs   .E*B B(B 1D 6C	 EBB 5CECE	5D>E DEEDE5E
E	E

EEN)r.   r   ri   r   rS   bool)r.   r   rt   z	list[str]rS   zIterator[None])rV   rW   rX   rY   rk   
contextlibcontextmanagerru    r%   r   re   re      s@    -;	" !C !Cr%   re   )rS   zSSLContext | None)rR   r   r.   r   rS   UpgradePrompt | None)rb   rz   rS   rT   )$rY   
__future__r   rw   loggingrA   collections.abcr   	functoolsr   optparser   typingr   r   r   pip._internal.cli.base_commandr	   !pip._internal.cli.command_contextr
   r   r   pip._vendor.packaging.utilsr   r?   r   r^   r   	getLoggerrV   r   r   r   r_   rc   re   ry   r%   r   <module>r      s    #   	 $      2 A:8?			8	$  $S- Sl::"(::0:C!4 :Cr%   