U ÀÒ.e48ã@s®dZddlZddlZddlZddlmZddlmZmZddl m Z ddl m Z m Z ddlmZddlmZmZdd lmZdd lmZdd lmZdd lmZdd lmZmZddlmZddl m!Z!ddl"m#Z#m$Z$ddl%m&Z&e�rddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-ddl.m/Z/dddgZ0e 1e2¡Z3e j4 5¡Z6dd„Z7dd„Z8dd„Z9dd„Z:dd„Z;Gd d!„d!e<ƒZ=d"d#„Z>d/d%d„Z?d&d'„Z@d(d)„ZAd*d+„ZBd0d,d„ZCd1d-d.„ZDdS)2a~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)ÚMarker)ÚInvalidRequirementÚ Requirement)Ú Specifier)ÚRequirementParseErrorÚparse_requirements)ÚInstallationError)ÚPyPIÚTestPyPI)ÚLink)Úmake_pyproject_path)ÚInstallRequirement)ÚARCHIVE_EXTENSIONS)Úis_installable_dirÚsplitext)ÚMYPY_CHECK_RUNNING)Ú path_to_url)Úis_urlÚvcs)ÚWheel)ÚAnyÚDictÚOptionalÚSetÚTupleÚUnion)Ú WheelCacheÚinstall_req_from_editableÚinstall_req_from_lineÚparse_editablecCs t|ƒd ¡}|tkrdSdS)z9Return True if `name` is a considered as an archive file.éTF)rÚlowerr)ÚnameZext©r#úB/usr/lib/python3.8/site-packages/pip/_internal/req/constructors.pyÚis_archive_file4sr%cCs6t d|¡}d}|r*| d¡}| d¡}n|}||fS)Nz^(.+)(\[[^\]]+\])$r é)ÚreÚmatchÚgroup)ÚpathÚmÚextrasZpath_no_extrasr#r#r$Ú _strip_extras=s   r-cCs|s tƒStd| ¡ƒjS)NÚ placeholder)Úsetrr!r,)r,r#r#r$Úconvert_extrasJsr0c Cs`|}t|ƒ\}}tj |¡rptj tj |d¡¡shd tj |¡¡}t|ƒ}tj  |¡r`|d7}t |ƒ‚t |ƒ}|  ¡  d¡r®t|ƒj}|r¤||td|  ¡ƒjfS||dfStD]&}|  ¡  d|¡r²d||f}qÚq²d |krðt d  |¡ƒ‚| d d ¡d   ¡}t |¡�s:d |d dd„tjDƒ¡d} t | ƒ‚t|ƒj}|�sVt d|ƒ‚||dfS)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.pyzMFile "setup.py" not found. Directory cannot be installed in editable mode: {}zb (A "pyproject.toml" file was found, but editable mode currently requires a setup.py based build.)zfile:r.Nz%s:z%s+%sú+z�{} is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with svn+, git+, hg+, or bzr+).r rzFor --editable=%s only z, cSsg|]}|jd‘qS)z+URL©r")Ú.0Zbackendr#r#r$Ú Žsz"parse_editable..z is currently supportedzZCould not detect requirement name for '%s', please specify one with #egg=your_package_name)r-Úosr*ÚisdirÚexistsÚjoinÚformatÚabspathr Úisfilerrr!Ú startswithr Ú egg_fragmentrr,rÚsplitZ get_backendZbackends) Ú editable_reqÚurlZ url_no_extrasr,ÚmsgZpyproject_pathZ package_nameZversion_controlZvc_typeZ error_messager#r#r$rQsb    ÿÿ ÿ ý  þÿ ÿþ ÿÿc Cs”d}tj |¡r„d}zFt|dƒ�2}tt| ¡ƒƒ|dd|ddd7}W5QRXWq�tk r€tj d |d d �Yq�Xn |d |7}|S) z„Returns helpful msg in case requirements file does not exist, or cannot be parsed. :params req: Requirements file path Úz It does exist.Úrz The argument you provided z(%s) appears to be az" requirements file. If that is thez# case, use the '-r' flag to installz" the packages specified within it.z2Cannot parse '%s' as requirements fileT)Úexc_infoz File '%s' does not exist.) r5r*r7ÚopenÚnextrÚreadrÚloggerÚdebug)ÚreqrAÚfpr#r#r$Údeduce_helpful_msg›s.  ÿþýüÿÿ rLc@seZdZdd„ZdS)ÚRequirementPartscCs||_||_||_||_dS©N)Ú requirementÚlinkÚmarkersr,)ÚselfrOrPrQr,r#r#r$Ú__init__¸szRequirementParts.__init__N)Ú__name__Ú __module__Ú __qualname__rSr#r#r#r$rM·srMcCs`t|ƒ\}}}|dk rFz t|ƒ}WqJtk rBtd|ƒ‚YqJXnd}t|ƒ}t||d|ƒS)NúInvalid requirement: '%s')rrrrr rM)r?r"r@Zextras_overriderJrPr#r#r$Úparse_req_from_editableÅs rXFc CsLt|ƒ}|jjdkr|jjnd}t|j||d|j||||r>|ni||jd� S)NÚfileT) Ú source_dirZeditablerPÚ constraintÚ use_pep517ÚisolatedÚoptionsÚ wheel_cacher,)rXrPÚschemeZ file_pathr rOr,) r?Ú comes_fromr\r]r^r_r[ÚpartsrZr#r#r$rÙs  ÷cCs>tjj|krdStjjdk r,tjj|kr,dS| d¡r: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)r5r*ÚsepÚaltsepr<r2r#r#r$Ú_looks_like_pathõs  rfcCsŒt|ƒr0tj |¡r0t|ƒr$t|ƒStd|ƒ‚t|ƒsÚlenrHZwarning)r*r"Z urlreq_partsr#r#r$Ú_get_url_from_path s( ÿÿ  ýricsât|ƒrd}nd}||krF| |d¡\}}| ¡}|s.with_sourcezIt looks like a path.ú=c3s|]}|ˆkVqdSrNr#)r3Úop)Ú req_as_stringr#r$Ú jsz&parse_req_from_line..z,= is not a valid operator. Did you mean == ?rBzInvalid requirement: {!r}z Hint: {}) rr>Ústriprr5r*Únormpathr:r r-rir`r'Úsearchr@rZis_wheelrÚfilenamer"Úversionr=r0rrrdrLÚanyÚ operatorsr9rrM)r"rlZ marker_sepZmarkers_as_stringrQr*rPZextras_as_stringÚpr@Zwheelr,rmrJZadd_msgrAr#)rlrpr$Úparse_req_from_line+sj    ÿ     ÿÿrzc Cs6t||ƒ}t|j||j|j|||r&|ni|||jd� 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. )rPrQr\r]r^r_r[r,)rzr rOrPrQr,) r"rar\r]r^r_r[rlrbr#r#r$rzs  úcCszz t|ƒ}Wn tk r,td|ƒ‚YnXtjtjg}|jrh|rh|jrh|jj|krhtd|j |fƒ‚t |||||d�S)NrWzkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI. %s depends on %s )r]r_r\) rrrr Zfile_storage_domainr r@rPZnetlocr"r )Z req_stringrar]r_r\rJZdomains_not_allowedr#r#r$Úinstall_req_from_req_string—s, þ ÿþÿþr{)NNFNNF)NNFNNFN)NFNN)EÚ__doc__Zloggingr5r'Zpip._vendor.packaging.markersrZ"pip._vendor.packaging.requirementsrrZ pip._vendor.packaging.specifiersrZpip._vendor.pkg_resourcesrrZpip._internal.exceptionsrZpip._internal.models.indexr r Zpip._internal.models.linkr Zpip._internal.pyprojectr Zpip._internal.req.req_installr Zpip._internal.utils.filetypesrZpip._internal.utils.miscrrZpip._internal.utils.typingrZpip._internal.utils.urlsrZpip._internal.vcsrrZpip._internal.wheelrÚtypingrrrrrrZpip._internal.cacherÚ__all__Z getLoggerrTrHZ _operatorsÚkeysrxr%r-r0rrLÚobjectrMrXrrfrirzrr{r#r#r#r$Úsr            þ    Jù "Qø û