t kԿ&jdZddlmZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl mZmZddlmZdd lmZdd lmZmZdd lmZdd lmZdd lmZddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(m)Z)gdZ*ej+e,Z-ej./Z0dTdZ1dUdZ2dVd!Z3dWd$Z4dWd%Z5dWd&Z6dXd)Z7dYd*Z8e d+,Gd-d.Z9dZd/Z: d[d0dd0d0d0dd1d\d>Z;d]d@Z d[d0dd0dd0ddDd`dFZ? dadbdIZ@ dcdddLZAdedPZBdfdQZCdgdSZDdS)ha~Backing implementation for InstallRequirement's various constructors The idea here is that these formed a major chunk of InstallRequirement's size so, moving them and support code dedicated to them outside of that class helps creates for better understandability for the rest of the code. These are meant to be used elsewhere within pip to create instances of InstallRequirement. ) annotationsN) Collection) dataclass)Marker)InvalidRequirement Requirement) Specifier)InstallationError)PyPITestPyPI)Link)Wheel)ParsedRequirement)InstallRequirement)is_archive_file)is_installable_dir)get_requirement) path_to_url)is_urlvcs)install_req_from_editableinstall_req_from_lineparse_editablepathstrreturntuple[str, str | None]ctjd|}d}|r=|d}|d}n|}||fS)Nz^(.+)(\[[^\]]+\])$)rematchgrouprstrip)rmextraspath_no_extrass p/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/pip/_internal/req/constructors.py _strip_extrasr).s] &--A F**,, 6 !!r& str | Noneset[str]ct|stStd|zjS)N placeholder)setrlowerr&)r&s r(convert_extrasr1:s1 uu =6<<>>9 : : AAr*reqr new_extrasctjdt|tj}|Jd|d|d}|d}||Jd|dd |r"d t|nd }t|||S) z Returns a new requirement based on the given one, with the supplied extras. If the given requirement already has extras those are replaced (or dropped if no new extras are given). z([\w\t .-]+)(\[[^\]]*\])?(.*))flagsNzregex match on requirement z! failed, this should never happenrz®ex group selection for requirement z[{}],) r! fullmatchrASCIIr#formatjoinsortedr)r2r3r"prepostr&s r(_set_requirement_extrasr@@s #%,( Ch ###E KSKKK kk!nnC{{1~~D D,,VVVV-,,-- R );); < < ??F   5 5 99;; ! !_"7"7"7 8 8 $,,s,,C E  99 !3 --r*c t|\}}}n##t$rt|\}}}YnwxYwt|}|jsN|jds4dtj }t|d|d|s-|jdstd|d|||fS)a[Parses an editable requirement into: - a requirement name with environment markers - an URL - extras Accepted requirements: - svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir - local_path[some_extra] - Foobar[extra] @ svn+http://blahblah@rev#subdirectory=subdir ; markers rJz, zq is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with z).z'Could not detect requirement name for 'z2', please specify one with your_package_name @ URL) rHrGrTr is_vcsrDrOr<r all_schemesr )rArRrDr&linkbackendss r(rrsM$>|$L$L! c66 MMM$>|$L$L! c666M 99D ; tx227;; 99S_-- , ,' , , ,      3 3G < <  >l > > >    f $$s 66filenameNonect|dd5}dd|DD}|D]}d|vr|d|d}|dr-|dd t |d z}t |ddddS ddddS#1swxYwYdS) a Check if file is parsable as a requirements file. This is heavily based on ``pkg_resources.parse_requirements``, but simplified to just check the first meaningful line. :raises InvalidRequirement: If the first meaningful line cannot be parsed as an requirement. zutf-8ignore)encodingerrorsc3HK|]}||d|VdS)#N)rO.0lines r( z2check_first_requirement_in_file..sR   !OOC00       r*c3>K|]}|VdSN)striprbs r(rez2check_first_requirement_in_file..s*44$444444r*z #N\r8)openfindendswithrhnextr)rZflinesrds r(check_first_requirement_in_filerqsP h : : :a  44!444      Dt||-diioo-.}}T"" ;CRCy((4r??: D ! ! ! ! sBB<<CCctj|sd|dSd} t||d|dz }n+#t$rt d|YnwxYw|S)zReturns helpful msg in case requirements file does not exist, or cannot be parsed. :params req: Requirements file path z File 'z' does not exist.z The path does exist. zThe argument you provided (zx) appears to be a requirements file. If that is the case, use the '-r' flag to install the packages specified within it.z&Cannot parse '%s' as requirements file)rMrexistsrqrloggerdebug)r2msgs r(deduce_helpful_msgrws 7>>#  0///// "C  ',,,  2 2 2 2  DDD =sCCCCCD JsA%A*)A*T)frozenc8eZdZUded<ded<ded<ded<d S) RequirementPartszRequirement | None requirementz Link | NonerXz Marker | Nonemarkersr,r&N)__name__ __module__ __qualname____annotations__r*r(rzrzsB####r*rzct|\}}}|8 t|}n)#t$r}td|d|d}~wwxYwd}t |}t ||d|S)NInvalid requirement: : )rrrr r rz)rArFrDextras_overrider2excrXs r(parse_req_from_editablers!/ !=!=D#  M&5d&;&;CC! M M M#$KD$K$Kc$K$KLL L M 99D Ct_ = ==s' A AA F)isolated hash_options constraint user_suppliedpermit_editable_wheelsconfig_settings comes_fromInstallRequirement | str | Nonerboolrdict[str, list[str]] | Nonerrrr!dict[str, str | list[str]] | Nonerc rt|}t|j||d||j|||||j S)NT) rreditablerrXrrrrr&)rrr{rXr&) rArrrrrrrpartss r(rrsP $L 1 1E  #5 Z!'|    r*rFctjj|vrdStjjtjj|vrdS|drdSdS)akChecks whether the string "looks like" a path on the filesystem. This does not check whether the target actually exists, only judge from the appearance. Returns true if any of the following conditions is true: * a path separator is found (either os.path.sep or os.path.altsep); * a dot is found (which represents the current directory). TN.F)rMrsepaltseprO)rFs r(_looks_like_pathrsS w{dt w~!bgn&<&<t st 5r*ct|rPtj|r1t |rt |St d|dt|sdStj|rt |S| dd}t|dkrt|dsdSt d|t |S) aK First, it checks whether a provided path is an installable directory. If it is, returns the path. If false, check if the path is an archive file (such as a .whl). The function checks if the path is a file. If false, if the path has an @, it will treat it as a PEP 440 URL requirement and return the path. z Directory zC is not installable. Neither 'setup.py' nor 'pyproject.toml' found.N@rr rzARequirement %r looks like a filename, but the file does not exist) rrMrrNrrr risfilesplitlenrtwarning)rrF urlreq_partss r(_get_url_from_pathr)s "'--"5"5 d # # %t$$ $  * * * *    4 t w~~d!4   ::c1%%L <A&6|A&G&Gt NNK  t  r* line_sourcec t|rd}nd}||vrB||d\}}|}|sd}nt|}nd}|}d}tjtj|}d}d}t|rt|}n3t|\} }t| |} | t| }|r|j dkrutj d|jr[tttjtj|j}|jr&t#|j} | jd| j}n |j}n|}t-|} dfd dfd } | | |}nd}t/|||| S)Nz; ;rfilez\.\./z==textrrcs|S|ddS)Nz (from )r)rrs r( with_sourcez(parse_req_from_line..with_source{s' K--{----r* req_as_stringrc@ tS#t$r}tjjvrd}|t z }n)dvr#t fdtDsd}nd}dd|}|r|d|z }t|d}~wwxYw) NzIt looks like a path.=c3 K|]}|vV dSrgr)rcoprs r(rezAparse_req_from_line.._parse_req_string..s922(*m#222222r*z,= is not a valid operator. Did you mean == ?r8rrz Hint: ) rrrMrrrwany operatorsr )rradd_msgrvrs` r(_parse_req_stringz.parse_req_from_line.._parse_req_strings )"=11 1! ) ) )w{m++1-m<<< %%c2222.7222//%I+NmNNNNOOC ,+'+++#C(( ( )s BA;BB)rrrr)rrrr)rrrhrrMrnormpathabspathr r)rschemer!searchrDris_wheelrrZrFversionrPr1rz)rFr marker_sepmarkers_as_stringr|rrrXextras_as_stringprDwheelr&rr2rs ` @r(parse_req_from_linerKs& d||  T"&**Z";";-3355  0GG.//GG ::<rs#"""""  &&&&&&!!!!!!000000NNNNNNNN66666666666655555555******,,,,,,888888<<<<<<999999777777999999000000))))))))     8 $ $  % % ' '  " " " "BBBB 33332$....:%%%%D82 $ > > > >*3704#(9=8&DL8L8L8L8b3704"9=F-1 !!!!!L9= @     0r*