o Ec;@s dZddlZddlZddlZddlmZmZmZmZm Z m Z ddl m Z ddl mZmZddlmZddlmZmZddlmZdd lmZmZdd lmZdd lmZdd lmZdd l m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+m,Z,gdZ-e.e/Z0ej12Z3de4de e4ee4ffddZ5dee4dee4fddZ6de4de ee4e4ee4ffddZ7de4de4fdd Z8Gd!d"d"Z9de4de9fd#d$Z:   %  % % %dCde4d&ee e!e4fd'ee;d(e;d)eee4efd*e;d+e;d,e;de!fd-d.Zd/e4d4ee4de9fd5d6Z?   %  %  %dDd/e4d&ee e4e!fd'ee;d(e;d)eee4efd*e;d4ee4d+e;de!fd7d8Z@  %  %dEd9e4d&ee!d(e;d'ee;d+e;de!f d:d;ZA %  %dFdZBd?ed@e!de!fdAdBZCdS)Ga~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. N)AnyDictOptionalSetTupleUnion)Marker)InvalidRequirement Requirement) Specifier)RequirementParseErrorparse_requirements)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_editablepathreturncCs<td|}d}|r|d}|d}||fS|}||fS)Nz^(.+)(\[[^\]]+\])$)rematchgroup)rmextrasZpath_no_extrasr'Q/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/req/constructors.py _strip_extras+s   r)r&cCs|stStd|jS)N placeholder)setrlowerr&)r&r'r'r(convert_extras7sr- editable_reqcCs|}t|\}}tj|rt|}|dr2t|j}|r,||t d|j fS||t fSt D]}||drI|d|}nq4t|}|j sadt j}t|d|d|j}|smtd|||t fS) aParses an editable requirement into: - a requirement name - an URL - extras - editable options Accepted requirements: svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir .[some_extra] zfile:r*:+z, zq is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with z).zZCould not detect requirement name for '{}', please specify one with #egg=your_package_name)r)osrisdirrr, startswithr egg_fragmentrr&r+rZis_vcsjoinZ all_schemesrformat)r.urlZ url_no_extrasr&Z package_nameZversion_controllinkZbackendsr'r'r(r=s@      rreqcCsd}tj|rEd}z(t|}tt||d|7}WdW|S1s+wYW|StyDt j d|ddY|Sw|d|d 7}|S) zReturns helpful msg in case requirements file does not exist, or cannot be parsed. :params req: Requirements file path z The path does exist. zThe argument you provided ({}) appears to be a requirements file. If that is the case, use the '-r' flag to install the packages specified within it.Nz&Cannot parse '%s' as requirements fileT)exc_infoz File 'z' does not exist.) r1rexistsopennextr readr6r loggerdebug)r9msgfpr'r'r(deduce_helpful_msgts(    rDc @s6eZdZdeedeedeedeefddZ dS)RequirementParts requirementr8markersr&cCs||_||_||_||_dSN)rFr8rGr&)selfrFr8rGr&r'r'r(__init__s zRequirementParts.__init__N) __name__ __module__ __qualname__rr rrrstrrJr'r'r'r(rEsrEcCs\t|\}}}|dur!zt|}Wnty td|dwd}t|}t||d|S)NInvalid requirement: '')rr r rrrE)r.namer7Zextras_overrider9r8r'r'r(parse_req_from_editables  rRF comes_from use_pep517isolatedoptions constraint user_suppliedpermit_editable_wheelsc Cs`t|}t|j||d||j||||r|dgng|r!|dgng|r*|dini|jd S)NTinstall_optionsglobal_optionshashes) rSrXeditablerYr8rWrTrUrZr[ hash_optionsr&)rRrrFr8getr&) r.rSrTrUrVrWrXrYpartsr'r'r(rs  rrQcCs>tjj|vrdStjjdurtjj|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)r1rsepaltsepr3)rQr'r'r(_looks_like_paths  rdcCst|rtj|rt|rt|Std|dt|s dStj|r*t|S| dd}t |dkr>t|ds>dSt 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@r r!rzARequirement %r looks like a filename, but the file does not exist) rdr1rr2rrrrisfilesplitlenr@Zwarning)rrQZ urlreq_partsr'r'r(_get_url_from_paths$    ri line_sourcecslt|rd}nd}||vr#||d\}}|}|sd}nt|}nd}|}d}tjtj|}d}d}t|rBt|}nt |\} }t | |} | durUt| }|r|j dkrrt d|jrrtttjtj|j}|jrt|j} | jd| j}n|j}n|}t|} dtdtffd d d tdtffd d } |dur| |}nd}t|||| S)Nz; ;r filez\.\./z==textrcss|S|ddS)Nz (from )r')rm)rjr'r( with_source4sz(parse_req_from_line..with_source req_as_stringcszt}Wn>tyDtjjvrd}|t7}ndvr.tfddtDs.d}nd}d}|r@|d|7}t|w|j D]}t |}| d r]d |d }t|qH|S) NzIt looks like a path.=c3s|]}|vVqdSrHr').0oprpr'r( @s zAparse_req_from_line.._parse_req_string..z,= is not a valid operator. Did you mean == ?r:zInvalid requirement: z Hint: ]zExtras after version 'z'.) rr r1rrbrDany operatorsrZ specifierrNendswith)rpr9Zadd_msgrBspecZspec_str)rortr(_parse_req_string9s.      z.parse_req_from_line.._parse_req_string)rrgstriprr1rnormpathabspathrr)rischemer"searchr7rZis_wheelrfilenamerQversionr4r-rNr rE)rQrjZ marker_sepZmarkers_as_stringrGrprr8Zextras_as_stringpr7Zwheelr&r{r9r')rjror(parse_req_from_linesH      rc Csbt||}t|j||j|j|||r|dgng|r |dgng|r)|dini||j|d S)aCreates an InstallRequirement from a name, which might be a requirement, directory containing 'setup.py', filename, or URL. :param line_source: An optional string describing where the line is from, for logging purposes in case of an error. rZr[r\) r8rGrTrUrZr[r^rWr&rX)rrrFr8rGr_r&) rQrSrTrUrVrWrjrXr`r'r'r(r^s r req_stringcCsxzt|}Wntytd|dwtjtjg}|jr3|r3|jr3|jj|vr3td |j |t |||||dS)NrOrPzkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI. {} depends on {} )rUrTrX) rr rrZfile_storage_domainrr7r8netlocr6rQr)rrSrUrTrXr9Zdomains_not_allowedr'r'r(install_req_from_req_strings6    r parsed_reqc CsJ|jrt|j|j||j||d}|St|j|j|||j|j|j|d}|S)N)rSrTrWrUrX)rSrTrUrVrWrjrX)Z is_editablerrFrSrWrrVrj)rrUrTrXr9r'r'r(#install_req_from_parsed_requirements* rr8ireqc Cs.t|j|j|j||j|j|j|j|j|j d S)N) r9rSr]r8rGrTrUrZr[r^) rr9rSr]rGrTrUrZr[r^)r8rr'r'r(install_req_from_link_and_ireqsr)NNFNFFF)NNFNFNF)NFNF)FNF)D__doc__Zloggingr1r"typingrrrrrrZpip._vendor.packaging.markersrZ"pip._vendor.packaging.requirementsr r Z pip._vendor.packaging.specifiersr Zpip._vendor.pkg_resourcesr r Zpip._internal.exceptionsrZpip._internal.models.indexrrZpip._internal.models.linkrZpip._internal.models.wheelrZpip._internal.req.req_filerZpip._internal.req.req_installrZpip._internal.utils.filetypesrZpip._internal.utils.miscrZpip._internal.utils.packagingrZpip._internal.utils.urlsrZpip._internal.vcsrr__all__Z getLoggerrKr@Z _operatorskeysrxrNr)r-rrDrErRboolrrdrirrrrrr'r'r'r(s                $7 "\ $ (