o ai;@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)rmextraspath_no_extrasr(/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/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,ris_vcsjoin all_schemesrformat)r/url url_no_extrasr& package_nameversion_controllinkbackendsr(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.) r2rexistsopennextr readr9r loggerdebug)r@msgfpr(r(r)deduce_helpful_msgts(    rKc @s6eZdZdeedeedeedeefddZ dS)RequirementParts requirementr>markersr&cCs||_||_||_||_dSN)rMr>rNr&)selfrMr>rNr&r(r(r)__init__s zRequirementParts.__init__N) __name__ __module__ __qualname__rr rrrstrrQr(r(r(r)rLsrLcCs\t|\}}}|dur!zt|}Wnty td|dwd}t|}t||d|S)NInvalid requirement: '')rr r rrrL)r/namer:extras_overrider@r>r(r(r)parse_req_from_editables  rZF 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) r[r`editablerar>r_r\r]rbrc hash_optionsr&)rZrrMr>getr&) r/r[r\r]r^r_r`rapartsr(r(r)rs  rrXcCs>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)r2rsepaltsepr4)rXr(r(r)_looks_like_paths  rlcCst|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) rlr2rr3rrrrisfilesplitlenrGwarning)rrX urlreq_partsr(r(r)_get_url_from_paths$    rs 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()rw)rtr(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|]}|vVqdSrOr().0oprzr(r) @s zAparse_req_from_line.._parse_req_string..z,= is not a valid operator. Did you mean == ?rAzInvalid requirement: z Hint: ]zExtras after version 'z'.) rr r2rrjrKany operatorsr specifierrUendswith)rzr@add_msgrIspecspec_str)ryr~r)_parse_req_string9s.      z.parse_req_from_line.._parse_req_string)rrostriprr2rnormpathabspathrr*rsschemer"searchr:ris_wheelrfilenamerXversionr5r.rUr rL)rXrt marker_sepmarkers_as_stringrNrzrr>extras_as_stringpr:wheelr&rr@r()rtryr)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. rbrcrd) r>rNr\r]rbrcrfr_r&r`)rrrMr>rNrgr&) rXr[r\r]r^r_rtr`rhr(r(r)r^s r req_stringcCsxzt|}Wntytd|dwtjtjg}|jr3|r3|jr3|jj|vr3td |j |t |||||dS)NrVrWzkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI. {} depends on {} )r]r\r`) rr rrfile_storage_domainrr:r>netlocr9rXr)rr[r]r\r`r@domains_not_allowedr(r(r)install_req_from_req_strings4    r parsed_reqc CsJ|jrt|j|j||j||d}|St|j|j|||j|j|j|d}|S)N)r[r\r_r]r`)r[r\r]r^r_rtr`) is_editablerrMr[r_rr^rt)rr]r\r`r@r(r(r)#install_req_from_parsed_requirements* rr>ireqc Cs.t|j|j|j||j|j|j|j|j|j d S)N) r@r[rer>rNr\r]rbrcrf) rr@r[rerNr\r]rbrcrf)r>rr(r(r)install_req_from_link_and_ireqsr)NNFNFFF)NNFNFNF)NFNF)FNF)D__doc__loggingr2r"typingrrrrrrZpip._vendor.packaging.markersrZ"pip._vendor.packaging.requirementsr r Z pip._vendor.packaging.specifiersr pip._vendor.pkg_resourcesr r pip._internal.exceptionsrpip._internal.models.indexrrpip._internal.models.linkrpip._internal.models.wheelrZpip._internal.req.req_filerpip._internal.req.req_installrpip._internal.utils.filetypesrpip._internal.utils.miscrpip._internal.utils.packagingrpip._internal.utils.urlsrpip._internal.vcsrr__all__ getLoggerrRrG _operatorskeysrrUr*r.rrKrLrZboolrrlrsrrrrrr(r(r(r)s                $7 "\ $ (