3 ”Re@ã@sÄdZddlZddlZddlZddlmZddlmZmZddl m Z ddl m Z m Z ddlmZddlmZmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlm Z m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'm(Z(e#�r"ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1dddgZ2ej3e4ƒZ5e j6j7ƒZ8dd„Z9dd„Z:dd„Z;dd„ZƒZ?d#d$„Z@d2d&d„ZAd'd(„ZBd)d*„ZCd+d,„ZDd3d-d„ZEd4d.d/„ZFd5d0d1„ZGdS)6a~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)ÚWheel)Úmake_pyproject_path)ÚInstallRequirement)Ú deprecated)ÚARCHIVE_EXTENSIONS)Úis_installable_dirÚsplitext)ÚMYPY_CHECK_RUNNING)Ú path_to_url)Úis_urlÚvcs)ÚAnyÚDictÚOptionalÚSetÚTupleÚUnion)ÚParsedRequirementÚinstall_req_from_editableÚinstall_req_from_lineÚparse_editablecCs t|ƒdjƒ}|tkrdSdS)z9Return True if `name` is a considered as an archive file.éTF)rÚlowerr)ÚnameÚext©r%ú�/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/req/constructors.pyÚis_archive_file1sr'cCs6tjd|ƒ}d}|r*|jdƒ}|jdƒ}n|}||fS)Nz^(.+)(\[[^\]]+\])$r!é)ÚreÚmatchÚgroup)ÚpathÚmÚextrasÚpath_no_extrasr%r%r&Ú _strip_extras:s   r0cCs|s tƒStd|jƒƒjS)NÚ placeholder)Úsetrr"r.)r.r%r%r&Úconvert_extrasGsr3c Csj|}t|ƒ\}}tjj|ƒrptjjtjj|dƒƒshdjtjj|ƒƒ}t|ƒ}tjj |ƒr`|d7}t |ƒ‚t |ƒ}|j ƒj dƒr°t|ƒj}|r¤||td|j ƒƒjfS||tƒfSx.tD]&}|j ƒj dj|ƒƒr¶dj||ƒ}Pq¶Wd|kröt d j|ƒƒ‚|jdd ƒd j ƒ}tj|ƒ�s@d jd d„tjDƒƒ} dj|| ƒ} t | ƒ‚t|ƒj}|�s^t dj|ƒƒ‚||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] 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:r1z{}:z{}+{}ú+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!rz, cSsg|]}|jd‘qS)z+URL)r#)Ú.0Úbendsr%r%r&ú Šsz"parse_editable..z2For --editable={}, only {} are currently supportedzZCould not detect requirement name for '{}', please specify one with #egg=your_package_name)r0Úosr,ÚisdirÚexistsÚjoinÚformatÚabspathr Úisfilerrr"Ú startswithr Ú egg_fragmentrr.r2rÚsplitÚ get_backendÚbackends) Ú editable_reqÚurlÚ url_no_extrasr.ÚmsgÚpyproject_pathÚ package_nameÚversion_controlÚvc_typerCÚ error_messager%r%r&r NsN          cCs†d}tjj|ƒrtd}y8t|dƒ�$}tt|jƒƒƒ|dj|ƒ7}WdQRXWq‚tk rpt j d|dd�Yq‚Xn|d j|ƒ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 ({}) 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 '{}' does not exist.) r8r,r:ÚopenÚnextrÚreadr<rÚloggerÚdebug)ÚreqrGÚfpr%r%r&Údeduce_helpful_msg™s  rWc@seZdZdd„ZdS)ÚRequirementPartscCs||_||_||_||_dS)N)Ú requirementÚlinkÚmarkersr.)ÚselfrYrZr[r.r%r%r&Ú__init__¹szRequirementParts.__init__N)Ú__name__Ú __module__Ú __qualname__r]r%r%r%r&rX¸srXc Csbt|ƒ\}}}|dk rHy t|ƒ}WqLtk rDtdj|ƒƒ‚YqLXnd}t|ƒ}t||d|ƒS)NzInvalid requirement: '{}')r rrrr<r rX)rDr#rEÚextras_overriderUrZr%r%r&Úparse_req_from_editableÆs rbFcCs^t|ƒ}t|j||d|j||||r.|jdgƒng|r@|jdgƒng|rR|jdiƒni|jd� S)NTÚinstall_optionsÚglobal_optionsÚhashes) Ú comes_fromÚ user_suppliedÚeditablerZÚ constraintÚ use_pep517ÚisolatedrcrdÚ hash_optionsr.)rbrrYrZÚgetr.)rDrfrjrkÚoptionsrirgÚpartsr%r%r&rÚs cCs>tjj|krdStjjdk r,tjj|kr,dS|jdƒ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)r8r,ÚsepÚaltsepr?)r#r%r%r&Ú_looks_like_path÷s  rscCs”t|ƒr6tjj|ƒr6t|ƒr$t|ƒStdjftƒŽƒ‚t |ƒsBdStjj |ƒrVt|ƒS|j ddƒ}t |ƒdkr€t|dƒ r€dSt jd|ƒt|ƒS)ad First, it checks whether a provided path is an installable directory (e.g. it has a setup.py). 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. zUDirectory {name!r} 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)rsr8r,r9rrrr<Úlocalsr'r>rAÚlenrSÚwarning)r,r#Ú urlreq_partsr%r%r&Ú_get_url_from_path s"    rycs$t|ƒrd}nd}||krF|j|dƒ\}}|jƒ}|s.with_sourcezIt looks like a path.ú=c3s|]}|ˆkVqdS)Nr%)r5Úop)Ú req_as_stringr%r&ú msz&parse_req_from_line..z,= is not a valid operator. Did you mean == ?rMzInvalid requirement: {!r}z Hint: {}ú]zExtras after version '{}'.z+moving the extras before version specifiersz21.0)Ú replacementÚgone_in)#rrAÚstriprr8r,Únormpathr=r r0ryÚschemer)ÚsearchrErÚis_wheelr Úfilenamer<rur@r3rrrqrWÚanyÚ operatorsrÚ specifierÚstrÚendswithrrX)r#r}Ú marker_sepÚmarkers_as_stringr[r,rZÚextras_as_stringÚprEÚwheelr.r~rUÚadd_msgrGÚspecÚspec_strÚreplacer%)r}r�r&Úparse_req_from_line-sp             ršc Csbt||ƒ}t|j||j|j|||r.|jdgƒng|r@|jdgƒng|rR|jdiƒni||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. rcrdre) rZr[rjrkrcrdrlrir.rg)ršrrYrZr[rmr.) r#rfrjrkrnrir}rgror%r%r&rˆs cCs|y t|ƒ}Wn"tk r.tdj|ƒƒ‚YnXtjtjg}|jrj|rj|jrj|jj |krjtdj|j |ƒƒ‚t |||||d�S)NzInvalid requirement: '{}'zkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI. {} depends on {} )rkrjrg) rrrr<r Úfile_storage_domainr rErZÚnetlocr#r)Ú req_stringrfrkrjrgrUÚdomains_not_allowedr%r%r&Úinstall_req_from_req_string§s"   rŸc CsH|jr"t|j|j||j||d�}n"t|j|j|||j|j|j|d�}|S)N)rfrjrirkrg)rfrjrkrnrir}rg)Ú is_editablerrYrfrirrnr})Ú parsed_reqrkrjrgrUr%r%r&Ú#install_req_from_parsed_requirementÊs$ r¢)NNFNFF)NNFNFNF)NFNF)FNF)HÚ__doc__Úloggingr8r)Zpip._vendor.packaging.markersrZ"pip._vendor.packaging.requirementsrrZ pip._vendor.packaging.specifiersrZpip._vendor.pkg_resourcesrrÚpip._internal.exceptionsrÚpip._internal.models.indexr r Úpip._internal.models.linkr Úpip._internal.models.wheelr Úpip._internal.pyprojectr Zpip._internal.req.req_installrÚpip._internal.utils.deprecationrÚpip._internal.utils.filetypesrÚpip._internal.utils.miscrrÚpip._internal.utils.typingrÚpip._internal.utils.urlsrÚpip._internal.vcsrrÚtypingrrrrrrZpip._internal.req.req_filerÚ__all__Ú getLoggerr^rSÚ _operatorsÚkeysr�r'r0r3r rWÚobjectrXrbrrsryršrrŸr¢r%r%r%r&Ú sp                 K "]