o 7]h>@s"dZddlZddlZddlZddlmZmZmZmZm 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)gdZ*e+e,Z-ej./Z0de1de e1ee1ffddZ2dee1dee1fddZ3de1de ee1e1ee1ffddZ4de1ddfddZ5d e1de1fd!d"Z6Gd#d$d$Z7de1de7fd%d&Z8   '  ' ' 'dEde1d(ee ee1fd)ee9d*e9d+eee1efd,e9d-e9d.e9defd/d0Z:d1e1de9fd2d3Z;de1d1e1dee1fd4d5Z  '  'dGd;e1d(eed*e9d)ee9d-e9def ded*e9d)ee9d-e9def d?d@Z@dAedBedefdCdDZAdS)Ia~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)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&@/usr/lib/python3/dist-packages/pip/_internal/req/constructors.py _strip_extras*s   r(r$cCs|stStd|jS)N placeholder)setrlowerr$)r$r&r&r'convert_extras6sr, 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_schemesr format)r-url url_no_extrasr$ package_nameversion_controllinkbackendsr&r&r'r<s@      rfilenamecCst|dddE}dddd|DD}|D]-}d|vr%|d|d}|d r7|dd t|d }t|WddSWddS1sOwYdS) 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)encodingerrorscss"|] }|r|ds|VqdS)#N)r2.0liner&r&r' ~s z2check_first_requirement_in_file..css|]}|VqdSN)striprCr&r&r'rFsz #N\)openfindendswithrHnextr )r>flinesrEr&r&r'check_first_requirement_in_filess   "rRreqcCs^tj|s d|dSd}zt|Wnty$td|Y|Sw|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 @s6eZdZdeedeedeedeefddZ dS)RequirementParts requirementr<markersr$cCs||_||_||_||_dSrG)rZr<r[r$)selfrZr<r[r$r&r&r'__init__s zRequirementParts.__init__N) __name__ __module__ __qualname__rr rrrstrr]r&r&r&r'rYsrYcCs\t|\}}}|dur!zt|}Wnty td|dwd}t|}t||d|S)NInvalid requirement: '')rr r r rrY)r-namer8extras_overriderSr<r&r&r'parse_req_from_editables  rfF 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) rgrleditablermr<rkrhrirnro hash_optionsr$)rfrrZr<getr$) r-rgrhrirjrkrlrmpartsr&r&r'rs  rrdcCs>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)r0rsepaltsepr2)rdr&r&r'_looks_like_paths  rxcCst|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@rrrzARequirement %r looks like a filename, but the file does not exist) rxr0rr1rrr risfilesplitlenrUwarning)rrd urlreq_partsr&r&r'_get_url_from_paths$    r 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; ;rfilez\.\./z==textrcss|S|ddS)Nz (from )r&)r)rr&r' with_sourceLsz(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|]}|vVqdSrGr&)rDoprr&r'rFXs zAparse_req_from_line.._parse_req_string..z,= is not a valid operator. Did you mean == ?rKzInvalid requirement: z Hint: ]zExtras after version 'z'.) rr r0rrvrXany operatorsr specifierrarN)rrSadd_msgrWspecspec_str)rrr'_parse_req_stringQs.      z.parse_req_from_line.._parse_req_string)rr{rHrr0rnormpathabspathrr(rschemer searchr8ris_wheelrr>rdversionr3r,rar rY)rdr marker_sepmarkers_as_stringr[rrr<extras_as_stringpr8wheelr$rrSr&)rrr'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. rnrorp) r<r[rhrirnrorrrkr$rl)rrrZr<r[rsr$) rdrgrhrirjrkrrlrtr&r&r'rvs r req_stringcCsxzt|}Wntytd|dwtjtjg}|jr3|r3|jr3|jj|vr3td |j |t |||||dS)NrbrczkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI. {} depends on {} )rirhrl) rr r r file_storage_domainrr8r<netlocr7rdr)rrgrirhrlrSdomains_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)rgrhrkrirl)rgrhrirjrkrrl) is_editablerrZrgrkrrjr)rrirhrlrSr&r&r'#install_req_from_parsed_requirements* rr<ireqc Cs.t|j|j|j||j|j|j|j|j|j d S)N) rSrgrqr<r[rhrirnrorr) rrSrgrqr[rhrirnrorr)r<rr&r&r'install_req_from_link_and_ireqsr)NNFNFFF)NNFNFNF)NFNF)FNF)B__doc__loggingr0r typingrrrrrrpip._vendor.packaging.markersr"pip._vendor.packaging.requirementsr r pip._vendor.packaging.specifiersr pip._internal.exceptionsr pip._internal.models.indexr rpip._internal.models.linkrpip._internal.models.wheelrpip._internal.req.req_filerpip._internal.req.req_installrpip._internal.utils.filetypesrpip._internal.utils.miscrpip._internal.utils.packagingrpip._internal.utils.urlsrpip._internal.vcsrr__all__ getLoggerr^rU _operatorskeysrrar(r,rrRrXrYrfboolrrxrrrrrrr&r&r&r's                $7 "\ $ (