a  ze= @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#d%d&d'Ze4ee4e9d.d/d0Z?d>e4ee e4e#fee;e;eee4efe;ee4e;e#d1 d2d3Z@d?e4ee#e;ee;e;e#d4d5d6ZAd@e!e;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)make_pyproject_path)ParsedRequirement)InstallRequirement)is_archive_file)is_installable_dir) 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(`/opt/bitninja-python-dojo/embedded/lib/python3.9/site-packages/pip/_internal/req/constructors.py _strip_extras*s   r*)r&rcCs|s tStd|jS)N placeholder)setr lowerr&)r&r(r(r)convert_extras6sr.) editable_reqrc CsV|}t|\}}tj|rtj|d}tj|d}tj|stj|sdtj|}t|}tj |r~|d7}t |t |}| drt|j}|r||td| jfS||tfStD],} | | dr| d|}qqt|} | js0d tj} t |d | d | j}|sJt d |||tfS) 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] zsetup.pyz setup.cfgz\File "setup.py" or "setup.cfg" not found. Directory cannot be installed in editable mode: {}zd (A "pyproject.toml" file was found, but editable mode currently requires a setuptools-based build.)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*osrisdirjoinexistsformatabspathrisfilerrr- startswithr egg_fragmentr r&r,ris_vcs all_schemes) r/url url_no_extrasr&setup_py setup_cfgmsgpyproject_path package_nameversion_controllinkbackendsr(r(r)r<sZ        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.) r2rr5opennextr readr6r loggerdebug)rGrAfpr(r(r)deduce_helpful_msgs"  ( rPc@s0eZdZeeeeeeeedddZ dS)RequirementParts requirementrEmarkersr&cCs||_||_||_||_dSNrR)selfrSrErTr&r(r(r)__init__szRequirementParts.__init__N) __name__ __module__ __qualname__rr rrrstrrWr(r(r(r)rQs rQcCsbt|\}}}|durHz t|}WqLtyDtd|dYqL0nd}t|}t||d|S)NInvalid requirement: '')rr r rrrQ)r/namer=extras_overriderGrEr(r(r)parse_req_from_editables  r`F)r/ comes_from use_pep517isolatedoptions constraint user_suppliedrcCs^t|}t|j||d|j||||r.|dgng|r@|dgng|rR|dini|jd S)NTinstall_optionsglobal_optionshashes) rarfeditablerErerbrcrgrh hash_optionsr&)r`rrSrEgetr&)r/rarbrcrdrerfpartsr(r(r)rs r)r^rcCs>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)r2rsepaltsepr9)r^r(r(r)_looks_like_paths  rq)rr^rcCst|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) rqr2rr3rrrrr8splitlenrMwarning)rr^ urlreq_partsr(r(r)_get_url_from_paths$    rw)r^ 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|]}|vVqdSrUr().0opr~r(r) PzAparse_req_from_line.._parse_req_string..z,= is not a valid operator. Did you mean == ?rHzInvalid requirement: z Hint: ]zExtras after version 'z'.) r r r2rrorPany operatorsr specifierr[endswith)r~rGadd_msgrAspecspec_str)r}rr)_parse_req_stringHs.       z.parse_req_from_line.._parse_req_string)rrsstriprr2rnormpathr7rr*rwschemer"searchr=ris_wheelrfilenamer^versionr:r.r[r rQ)r^rx marker_sepmarkers_as_stringrTr~rrEextras_as_stringpr=wheelr&rrGr()rxr}r)parse_req_from_linesL       r) r^rarbrcrdrerxrfrc 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. rgrhri) rErTrbrcrgrhrkrer&rf)rrrSrErTrlr&) r^rarbrcrdrerxrfrmr(r(r)rns r) req_stringrarcrbrfrcCs|z t|}Wn"ty.td|dYn0tjtjg}|jrj|rj|jrj|jj|vrjtd |j |t |||||dS)Nr\r]zkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI. {} depends on {} )rcrbrf) r r rrfile_storage_domainrr=rEnetlocr6r^r)rrarcrbrfrGdomains_not_allowedr(r(r)install_req_from_req_strings,   r) parsed_reqrcrbrfrc CsH|jr"t|j|j||j||d}n"t|j|j|||j|j|j|d}|S)N)rarbrercrf)rarbrcrdrerxrf) is_editablerrSrarerrdrx)rrcrbrfrGr(r(r)#install_req_from_parsed_requirements(  r)rEireqrc Cs.t|j|j|j||j|j|j|j|j|j d S)N) rGrarjrErTrbrcrgrhrk) rrGrarjrTrbrcrgrhrk)rErr(r(r)install_req_from_link_and_ireqsr)NNFNFF)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.wheelrpip._internal.pyprojectrZpip._internal.req.req_filerZpip._internal.req.req_installrpip._internal.utils.filetypesrpip._internal.utils.miscrpip._internal.utils.urlsrpip._internal.vcsrr__all__ getLoggerrXrM _operatorskeysrr[r*r.rrPrQr`boolrrqrwrrrrrr(r(r(r)s                "G !^  $