a Re; @sdZddlZddlZddlZddlmZmZmZmZm 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/Z0ej12Z3e4e e4ee4fdddZ5ee4ee4dddZ6e4e ee4e4ee4fdddZ7e4e4dddZ8Gd d!d!Z9e4e9dd"d#Z:d=e4ee e!e4fee;e;eee4efe;e;e;e!d% d&d'Ze4ee4e9d.d/d0Z?d>e4ee e4e!fee;e;eee4efe;ee4e;e!d1 d2d3Z@d?e4ee!e;ee;e;e!d4d5d6ZAd@ee;ee;e;e!d7d8d9ZBee!e!d:d;d<ZCdS)Aa~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_editable)pathreturncCs6td|}d}|r*|d}|d}n|}||fS)Nz^(.+)(\[[^\]]+\])$)rematchgroup)rmextraspath_no_extrasr(/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/req/constructors.py _strip_extras+s   r*)r&rcCs|s tStd|jS)N placeholder)setrlowerr&)r&r(r(r)convert_extras7sr.) editable_reqrcCs|}t|\}}tj|r$t|}|drdt|j}|rX||t d|j fS||t fSt D]*}||drh|d|}qqht|}|j sdt j}t|d|d|j}|std|||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@      r)reqrcCsd}tj|rd}zJt|.}tt||d|7}Wdn1sR0YWqtyt j d|ddYq0n|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@s0eZdZeeeeeeeedddZ dS)RequirementParts requirementr>markersr&cCs||_||_||_||_dSNrM)selfrNr>rOr&r(r(r)__init__szRequirementParts.__init__N) __name__ __module__ __qualname__rr rrrstrrRr(r(r(r)rLs rLcCsbt|\}}}|durHz t|}WqLtyDtd|dYqL0nd}t|}t||d|S)NInvalid requirement: '')rr r rrrL)r/namer:extras_overrider@r>r(r(r)parse_req_from_editables  r[F) r/ comes_from use_pep517isolatedoptions constraint user_suppliedpermit_editable_wheelsrc Cs`t|}t|j||d||j||||r0|dgng|rB|dgng|rT|dini|jd S)NTinstall_optionsglobal_optionshashes) r\raeditablerbr>r`r]r^rcrd hash_optionsr&)r[rrNr>getr&) r/r\r]r^r_r`rarbpartsr(r(r)rs r)rYrcCs>tjj|vrdStjjdur,tjj|vr,dS|dr:dSdS)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)rYr(r(r)_looks_like_paths  rm)rrYrcCst|r4tj|r4t|r$t|Std|dt|s@dStj|rTt|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) rmr2rr3rrrrisfilesplitlenrGwarning)rrY urlreq_partsr(r(r)_get_url_from_paths$    rt)rY line_sourcercsnt|rd}nd}||vrF||d\}}|}|s.with_source) req_as_stringrcsz t}Wntytjjvr8d}|t7}n(dvr\tfddtDs\d}nd}d}|r|d|7}t|Yn40|j D]*}t |}| d rd |d }t|q|S) NzIt looks like a path.=c3s|]}|vVqdSrPr().0opr{r(r) @szAparse_req_from_line.._parse_req_string..z,= is not a valid operator. Did you mean == ?rAzInvalid requirement: z Hint: ]zExtras after version 'z'.) rr r2rrkrKany operatorsr specifierrVendswith)r{r@add_msgrIspecspec_str)rzrr)_parse_req_string9s*       z.parse_req_from_line.._parse_req_string)rrpstriprr2rnormpathabspathrr*rtschemer"searchr:ris_wheelrfilenamerYversionr5r.rVr rL)rYru marker_sepmarkers_as_stringrOr{rr>extras_as_stringpr:wheelr&rr@r()rurzr)parse_req_from_linesH       r) rYr\r]r^r_r`rurarc Csbt||}t|j||j|j|||r.|dgng|r@|dgng|rR|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. rcrdre) r>rOr]r^rcrdrgr`r&ra)rrrNr>rOrhr&) rYr\r]r^r_r`rurarir(r(r)r^s r) req_stringr\r^r]rarcCs|z t|}Wn"ty.td|dYn0tjtjg}|jrj|rj|jrj|jj|vrjtd |j |t |||||dS)NrWrXzkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI. {} depends on {} )r^r]ra) rr rrfile_storage_domainrr:r>netlocr9rYr)rr\r^r]rar@domains_not_allowedr(r(r)install_req_from_req_strings6   r) parsed_reqr^r]rarc CsH|jr"t|j|j||j||d}n"t|j|j|||j|j|j|d}|S)N)r\r]r`r^ra)r\r]r^r_r`rura) is_editablerrNr\r`rr_ru)rr^r]rar@r(r(r)#install_req_from_parsed_requirements(  r)r>ireqrc Cs.t|j|j|j||j|j|j|j|j|j d S)N) r@r\rfr>rOr]r^rcrdrg) rr@r\rfrOr]r^rcrdrg)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_filerZpip._internal.req.req_installrpip._internal.utils.filetypesrpip._internal.utils.miscrpip._internal.utils.packagingrpip._internal.utils.urlsrpip._internal.vcsrr__all__ getLoggerrSrG _operatorskeysrrVr*r.rrKrLr[boolrrmrtrrrrrr(r(r(r)s                "7 "\ $ (