U 巀gG@sdZddlZddlZddlZddlZddlmZddlmZm Z m Z m Z m Z m Z mZddlmZddlmZmZddlmZddlmZdd lmZmZdd lmZdd lmZdd lm Z dd l!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,m-Z-dddgZ.e/e0Z1ej23Z4e5e e5e e5fdddZ6e e5e e5dddZ7ee e5edddZ8e5e e e5e5e e5fdd dZ9e5dd!d"d#Z:e5e5d$d%d&Z;ed'd(Gd)d*d*Ze>e e e5e e e5e e5fe>e>e>e e e5ee5e e5ffe"d/ d0dZ?e5e>d1d2d3Z@e5e5e e5d4d5d6ZAe5e e5ee>e e e5e e e5e e5fe>e e5e>e e e5ee5e e5ffe"d; de e>e>e"d=d>d?ZDdOe e>e e>e>e e e5ee5e e5ffe"d@dAdBZEee"e"dCdDdEZFe"e"dFdGdHZGe"ee5e"dIdJdKZHdS)Pa~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) dataclass) CollectionDictListOptionalSetTupleUnion)Marker)InvalidRequirement Requirement) Specifier)InstallationError)PyPITestPyPI)Link)Wheel)ParsedRequirement)InstallRequirement)is_archive_file)is_installable_dir)get_requirement) path_to_url)is_urlvcsinstall_req_from_editableinstall_req_from_lineparse_editable)pathreturncCs6td|}d}|r*|d}|d}n|}||fS)Nz^(.+)(\[[^\]]+\])$)rematchgroup)rmextraspath_no_extrasr(L/opt/hc_python/lib/python3.8/site-packages/pip/_internal/req/constructors.py _strip_extras,s   r*)r&rcCs|s tStd|jS)N placeholder)setrlowerr&)r&r(r(r)convert_extras8sr.)req new_extrasrcCstjdt|tjd}|dk s.td|d|d}|d}|dk rR|dk sbtd|dd |rxd t|nd }t |||S) z Returns a new requirement based on the given one, with the supplied extras. If the given requirement already has extras those are replaced (or dropped if no new extras are given). z([\w\t .-]+)(\[[^\]]*\])?(.*))flagsNzregex match on requirement z! failed, this should never happenr z®ex group selection for requirement z[{}],) r" fullmatchstrASCIIAssertionErrorr$formatjoinsortedr)r/r0r#prepostr&r(r(r)_set_requirement_extras>s&    r>) 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|d ||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).z'Could not detect requirement name for 'z1', please specify one with #egg=your_package_name)r*osrisdirrr- startswithr egg_fragmentrr&r,ris_vcsr: all_schemesr)r?url url_no_extrasr& package_nameversion_controllinkbackendsr(r(r)rWs8       )filenamerc Cst|ddd|}dddd|DD}|D]X}d|krJ|d|d}|d rn|dd t|d }t|W5QRdSW5QRXdS) 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)rD.0liner(r(r) s z2check_first_requirement_in_file..css|]}|VqdSN)striprSr(r(r)rVsz #N\r4)openfindendswithrXnextr)rNflinesrUr(r(r)check_first_requirement_in_files   ra)r/rcCs^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.)rBrexistsrar loggerdebug)r/msgr(r(r)deduce_helpful_msgs    rfT)frozenc@s>eZdZUeeed<eeed<eeed<ee ed<dS)RequirementParts requirementrLmarkersr&N) __name__ __module__ __qualname__rr __annotations__rr rr6r(r(r(r)rhs    rhc Csvt|\}}}|dk r\z t|}Wq`tk rX}ztd|d|W5d}~XYq`Xnd}t|}t||d|S)NInvalid requirement: : )rrr rrrh)r?namerHextras_overrider/excrLr(r(r)parse_req_from_editables (rtF) use_pep517isolatedglobal_options hash_options constraint user_suppliedpermit_editable_wheelsconfig_settings) r? comes_fromrurvrwrxryrzr{r|rc Cs0t|} t| j||d|| j|||||| | jd S)NT) r}rzeditabler{rLryrurvrwrxr|r&)rtrrirLr&) r?r}rurvrwrxryrzr{r|partsr(r(r)rs )rqrcCs>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)rBrsepaltseprD)rqr(r(r)_looks_like_paths  r)rrqrcCst|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) rrBrrCrrrrisfilesplitlenrcwarning)rrq urlreq_partsr(r(r)_get_url_from_paths$    r)rq line_sourcercsnt|rd}nd}||krF||d\}}|}|s.with_source) req_as_stringrc sz tWStk r}zxtjjkr:d}|t7}n(dkr^tfddtDs^d}nd}dd|}|r|d |7}t|W5d}~XYnXdS) NzIt looks like a path.=c3s|]}|kVqdSrWr()rToprr(r)rVoszAparse_req_from_line.._parse_req_string..z,= is not a valid operator. Did you mean == ?r4rorpz Hint: ) rr rBrrrfany operatorsr)rrsadd_msgre)rrr)_parse_req_stringhs  z.parse_req_from_line.._parse_req_string)rrrXr rBrnormpathabspathrr*rschemer"searchrHris_wheelrrNrqversionrEr.r6r rh)rqr marker_sepmarkers_as_stringrjrrrLextras_as_stringprHwheelr&rr/r()rrr)parse_req_from_line3sH       r)rurvrwrxryrrzr|) rqr}rurvrwrxryrrzr|rc Cs2t||} t| j|| j| j||||| || 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. ) rLrjrurvrwrxr|ryr&rz)rrrirLrjr&) rqr}rurvrwrxryrrzr|rr(r(r)rs ) req_stringr}rvrurzrc Csz t|}Wn6tk rB}ztd|d|W5d}~XYnXtjtjg}|jr|r|jr|jj|krtd|j d|dt |||||dS)NrorpzZPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI. z depends on  )rvrurz) rr rrfile_storage_domainrrHrLnetlocrqr)rr}rvrurzr/rsdomains_not_allowedr(r(r)install_req_from_req_strings2 & r) parsed_reqrvrurzr|rc Cst|jr$t|j|j||j|||d}nLt|j|j|||jrF|jdgng|jr\|jdini|j|j||d }|S)N)r}ruryrvrzr|rwhashes) r}rurvrwrxryrrzr|) is_editablerrir}ryroptionsgetr)rrvrurzr|r/r(r(r)#install_req_from_parsed_requirements2 r)rLireqrc Cs2t|j|j|j||j|j|j|j|j|j |j d S)N) r/r}r~rLrjrurvrwrxr|rz) rr/r}r~rjrurvrwrxr|rz)rLrr(r(r)install_req_from_link_and_ireqsr)rrcCsRt|jdk rt|jtnd||j|j|j|j|j|j |j |j g|j |j |jdS)z Creates a new InstallationRequirement using the given template but without any extras. Sets the original requirement as the new one's parent (comes_from). N)r/r}r~rLrjrurvrwrxryr&r|rzr{)rr/r>r,r~rLrjrurvrwrxryr|rzr{)rr(r(r)install_req_drop_extrass r)rr&rcCs8t|}|j||_|jdk r.t|j|jnd|_|S)z Returns a copy of an installation requirement with some additional extras. Makes a shallow copy of the ireq object. N)copyr&r/r>)rr&resultr(r(r)install_req_extend_extras!s  r)N)N)NFNF)FNFN)I__doc__rloggingrBr" dataclassesrtypingrrrrrrr Zpip._vendor.packaging.markersr "pip._vendor.packaging.requirementsr r Z pip._vendor.packaging.specifiersr 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__ getLoggerrkrc _operatorskeysrr6r*r.r>rrarfrhrtboolrrrrrrrrrrr(r(r(r)s  $              "7  "Q  ' ( )