
    eH                        U d Z ddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlZddlZddlmZmZmZmZmZmZmZmZmZmZ ddlmZmZ ddlmZ  ddl!m"Z"m#Z# ddl!m$Z% ddl&m'Z'm(Z( dd	l)m*Z* dd
l+m,Z, ddl-m.Z. ddl/m0Z0 ddl1m2Z2 ddl3m4Z4 ddl5m6Z6 ddl7m8Z8 ddl9m:Z: ddl;m<Z< ddl=m>Z>m?Z? ddl@mAZA erddlBmCZC ddlDmEZE  ejF        eG          ZHeeIeIeeeJeIf                  f         ZK ejL        de.           g dZMeeK         eNd<   dZOdePfdZQdeIfdZR G d d e#          ZS G d! d"          ZT G d# d$eTe%          Z$ G d% d&eTe           Z G d' d(e$          ZU G d) d*e          ZV G d+ d,ejW                  ZXdS )-zhPipSession and supporting code, containing all pip-specific
network request configuration and behavior.
    N)
TYPE_CHECKINGAnyDict	GeneratorListMappingOptionalSequenceTupleUnion)requestsurllib3)CacheControlAdapter)DEFAULT_POOLBLOCKBaseAdapter)HTTPAdapter)PreparedRequestResponse)CaseInsensitiveDict)ConnectionPool)InsecureRequestWarning)__version__)get_default_environment)Link)MultiDomainBasicAuth)SafeFileCache)has_tls)libc_ver)build_url_from_netlocparse_netloc)url_to_path)
SSLContext)PoolManagerignore)category))https*r'   )r'   	localhostr'   )r'   z127.0.0.0/8r'   )r'   z::1/128r'   )filer'   N)sshr'   r'   SECURE_ORIGINS)BUILD_BUILDIDBUILD_IDCI	PIP_IS_CIreturnc                  >    t          d t          D                       S )z?
    Return whether it looks like pip is running under CI.
    c              3   2   K   | ]}|t           j        v V  d S N)osenviron).0names     T/var/www/html/api/venv/lib/python3.11/site-packages/pip/_internal/network/session.py	<genexpr>z looks_like_ci.<locals>.<genexpr>j   s)      GGdtrz!GGGGGG    )anyCI_ENVIRONMENT_VARIABLES r:   r8   looks_like_cir>   c   s"     GG.FGGGGGGr:   c            
      l   dt           dt          j                    dt          j                    id} | d         d         dk    rt          j                    | d         d<   n| d         d         dk    rJt          j        }|j        d	k    r
|d
d         }d                    d |D                       | d         d<   n]| d         d         dk    rt          j                    | d         d<   n.| d         d         dk    rt          j                    | d         d<   t          j                            d          rddl	m
} |                                |                                |                                f}t          t          d t!          g d|                              }t          t          d t!          ddgt#                                                    }|r||d<   |r|| d<   t          j                            d          r8t          j                    d         rdt          j                    d         d| d<   t          j                    r*t          j                    |                     di           d<   t          j                    r*t          j                    |                     di           d<   t          j                    rt          j                    | d<   t/                      rdd
l}|j        | d<   t5                                          d          }|t9          |j                  | d <   t;          j        d!          z	 t?          j         d!d"gt>          j!        d#$          }|                    d%          r0|"                    d&          d'         #                                | d(<   n# tH          $ r Y nw xY wtK                      rd)nd
| d*<   tL          j'        (                    d+          }	|	|	| d,<   d-)                    | tU          j+        | d.d)/          0          S )1z6
    Return a string representing the user agent.
    pip)r7   versionr7   )	installerpythonimplementationrD   CPythonrA   PyPyfinalN   .c                 ,    g | ]}t          |          S r=   )str)r6   xs     r8   
<listcomp>zuser_agent.<locals>.<listcomp>   s    ///SVV///r:   Jython
IronPythonlinuxr   )distroc                     | d         S N   r=   rL   s    r8   <lambda>zuser_agent.<locals>.<lambda>   
    !A$ r:   )r7   rA   idc                     | d         S rS   r=   rU   s    r8   rV   zuser_agent.<locals>.<lambda>   rW   r:   liblibcrQ   darwinmacOSsystemreleasecpuopenssl_version
