3 Reh;@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z m Z ddlmZddlmZmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd l m!Z!dd l"m#Z#m$Z$ddl%m&Z&ddl'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.e,rXddl/m0Z0m1Z1m2Z2m3Z3m4Z4ddl5m6Z6e3e7e7e2e4e8e7ffZ9ej:e;Zd3Z?d!d"Z@d#d$ZAGd%d&d&eZBGd'd(d(eZCGd)d*d*eZDGd+d,d,e jEZFdS)4zhPipSession and supporting code, containing all pip-specific network request configuration and behavior. N)requestssixurllib3)CacheControlAdapter) BaseAdapter HTTPAdapter)Response)CaseInsensitiveDict)parse)InsecureRequestWarning) __version__)MultiDomainBasicAuth) SafeFileCache)has_tls ipaddress)libc_ver)build_url_from_netlocget_installed_version parse_netloc)MYPY_CHECK_RUNNING) url_to_path)IteratorListOptionalTupleUnion)Linkignore)categoryhttps* localhost 127.0.0.0/8::1/128filessh BUILD_BUILDIDBUILD_IDCI PIP_IS_CIcCstddtDS)z? Return whether it looks like pip is running under CI. css|]}|tjkVqdS)N)osenviron).0namer./builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el9.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/network/session.py `sz looks_like_ci..)anyCI_ENVIRONMENT_VARIABLESr.r.r.r/ looks_like_ciXsr3cCsLdtdtjdtjid}|dddkr@tj|dd<n|dddkrtjjd krltjd d }ntj}d jd d|D|dd<nB|dddkrtj|dd<n |dddkrtj|dd<tjjdrHddl m }t t ddt dddg|j}t t ddt ddgt}|r:||d<|rH||d<tjjdrztjdrzdtjdd|d<tjrtj|jdid<tjrtj|jdid<tjrtj|d<trdd l}|j|d <td!}|d k r||d"<tr d#nd |d$<tjjd%}|d k r2||d&<d'j|tj|d,d#d*d+S)-z6 Return a string representing the user agent. pip)r-versionr-) installerpythonimplementationr8CPythonr5PyPyfinalN.cSsg|] }t|qSr.)str)r,xr.r.r/ wszuser_agent..Jython IronPythonlinuxr)distrocSs|dS)Nr.)r?r.r.r/szuser_agent..idcSs|dS)NrEr.)r?r.r.r/rFsliblibcrDdarwinmacOSsystemreleasecpuopenssl_version setuptoolssetuptools_versionTciPIP_USER_AGENT_USER_DATA user_dataz9{data[installer][name]}/{data[installer][version]} {json},:) separators sort_keys)datajson)rUrV) r platformpython_versionpython_implementationsyspypy_version_info releaseleveljoin startswith pip._vendorrDdictfilterziplinux_distributionrmac_verrL setdefaultrMmachiner_sslOPENSSL_VERSIONrr3r*r+getformatrZdumps)rYr_rD distro_infosrIsslrQrTr.r.r/ user_agentcs`          rrc@seZdZdddZddZdS)LocalFSAdapterNc Cst|j}t}d|_|j|_ytj|} Wn.tk rZ} zd|_| |_WYdd} ~ XnPXtj j | j dd} t j |dp~d} t| | j| d|_t|d|_|jj|_|S) NiT)usegmtrz text/plain)z Content-TypezContent-Lengthz Last-Modifiedrb)rurlr status_coder*statOSErrorrawemailutils formatdatest_mtime mimetypes guess_typer st_sizeheadersopenclose) selfrequeststreamtimeoutverifycertproxiespathnamerespstatsexcmodified content_typer.r.r/sends$    zLocalFSAdapter.sendcCsdS)Nr.)rr.r.r/rszLocalFSAdapter.close)NNNNN)__name__ __module__ __qualname__rrr.r.r.r/rss rscseZdZfddZZS)InsecureHTTPAdaptercstt|j||d|ddS)NF)connrwrr)superr cert_verify)rrrwrr) __class__r.r/rs zInsecureHTTPAdapter.cert_verify)rrrr __classcell__r.r.)rr/rsrcseZdZfddZZS)InsecureCacheControlAdaptercstt|j||d|ddS)NF)rrwrr)rrr)rrrwrr)rr.r/rs z'InsecureCacheControlAdapter.cert_verify)rrrrrr.r.)rr/rsrcsFeZdZdZfddZd ddZddZd d Zfd d ZZ S) PipSessionNc s|jdd}|jdd}|jdg}|jdd}tt|j||g|_t|jd<t|d|_t j |d d d d gd d}t |d}|rt t ||d}tt ||d|_nt|d}||_|jd||jd||jdtx|D]} |j| ddqWdS)zj :param trusted_hosts: Domains not to emit warnings for when not using HTTPS. retriesrcacheN trusted_hosts index_urlsz User-Agent)riiiig?)totalstatus_forcelistbackoff_factor) max_retries)rrzhttps://zhttp://zfile://T)suppress_logging)poprr__init__pip_trusted_originsrrrr authrRetryrrrr_trusted_host_adapterrmountrsadd_trusted_host) rargskwargsrrrrinsecure_adaptersecure_adapterhost)rr.r/rs6             zPipSession.__init__FcCs|s.dj|}|dk r$|dj|7}tj|t|}||jkrL|jj||jt|d|j|ds|jt|d|jdS)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: {!r}Nz (from {})/rErV) rnloggerinforrappendrrr)rrsourcermsg host_portr.r.r/r4s      zPipSession.add_trusted_hostccsDxtD] }|VqWx*|jD] \}}d||dkr4dn|fVqWdS)Nr )SECURE_ORIGINSr)r secure_originrportr.r.r/iter_secure_originsQs  zPipSession.iter_secure_originsc Cstjt|}|j|j|j}}}|jddd}x|jD]}|\}}} ||kr^|dkr^q>y0tj |dkrpdnt j |} tj t j |} Wn2t k r|r|j|jkr|dkrw>Yn X| | krq>|| kr| dkr| dk rq>dSWtjd||dS)N+rEr 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_parseurlparser>schemehostnamerrsplitrr ip_addressr ensure_text ip_network ValueErrorlowerrwarning) rlocationparsedorigin_protocol origin_host origin_portrsecure_protocol secure_host secure_portaddrnetworkr.r.r/is_secure_originXs<   zPipSession.is_secure_origincs(|jd|jtt|j||f||S)Nr)rirrrr)rmethodrwrr)rr.r/rszPipSession.request)NF) rrrrrrrrrrr.r.)rr/rs  L Hr)rr r )r r!r )r r"r )r r#r )r$r N)r%r r )r&r'r(r))G__doc__ email.utilsr|rZloggingrr*r[r^warningsrcrrrZpip._vendor.cachecontrolrZpip._vendor.requests.adaptersrrZpip._vendor.requests.modelsrZpip._vendor.requests.structuresr Zpip._vendor.six.moves.urllibr rZpip._vendor.urllib3.exceptionsr r4r pip._internal.network.authr pip._internal.network.cacherpip._internal.utils.compatrrpip._internal.utils.glibcrpip._internal.utils.miscrrrpip._internal.utils.typingrpip._internal.utils.urlsrtypingrrrrrpip._internal.models.linkrr>intZ SecureOrigin getLoggerrrfilterwarningsrr2r3rrrsrrSessionrr.r.r.r/sZ               P!