
    KuiT                       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 erdd
lmZ ddlmZ ddlmZ  ej0                  e      Zedd       Z G d de      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)	lru_cache)Values)TYPE_CHECKING)certifi)Command)CommandContextMixIn)
SSLContext)NormalizedName
PipSessionc                 |   t         j                  dk  rt        j                  d       y 	 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)N)   
   z7Disabling truststore because Python version isn't 3.10+r   z1Disabling truststore since ssl support is missing)
truststorez5Disabling truststore because platform isn't supported)sysversion_infologgerdebugsslImportErrorwarningpip._vendorr   r
   PROTOCOL_TLS_CLIENTload_verify_locationsr   where)r   r   ctxs      i/root/.openclaw/workspace/chatterbox_venv/lib/python3.12/site-packages/pip/_internal/cli/index_command.py_create_truststore_ssl_contextr   !   s    
'!NO
*
 

 7 7
8Cgmmo.J  JK  NOs"   A6 B 6BB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_urlsA   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&   r1   s     r   get_default_sessionz'SessionCommandMixin.get_default_sessionO   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_hostsr2   ssl_context)httphttpsF)pip._internal.network.sessionr   	cache_dirospathisabsdeprecated_features_enabledr   joinr<   r=   r>   r5   certverifyclient_certtimeoutproxyproxies	trust_env	pip_proxyno_inputauth	promptingkeyring_provider)r&   r1   r<   rL   r   rC   r?   sessions           r   r8   z"SessionCommandMixin._build_sessionY   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)r1   r   rV   zlist[str] | None)r1   r   rV   r   )NN)r1   r   r<   
int | NonerL   rX   rV   r   )
__name__
__module____qualname____doc__r$   classmethodr5   r9   r8   __classcell__)r'   s   @r   r!   r!   8   sY    0 " " #"	22 2 	2
 
2r(   r!   c                "    ddl m}  || |       y )Nr   )pip_self_version_check)!pip._internal.self_outdated_checkr`   )rU   r1   checks      r   _pip_self_version_checkrc      s    Q	'7r(   c                  ,    e Zd ZdZ	 	 	 	 	 	 ddZ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&   r1   package_nameallow_prereleasess       r   should_exclude_prereleasez+IndexGroupCommand.should_exclude_prerelease   s?     "" ' 7 7 J J< X D("e+ r(   c                `   t        |d      sJ |j                  s|j                  ry	 | j                  |dt	        d|j
                              }|5  t        ||       ddd       y# 1 sw Y   yxY w# t        $ r/ t        j                  d       t        j                  dd	       Y yw xY w)
z
        Do the pip version check if not disabled.

        This overrides the default behavior of not doing the check.
        r*   Nr      )r<   rL   z6There was an error checking the latest version of pip.zSee below for errorT)exc_info)hasattrdisable_pip_version_checkr*   r8   minrL   rc   	Exceptionr   r   r   )r&   r1   rU   s      r   handle_pip_version_checkz*IndexGroupCommand.handle_pip_version_check   s     w
+++,,0@0@	?))Aw/ * G
  :'9: : : 	?NNSTLL.L>	?s/   *A5 A) A5 )A2.A5 2A5 55B-,B-N)r1   r   ri   r   rV   bool)r1   r   rV   rW   )rY   rZ   r[   r\   rk   rs    r(   r   re   re      s)    -;	"?r(   re   )rV   zSSLContext | None)rU   r   r1   r   rV   rW   )r\   
__future__r   loggingrD   r   	functoolsr   optparser   typingr   r   r   pip._internal.cli.base_commandr   !pip._internal.cli.command_contextr	   r   r
   pip._vendor.packaging.utilsr   rB   r   	getLoggerrY   r   r   r!   rc   re   ru   r(   r   <module>r      s    #  	 
      2 A:8			8	$  ,S- Sl/?!4 /?r(   