setuptoolssetuptools_versionrustcz	--versiong      ?)stderrtimeouts   rustc     rT   rustc_versionTciPIP_USER_AGENT_USER_DATA	user_dataz9{data[installer][name]}/{data[installer][version]} {json}),:)
separators	sort_keys)datajson),r   platformpython_versionpython_implementationsyspypy_version_inforeleaseleveljoin
startswithpip._vendorrQ   r7   rA   codenamedictfilterzipr   mac_verr^   
setdefaultr_   machiner   _sslOPENSSL_VERSIONr   get_distributionrK   shutilwhich
subprocesscheck_outputSTDOUTsplitdecode	Exceptionr>   r4   r5   getformatrq   dumps)
rp   rv   rQ   linux_distributiondistro_infosr[   sslsetuptools_distrustc_outputrk   s
             r8   
user_agentr   m   sk   
 $<<)++H244
 D f%22,4,C,E,Ey))			'6	1	11)W44 1"1" 5,/HH//.///-
 -
y)) 
		'8	3	3,4,C,E,Ey))			'<	7	7,4,C,E,Ey)
|w'' *&&&&&&#[[]]FNN,<,<foo>O>OO'+---/ABB (
 (
 UI&

33 
 
  	(#'L  	*)DN
|x(( MX-=-?-?-B M")h6F6H6H6KLLX B080A0A"%%f- F3;3C3E3E"%%i0 )&((Uyy 6"%"5-//@@NNO"%()@%A%A!"|G(	M%2+&z/@#  L &&y11 M )5(:(:4(@(@(C(J(J(L(L_%  	 	 	D	 '2dDJ
9::I%[FMMZtDDD N   s   #N? ?
OOc                       e Zd Z	 	 	 	 	 ddededeeeeeef         f                  deee	f         deee	ee	e	f         f                  d	ee
e	e	f                  d
efdZddZdS )LocalFSAdapterFNTrequeststreamrf   verifycertproxiesr0   c                    t          |j                  }t                      }d|_        |j        |_        	 t	          j        |          }	t          j                            |	j	        d          }
t          j        |          d         pd}t          ||	j        |
d          |_        t          |d          |_        |j        j        |_        nm# t$          $ r`}d|_        t'          |          j        |_        t-          j        |j         d	|                     d
                    |_        Y d }~nd }~ww xY w|S )N   T)usegmtr   z
text/plain)zContent-TypezContent-LengthzLast-Modifiedrbi  z: utf8)r!   urlr   status_coder4   statemailutils
formatdatest_mtime	mimetypes
guess_typer   st_sizeheadersopenrawcloseOSErrortype__name__reasonioBytesIOencode)selfr   r   rf   r   r   r   pathnamerespstatsmodifiedcontent_typeexcs                r8   sendzLocalFSAdapter.send   s>    w{++zz;	(GH%%E {--enT-JJH$/99!<LL.$0&+m%-  DL Hd++DHDJJ%  	J 	J 	J  #Ds)),DKzT["9"9C"9"9"@"@"H"HIIDHHHHHH	J( s   C 
D;AD66D;c                     d S r3   r=   )r   s    r8   r   zLocalFSAdapter.close   s    r:   )FNTNN)r0   N)r   
__module____qualname__r   boolr	   r   floatr   rK   r   r   r   r   r=   r:   r8   r   r      s         ?C#'6:/3% % % % %uUE\': :;<	%
 dCi % uS%S/123% '#s(+,% 
