
     hSI                     R   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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l0m1Z1 ddl2m3Z3 ddl4m5Z5 ddl6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= ddl>m?Z?m@Z@ ddlAmBZB erddlCmDZD ddlEmFZF  ejG        eH          ZIeeJeJeeeKeJf                  f         ZL ejM        de/           g dZNeeL         eOd<   dZPdeQfdZR ejS        d          deJfd             ZT G d! d"e$          ZU G d# d$          ZV G d% d&eVe&          Z% G d' d(eVe!          Z  G d) d*e%          ZW G d+ d,e           ZX G d- d.ejY                  ZZd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     \/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/pip/_internal/network/session.py	<genexpr>z looks_like_ci.<locals>.<genexpr>k   s)      GGdtrz!GGGGGG    )anyCI_ENVIRONMENT_VARIABLES r:   r8   looks_like_cir>   d   s"     GG.FGGGGGGr:      )maxsizec            
      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implementationrF   CPythonrC   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 Nr?   r=   rN   s    r8   <lambda>zuser_agent.<locals>.<lambda>   
    !A$ r:   )r7   rC   idc                     | d         S rU   r=   rV   s    r8   rW   zuser_agent.<locals>.<lambda>   rX   r:   liblibcrS   darwinmacOSsystemreleasecpuopenssl_version
setuptoolssetuptools_versionrustcz	--versiong      ?)stderrtimeouts   rustc     r?   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._vendorrS   r7   rC   codenamedictfilterzipr   mac_verr_   
setdefaultr`   machiner   _sslOPENSSL_VERSIONr   get_distributionrM   shutilwhich
subprocesscheck_outputSTDOUTsplitdecode	Exceptionr>   r4   r5   getformatrr   dumps)
rq   rw   rS   linux_distributiondistro_infosr\   sslsetuptools_distrustc_outputrl   s
             r8   
user_agentr   n   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streamrg   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        |_        nl# t$          $ r_}d|_        t'          |          j        |_        t-          j        |j         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: )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   rg   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%  	D 	D 	D  #Ds)),DKzT["9"9C"9"9"@"@"B"BCCDHHHHHH	D( s   C 
D:AD55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   rM   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:   connectionsr@   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   rM   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_verify6  r   r:   r   r   s   @r8   r   r   5  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 )
PipSessionNrg   r   r=   )retriescachetrusted_hosts
index_urlsr   argsr   r   r   r   r   r"   r   r0   c                    t                      j        |i | g | _        d| _        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.
        Nz
User-Agent)r   )i  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_logging)r   r   pip_trusted_origins	pip_proxyr   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__C  s    	$)&))) EG  &0\\\" )J???	 -  766  
 
 
, /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                 `   |s*d|}|	|d| dz  }t                               |           t          |          \  }}|t          d|          ||f| j        vr| j                            ||f           |                     t          |d          dz   | j                   |                     t          |          dz   | j                   |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 )z+Trusted host URL must include a host part: http)scheme/rn   )	loggerinfor    
ValueErrorr   appendr   r   r   )r   r   r  r   msgparsed_hostparsed_ports          r8   r   zPipSession.add_trusted_host  so      	2$22C!*****KK#/#5#5 [S4SSTTT%T-EEE$++[+,FGGG

!$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+r?   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urlparserM   r  hostnamer  rsplitr  	ipaddress
ip_address
ip_networkr
  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 )Nrg   r   )r   rg   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   rg   r	   r   __annotations__r   rM   r
   r   r   r  r   r   r   SecureOriginr  r   r+  r   r   r   r   s   @r8   r   r   @  s        !GXc]!!!
 #')*..2O? O? O?O? O? }	O?
  }O? T#Y'O? l+O? O? 
O? O? O? O? O? O?b.S	 .d . . . . QVV VV!)#VIMV	V V V VB=Y|T4/G%H = = = =
A A$ A A A AF=c = =C =3 =8 = = = = = = = = = =r:   r   )[r   email.utilsr   	functoolsr   r  rr   loggingr   r4   rs   r   r   rv   urllib.parser  warningstypingr   r   r   r   r   r   r	   r
   r   r   r{   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   rB   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  rM   r   r/  filterwarningsr+   r.  r<   r   r>   	lru_cacher   r   r   r   r   Sessionr   r=   r:   r8   <module>rK     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 Q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K= K= K= K= K=! K= K= K= K= K=r:   