U .e=@sdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z m Z m Z ddlmZddlmZmZddlmZddlmZddlmZdd lmZdd lmZdd lmZdd l m!Z!dd l"m#Z#m$Z$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+m,Z,m-Z-ddl.m/Z/ddl0m1Z1e/rhddl2m3Z3m4Z4m5Z5m6Z6m7Z7ddl8m9Z9e6e:e:e5e7e;e:ffZZ?e j@dedddddddgZAdZBddZCd d!ZDGd"d#d#eZEGd$d%d%eZFGd&d'd'e jGZHdS)(zhPipSession 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 ipaddressssl)check_path_owner)libc_ver)build_url_from_netlocget_installed_version parse_netloc)MYPY_CHECK_RUNNING) url_to_path)IteratorListOptionalTupleUnion)Linkignore)category)Zhttps*r!)r!Z localhostr!)r!z 127.0.0.0/8r!)r!z::1/128r!)filer!N)Zsshr!r!)Z BUILD_BUILDIDZBUILD_IDZCIZ PIP_IS_CIcCstddtDS)z? Return whether it looks like pip is running under CI. css|]}|tjkVqdSN)osenviron).0namer(A/usr/lib/python3.8/site-packages/pip/_internal/network/session.py asz looks_like_ci..)anyCI_ENVIRONMENT_VARIABLESr(r(r(r) looks_like_ciYsr-cCsBdtdtdtid}|dddkr@t|dd<n|dddkrtjjd krltjd d }ntj}d d d|D|dd<nB|dddkrt|dd<n |dddkrt|dd<tjdrHddl m }t t ddt dddg|}t t ddt ddgt}|r:||d<|rH||d<tjdrztdrzdtdd|d<trt|did<trt|did<trt|d<trtj|d <td!}|d k r||d"<trd#nd |d$<tjd%}|d k r(||d&<d'j|tj|d(d#d)d*S)+z6 Return a string representing the user agent. pip)r'versionr')Z installerpythonimplementationr1ZCPythonr/ZPyPyfinalN.cSsg|] }t|qSr()str)r&xr(r(r) xszuser_agent..ZJythonZ IronPythonZlinuxr)distrocSs|dSNr(r6r(r(r)zuser_agent..idcSs|dSr9r(r;r(r(r)r<r=liblibcr8darwinZmacOSsystemreleaseZcpuZopenssl_versionZ setuptoolssetuptools_versionTZciZPIP_USER_AGENT_USER_DATA user_dataz9{data[installer][name]}/{data[installer][version]} {json}),:)Z separatorsZ sort_keys)datajson) r platformZpython_versionZpython_implementationsyspypy_version_info releaseleveljoin startswith pip._vendorr8dictfilterzipZlinux_distributionrZmac_verrB setdefaultrCmachinerrZOPENSSL_VERSIONrr-r$r%getformatrIdumps)rHrLr8Z distro_infosr@rDrEr(r(r) user_agentdsl           rYc@seZdZdddZddZdS)LocalFSAdapterNc Cst|j}t}d|_|j|_zt|} Wn.tk rZ} zd|_| |_W5d} ~ XYnPXtj j | j dd} t |dp~d} t| | j| d|_t|d|_|jj|_|S) NiT)Zusegmtrz text/plain)z Content-TypezContent-Lengthz Last-Modifiedrb)rurlrZ status_coder$statOSErrorrawemailZutilsZ formatdatest_mtime mimetypesZ guess_typer st_sizeheadersopenclose) selfrequeststreamtimeoutverifycertZproxiespathnameZrespZstatsexcZmodifiedZ content_typer(r(r)sends&    zLocalFSAdapter.sendcCsdSr#r()rhr(r(r)rgszLocalFSAdapter.close)NNNNN)__name__ __module__ __qualname__rprgr(r(r(r)rZs rZc@seZdZddZdS)InsecureHTTPAdaptercCsd|_d|_dS)NZ CERT_NONE)Z cert_reqsZca_certs)rhZconnr]rlrmr(r(r) cert_verifyszInsecureHTTPAdapter.cert_verifyN)rqrrrsrur(r(r(r)rtsrtcsFeZdZdZfddZd ddZddZd d Zfd d ZZ S) PipSessionNc s|dd}|dd}|dg}|dd}tt|j||g|_t|jd<t|d|_t j |d d d d gd d}|rt |st d|d}|rtt||d}n t|d}t|d}||_|d||d||dt|D]} |j| ddqdS)zj :param trusted_hosts: Domains not to emit warnings for when not using HTTPS. retriesrcacheN trusted_hosts index_urlsz User-Agent)rziiiig?)ZtotalZstatus_forcelistZbackoff_factorzThe directory '%s' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.)rx max_retries)r{zhttps://zhttp://zfile://T)suppress_logging)popsuperrv__init__pip_trusted_originsrYrer ZauthrZRetryrloggerwarningrrrrt_insecure_adaptermountrZadd_trusted_host) rhargskwargsrwrxryrzZsecure_adapterZinsecure_adapterhost __class__r(r)rs@            zPipSession.__init__FcCs|s.d|}|dk r$|d|7}t|t|}||jkrL|j||t|d|j|ds|t|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 {})/r:rG) rWrinforrappendrrr)rhrsourcer|msgZ host_portr(r(r)r3s     zPipSession.add_trusted_hostccs<tD] }|Vq|jD] \}}d||dkr.dn|fVqdS)Nr!)SECURE_ORIGINSr)rh secure_originrportr(r(r)iter_secure_originsMszPipSession.iter_secure_originsc Cs tt|}|j|j|j}}}|ddd}|D]}|\}}} ||kr\|dkr\qsV                O!