% % % %N     r:   r   c                   f     e Zd ZdZddded         deddf fdZefd	ed
ede	deddf
 fdZ
 xZS )_SSLContextAdapterMixina#  Mixin to add the ``ssl_context`` constructor argument to HTTP adapters.

    The additional argument is forwarded directly to the pool manager. This allows us
    to dynamically decide what SSL store to use at runtime, which is used to implement
    the optional ``truststore`` backend.
    N)ssl_contextr   r"   kwargsr0   c                H    || _          t                      j        di | d S )Nr=   )_ssl_contextsuper__init__)r   r   r   	__class__s      r8   r   z _SSLContextAdapterMixin.__init__  s0     (""6"""""r:   connectionsmaxsizeblockpool_kwargsr#   c                     | j         |                    d| j                     t                      j        d|||d|S )Nr   )r   r   r   r=   )r   r   r   init_poolmanager)r   r   r   r   r   r   s        r8   r   z(_SSLContextAdapterMixin.init_poolmanager  s_     (""=$2CDDD'uww' 
#
 
 	
 
 	
r:   )r   r   r   __doc__r	   r   r   r   intr   r   __classcell__r   s   @r8   r   r      s          /3# # # l+# 	#
 
# # # # # # (	
 

 
 	

 
 

 
 
 
 
 
 
 
 
 
r:   r   c                       e Zd ZdS )r   Nr   r   r   r=   r:   r8   r   r              Dr:   r   c                       e Zd ZdS )r   Nr   r=   r:   r8   r   r   $  r   r:   r   c                   p     e Zd Zdededeeef         deeeeeef         f                  ddf
 fdZ	 xZ
S )InsecureHTTPAdapterconnr   r   r   r0   Nc                 R    t                                          ||d|           d S NF)r   r   r   r   r   cert_verifyr   r   r   r   r   r   s        r8   r   zInsecureHTTPAdapter.cert_verify)  ,     	3u4HHHHHr:   r   r   r   r   rK   r   r   r	   r   r   r   r   s   @r8   r   r   (          II I dCi 	I
 uS%S/123I 
I I I I I I I I I Ir:   r   c                   p     e Zd Zdededeeef         deeeeeef         f                  ddf
 fdZ	 xZ
S )InsecureCacheControlAdapterr   r   r   r   r0   Nc                 R    t                                          ||d|           d S r   r   r   s        r8   r   z'InsecureCacheControlAdapter.cert_verify4  r   r:   r   r   s   @r8   r   r   3  r   r:   r   c                   8    e Zd ZU dZee         ed<   dddddddededee         d	e	e         d
ee
e                  ded         deddf fdZde
e         ddfdZ	 ddedee         deddfdZdeeddf         fdZdedefdZdededededef
 fdZ xZS )
PipSessionNrf   r   r=   )retriescachetrusted_hosts
index_urlsr   argsr   r   r   r   r   r"   r   r0   c                ~    t                      j        |i | g | _        t                      | j        d<   t          |          | _        t          j        |g dd          }t          |          }|rCt          t          |          ||          }	t          t          |          |          | _        nt          ||	          }	|| _        |                     d
|	           |                     d|           |                     dt!                                 |D ]}
|                     |
d           dS )zj
        :param trusted_hosts: Domains not to emit warnings for when not using
            HTTPS.
        z
User-Agent)r   )i  i  i  i  g      ?)totalstatus_forcelistbackoff_factor)max_retries)r   r   r   )r   r   )r   r   zhttps://zhttp://zfile://T)suppress_loggingN)r   r   pip_trusted_originsr   r   r   authr   Retryr   r   r   r   _trusted_host_adapterr   mountr   add_trusted_host)r   r   r   r   r   r   r   r   insecure_adaptersecure_adapterhostr   s              r8   r   zPipSession.__init__B  s    	$)&))) EG  &0\\\" )J???	 -  211  
 
 
* /7CCC  	:0#E**#'  N
 *E#E**#* * *D&&
 )W+VVVN)9D&

:~...

9./// 	

9n..///! 	? 	?D!!$!>>>>	? 	?r:   new_index_urlsc                     || j         _        dS )zn
        :param new_index_urls: New index urls to update the authentication
            handler with.
        N)r   r   )r   r   s     r8   update_index_urlszPipSession.update_index_urls  s    
  .	r:   Fr   sourcer   c                 6   |s*d|}|	|d| dz  }t                               |           t          |          }|| j        vr| j                            |           |                     t          |d          dz   | j                   |                     t          |          dz   | j                   |d         sZ|                     t          |d          d	z   | j                   |                     t          |          d	z   | j                   dS dS )
z
        :param host: It is okay to provide a host that has previously been
            added.
        :param source: An optional source string, for logging where the host
            string came from.
        zadding trusted host: Nz (from )http)scheme/rT   rm   )loggerinfor    r   appendr   r   r   )r   r   r  r   msg	host_ports         r8   r   zPipSession.add_trusted_host  sG      	2$22C!*****KK &&	D444$++I666

!$v666<d>X	
 	
 	
 	

(..4d6PQQQ| 	VJJ%d6:::S@*  
 JJ,T22S8$:TUUUUU	V 	Vr:   c              #   T   K   t           E d {V  | j        D ]\  }}d||dn|fV  d S )Nr'   )r+   r   )r   r   ports      r8   iter_secure_originszPipSession.iter_secure_origins  s\      !!!!!!!!2 	= 	=JD$T\cct<<<<<	= 	=r:   locationc                 X   t           j                            t          |                    }|j        |j        |j        }}}|                    dd          d         }|                                 D ]}|\  }}}	||k    r|dk    r	 t          j
        |pd          }
t          j        |          }|
|vrEnD# t          $ r7 |r2|                                |                                k    r|dk    rY Y nw xY w||	k    r	|	dk    r|	 dS t                              d||           dS )	N+rT   r'    TzThe repository located at %s is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host %s'.F)urllibparseurlparserK   r  hostnamer  rsplitr  	ipaddress
ip_address
ip_network
ValueErrorlowerr  warning)r   r  parsedorigin_protocolorigin_hostorigin_portsecure_originsecure_protocolsecure_hostsecure_portaddrnetworks               r8   is_secure_originzPipSession.is_secure_origin  s   &&s8}}55MOK '2 *00a88<
 "5577 !	 !	M8E5O[+/11o6L6L +K,=2>>#.{;; w&& '      #))++{/@/@/B/BBB#s**H" {**3&&+ 44
 	I 	
 	
 	
 us   *B88<C98C9methodr   c                     |                     d| j                   |                     d| j                    t                      j        ||g|R i |S )Nrf   r   )r   rf   r   r   r   )r   r+  r   r   r   r   s        r8   r   zPipSession.request  s]    )T\222)T\222 uwwvs<T<<<V<<<r:   )NF)r   r   r   rf   r	   r   __annotations__r   rK   r
   r   r   r  r   r   r   SecureOriginr  r   r*  r   r   r   r   s   @r8   r   r   >  s        !GXc]!!!
 #')*..2M? M? M?M? M? }	M?
  }M? T#Y'M? l+M? M? 
M? M? M? M? M? M?^.S	 .d . . . . QVV VV!)#VIMV	V V V V>=Y|T4/G%H = = = =
A A$ A A A AF=c = =C =3 =8 = = = = = = = = = =r:   r   )Yr   email.utilsr   r   r  rq   loggingr   r4   rr   r   r   ru   urllib.parser  warningstypingr   r   r   r   r   r   r	   r
   r   r   rz   r   r   pip._vendor.cachecontrolr   _BaseCacheControlAdapterpip._vendor.requests.adaptersr   r   r   _BaseHTTPAdapterpip._vendor.requests.modelsr   r   pip._vendor.requests.structuresr   "pip._vendor.urllib3.connectionpoolr   pip._vendor.urllib3.exceptionsr   r@   r   pip._internal.metadatar   pip._internal.models.linkr   pip._internal.network.authr   pip._internal.network.cacher   pip._internal.utils.compatr   pip._internal.utils.glibcr   pip._internal.utils.miscr   r    pip._internal.utils.urlsr!   r   r"   pip._vendor.urllib3.poolmanagerr#   	getLoggerr   r  rK   r   r.  filterwarningsr+   r-  r<   r   r>   r   r   r   r   r   Sessionr   r=   r:   r8   <module>rH     s         				           				       



                             * ) ) ) ) ) ) ) T T T T T T H H H H H H H H I I I I I I A A A A A A A A ? ? ? ? ? ? = = = = = = A A A A A A       : : : : : : * * * * * * ; ; ; ; ; ; 5 5 5 5 5 5 / . . . . . . . . . . . H H H H H H H H 0 0 0 0 0 0 <;;;;;; 
	8	$	$S#xc3h889  +A B B B B
& 
& 
&\" 
 
 
(	 Ht H H H HbC b b b bJ) ) ) ) )[ ) ) )X
 
 
 
 
 
 
 
D	 	 	 	 	)+; 	 	 		 	 	 	 	13K 	 	 	I I I I I+ I I II I I I I"5 I I IH= H= H= H= H=! H= H= H= H= H=r:   