U ʗRe@ @sdZddlZddlZddlZddlmZmZmZmZm Z m Z ddl m Z ddl mZmZddlmZddlmZddlmZmZdd lmZdd lmZdd lmZdd lmZdd lm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(m)Z)dddgZ*e+e,Z-ej./Z0e1e e1ee1fdddZ2ee1ee1dddZ3e1e ee1e1ee1fdddZ4e1ddddZ5e1e1d d!d"Z6Gd#d$d$Z7e1e7dd%d&Z8d>e1ee ee1fee9e9eee1efe9e9e9eee1e1fed( d)dZ:e1e9d*d+d,Z;e1e1ee1d-d.d/Zd@e1eee9ee9e9eee1e1fed5d6d7Z?dAee9ee9e9eee1e1fed8d9d:Z@eeed;d~s z2check_first_requirement_in_file..css|]}|VqdSN)striprCr&r&r'rFsz #N\)openfindendswithrHnextr )r>flinesrEr&r&r'check_first_requirement_in_filess   rR)reqrcCs^tj|sd|dSd}z t|Wn tk rHtd|YnX|d|d7}|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. z&Cannot parse '%s' as requirements filezThe 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.)r0rexistsrRr loggerdebug)rSmsgr&r&r'deduce_helpful_msgs    rXc@s0eZdZeeeeeeeedddZ dS)RequirementParts requirementr<markersr$cCs||_||_||_||_dSrGrZ)selfr[r<r\r$r&r&r'__init__szRequirementParts.__init__N) __name__ __module__ __qualname__rr rrrstrr^r&r&r&r'rYs rYcCsdt|\}}}|dk rJz t|}WqNtk rFtd|dYqNXnd}t|}t||d|S)NInvalid requirement: '')rr r r rrY)r-namer8extras_overriderSr<r&r&r'parse_req_from_editables rgF) r- comes_from use_pep517isolatedoptions constraint user_suppliedpermit_editable_wheelsconfig_settingsrc Csbt|} t| j||d|| j||||r0|dgng|rB|dgng|rT|dini|| jdS)NTinstall_optionsglobal_optionshashes) rhrmeditablernr<rlrirjrprq hash_optionsror$)rgrr[r<getr$) r-rhrirjrkrlrmrnropartsr&r&r'rs" )rercCs>tjj|krdStjjdk r,tjj|kr,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)r0rsepaltsepr2)rer&r&r'_looks_like_paths  rz)rrercCst|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@rrrzARequirement %r looks like a filename, but the file does not exist) rzr0rr1rrr risfilesplitlenrUwarning)rre urlreq_partsr&r&r'_get_url_from_paths$    r)re line_sourcercsnt|rd}nd}||krF||d\}}|}|s.with_source) req_as_stringrcsz t}Wntk rtjjkr:d}|t7}n(dkr^tfddtDs^d}nd}d}|r|d|7}t|Yn4X|j D]*}t |}| d rd |d }t|q|S) NzIt looks like a path.=c3s|]}|kVqdSrGr&)rDoprr&r'rFZszAparse_req_from_line.._parse_req_string..z,= is not a valid operator. Did you mean == ?rKzInvalid requirement: z Hint: ]zExtras after version 'z'.) rr r0rrxrXany operatorsr specifierrbrN)rrSadd_msgrWspecspec_str)rrr'_parse_req_stringSs*      z.parse_req_from_line.._parse_req_string)rr}rHrr0rnormpathabspathrr(rschemer searchr8ris_wheelrr>reversionr3r,rbr rY)rer marker_sepmarkers_as_stringr\rrr<extras_as_stringpr8wheelr$rrSr&)rrr'parse_req_from_linesH       r) rerhrirjrkrlrrmrorc Csdt||} 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. rprqrr) r<r\rirjrprqrtrorlr$rm)rrr[r<r\rur$) rerhrirjrkrlrrmrorvr&r&r'rxs  ) req_stringrhrjrirmrorcCsz t|}Wn$tk r0td|dYnXtjtjg}|jrl|rl|jrl|jj|krltd |j |t ||||||dS)NrcrdzkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI. {} depends on {} )rjrirmro) rr r r file_storage_domainrr8r<netlocr7rer)rrhrjrirmrorSdomains_not_allowedr&r&r'install_req_from_req_strings:  r) parsed_reqrjrirmrorc CsL|jr$t|j|j||j|||d}n$t|j|j|||j|j|j||d }|S)N)rhrirlrjrmro)rhrirjrkrlrrmro) is_editablerr[rhrlrrkr)rrjrirmrorSr&r&r'#install_req_from_parsed_requirements,  r)r<ireqrcCs6t|j|j|j||j|j|j|j|j|j |j |j d S)N) rSrhrsr<r\rirjrprqrtrorm) rrSrhrsr\rirjrprqrtrorm)r<rr&r&r'install_req_from_link_and_ireqsr)NNFNFFFN)NNFNFNFN)NFNFN)FNFN)B__doc__loggingr0r typingrrrrrrZpip._vendor.packaging.markersr"pip._vendor.packaging.requirementsr r Z pip._vendor.packaging.specifiersr pip._internal.exceptionsr pip._internal.models.indexr rpip._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__ getLoggerr_rU _operatorskeysrrbr(r,rrRrXrYrgboolrrzrrrrrrr&r&r&r's                "7 "\ & * "