o 7]hYA@sUdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl ZddlZddlmZmZmZmZmZmZmZmZmZddlmZmZddlmZddlm Z m!Z!ddl"m#Z#m$Z$ddl%m&Z&dd l'm(Z(dd l)m*Z*dd l+m,Z,dd l-m.Z.dd l/m0Z0ddl1m2Z2ddl3m4Z4ddl5m6Z6ddl7m8Z8ddl9m:Z:m;Z;ddle?Z@eeAeAeeeBeAffZCejDde*dgdZEeeCeFd<dZGdeHfddZIdeAfddZJGddde ZKGd d!d!e!ZLGd"d#d#eZMGd$d%d%ejNZOdS)&zhPipSession and supporting code, containing all pip-specific network request configuration and behavior. N) AnyDictIteratorListMappingOptionalSequenceTupleUnion)requestsurllib3)CacheControlAdapter) BaseAdapter HTTPAdapter)PreparedRequestResponse)CaseInsensitiveDict)ConnectionPool)InsecureRequestWarning) __version__)get_default_environment)Link)MultiDomainBasicAuth) SafeFileCache)has_tls)libc_ver)build_url_from_netloc parse_netloc) url_to_pathignore)category))https*r")r" localhostr")r"z 127.0.0.0/8r")r"z::1/128r")filer"N)sshr"r"SECURE_ORIGINS) BUILD_BUILDIDBUILD_IDCI PIP_IS_CIreturncCstddtDS)z? Return whether it looks like pip is running under CI. css|]}|tjvVqdSN)osenviron).0namer1?/usr/lib/python3/dist-packages/pip/_internal/network/session.py Xsz looks_like_ci..)anyCI_ENVIRONMENT_VARIABLESr1r1r1r2 looks_like_ciQsr6c Csdtdtdtid}|dddkr t|dd<nF|dddkrEtj}|jd kr6|d d }d d d|D|dd<n!|dddkrVt|dd<n|dddkrft|dd<tjdrddl m }| | | f}ttddtgd|}ttddtddgt}|r||d<|r||d<tjdrtdrdtdd|d<trt|did<trt|did<trt|d<trdd l}|j|d <td!}|d urt|j |d"<td#d ur2z tj d#d$gtj!d%d&}Wn t"y Ynw|d'r2|#d(d)$|d*<t%r8d+nd |d,<t&j'(d-} | d urK| |d.<d/j)|t*j+|d0d+d1d2S)3z6 Return a string representing the user agent. pip)r0versionr0) installerpythonimplementationr;CPythonr8PyPyfinalN.cSsg|]}t|qSr1)str)r/xr1r1r2 nszuser_agent..Jython IronPythonlinuxr)distrocS|dSNr1rBr1r1r2}zuser_agent..)r0r8idcSrHrIr1rKr1r1r2rLrMliblibcrGdarwinmacOSsystemreleasecpuopenssl_version setuptoolssetuptools_versionrustcz --versiong?)stderrtimeoutsrustc  rJ rustc_versionTciPIP_USER_AGENT_USER_DATA user_dataz9{data[installer][name]}/{data[installer][version]} {json}),:) separators sort_keys)datajson),rplatformpython_versionpython_implementationsyspypy_version_info releaseleveljoin startswith pip._vendorrGr0r8codenamedictfilterziprmac_verrS setdefaultrTmachiner_sslOPENSSL_VERSIONrget_distributionrAshutilwhich subprocess check_outputSTDOUT Exceptionsplitdecoder6r-r.getformatrfdumps) rerkrGlinux_distribution distro_infosrPsslsetuptools_dist rustc_outputr`r1r1r2 user_agent[s               rc@seZdZ     ddededeeeeeeffdeee fdeee ee e ffd ee e e fd e fd d Z dd dZ dS)LocalFSAdapterFNTrequeststreamr[verifycertproxiesr+c Cst|j}t}d|_|j|_zt|} Wn+tyA} zd|_t| j|_ t |j d|  d|_ WYd} ~ |Sd} ~ wwtjj| jdd} t|dpSd} t| | j| d |_t|d |_ |j j|_|S) Niz: utf8T)usegmtrz text/plain)z Content-TypezContent-Lengthz Last-Modifiedrb)rurlr status_coder-statOSErrortype__name__reasonioBytesIOencoderawemailutils formatdatest_mtime mimetypes guess_typerst_sizeheadersopenclose) selfrrr[rrrpathnamerespstatsexcmodified content_typer1r1r2sends0  (  zLocalFSAdapter.sendcCsdSr,r1)rr1r1r2rszLocalFSAdapter.close)FNTNN)r+N)r __module__ __qualname__rboolrr floatr rArrrrr1r1r1r2rs,  'rc NeZdZdededeeefdeeeeeeffddf fdd Z Z S) InsecureHTTPAdapterconnrrrr+Nctj||d|ddSNF)rrrrsuper cert_verifyrrrrr __class__r1r2rzInsecureHTTPAdapter.cert_verify rrrrrAr rrr r __classcell__r1r1rr2r rc r) InsecureCacheControlAdapterrrrrr+Ncrrrrrr1r2rrz'InsecureCacheControlAdapter.cert_verifyrr1r1rr2rrrcseZdZUdZeeed<ddddddededeed e ed ee ed ed dffd dZ de ed dfddZ d!dedeede d dfddZd eefddZded e fddZdededed ed ef fdd ZZS)" PipSessionNr[rr1)retriescache trusted_hosts index_urlsargsrrrrkwargsr+c stj|i|g|_t|jd<t|d|_tj|gddd}t |d}|r;t t ||d}t t ||d|_ nt|d}||_ |d||d ||d t|D] } |j| d d qXd S)zj :param trusted_hosts: Domains not to emit warnings for when not using HTTPS. z User-Agent)r)iiiig?)totalstatus_forcelistbackoff_factor) max_retries)rrzhttps://zhttp://zfile://T)suppress_loggingN)r__init__pip_trusted_originsrrrauthr Retryrr rr_trusted_host_adapterrmountradd_trusted_host) rrrrrrrinsecure_adaptersecure_adapterhostrr1r2rs6       zPipSession.__init__new_index_urlscCs ||j_dS)zn :param new_index_urls: New index urls to update the authentication handler with. N)rr)rrr1r1r2update_index_urlsSs zPipSession.update_index_urlsFrsourcercCs|sd|}|dur|d|d7}t|t|}||jvr'|j||t|ddd|j|t|d|j|ds]|t|ddd |j|t|d |jdSdS) 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. zadding trusted host: Nz (from )http)scheme/rJrb)loggerinforrappendrrr)rrrrmsg host_portr1r1r2rZs&    zPipSession.add_trusted_hostccs8tEdH|jD]\}}d||durdn|fVq dS)Nr")r&r)rrportr1r1r2iter_secure_originsys  zPipSession.iter_secure_originslocationc Cstjt|}|j|j|j}}}|ddd}|D]J}|\}}} ||kr/|dkr/qz t |} t |} Wnt yT|rR| | krR|dkrRYqYnw| | vrZq|| krg| dkrg| durgqdStd||dS)N+rJr"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)urllibparseurlparserArhostnamerrsplitr ipaddress ip_address ip_network ValueErrorlowerrwarning) rrparsedorigin_protocol origin_host origin_port secure_originsecure_protocol secure_host secure_portaddrnetworkr1r1r2is_secure_origin~sD       zPipSession.is_secure_originmethodrcs*|d|jtj||g|Ri|S)Nr[)rur[rr)rrrrrrr1r2rszPipSession.request)NF)rrrr[rint__annotations__rrArrrrrrr SecureOriginrrrrrrr1r1rr2rsF  M *Cr)P__doc__ email.utilsrrrrfloggingrr-rgrzr|rj urllib.parserwarningstypingrrrrrrrr r ror r pip._vendor.cachecontrolr pip._vendor.requests.adaptersrrpip._vendor.requests.modelsrrpip._vendor.requests.structuresr"pip._vendor.urllib3.connectionpoolrpip._vendor.urllib3.exceptionsrr7rpip._internal.metadatarpip._internal.models.linkrpip._internal.network.authrpip._internal.network.cacherpip._internal.utils.compatrpip._internal.utils.glibcrpip._internal.utils.miscrrpip._internal.utils.urlsr getLoggerrrrArrfilterwarningsr&rr5rr6rrrrSessionrr1r1r1r2sT,               e,