Re@ @sdZddlZddlZddlZddlmZddlmZmZddl 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#rddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1dddgZ2ej3e4Z5e j6j7Z8ddZ9ddZ:ddZ;ddZ<dd Z=Gd!d"d"e>Z?d#d$Z@ddd%dd%d%d&dZAd'd(ZBd)d*ZCd+d,ZDddd%dd%dd%d-dZEdd%dd%d.d/ZFd%dd%d0d1ZGdS)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)RequirementParseErrorparse_requirements)InstallationError)PyPITestPyPI)Link)Wheel)make_pyproject_path)InstallRequirement) deprecated)ARCHIVE_EXTENSIONS)is_installable_dirsplitext)MYPY_CHECK_RUNNING) path_to_url)is_urlvcs)AnyDictOptionalSetTupleUnion)ParsedRequirementinstall_req_from_editableinstall_req_from_lineparse_editablecCs*t|dj}|tkr&dSdS)z9Return True if `name` is a considered as an archive file.TF)rlowerr)nameextr%/builddir/build/BUILDROOT/alt-python35-pip-20.2.4-5.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/pip/_internal/req/constructors.pyis_archive_file1s r'cCsOtjd|}d}|r?|jd}|jd}n|}||fS)Nz^(.+)(\[[^\]]+\])$r!)rematchgroup)pathmextraspath_no_extrasr%r%r& _strip_extras:sr0cCs$|s tStd|jjS)N placeholder)setrr"r.)r.r%r%r&convert_extrasGsr3c Cs|}t|\}}tjj|rtjjtjj|dsdjtjj|}t|}tjj |r|d7}t |t |}|j j drt|j}|r||td|j jfS||tfSx?tD]7}|j j dj|rdj||}PqWd|krct d j||jdd d j }tj|sd jd dtjD} dj|| } t | t|j}|st dj|||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.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|]}|jdqS)z+URL)r#).0bendsr%r%r& s z"parse_editable..z2For --editable={}, only {} are currently supportedzZCould not detect requirement name for '{}', please specify one with #egg=your_package_name)r0osr,isdirexistsjoinformatabspathr isfilerrr" startswithr egg_fragmentrr.r2rsplit get_backendbackends) editable_requrl url_no_extrasr.msgpyproject_path package_nameversion_controlvc_typerC error_messager%r%r&r NsN !         cCsd}tjj|rd}yFt|d0}tt|j|dj|7}WdQRXWqtk rt j d|ddYqXn|d j|7}|S) zReturns helpful msg in case requirements file does not exist, or cannot be parsed. :params req: Requirements file path z It does exist.rzThe 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 fileexc_infoTz File '{}' does not exist.) r8r,r:opennextrreadr<rloggerdebug)reqrGfpr%r%r&deduce_helpful_msgs rWc@seZdZddZdS)RequirementPartscCs(||_||_||_||_dS)N) requirementlinkmarkersr.)selfrYrZr[r.r%r%r&__init__s   zRequirementParts.__init__N)__name__ __module__ __qualname__r]r%r%r%r&rXs rXc Cst|\}}}|dk r^yt|}Wqdtk rZtdj|YqdXnd}t|}t||d|S)NzInvalid requirement: '{}')r rrrr<r rX)rDr#rEextras_overriderUrZr%r%r&parse_req_from_editables   rbFcCst|}t|jd|d|ddd|jd|d|d|d |r]|jd gngd |r{|jd gngd |r|jd inid |j S)N comes_from user_suppliededitableTrZ constraint use_pep517isolatedinstall_optionsglobal_options hash_optionshashesr.)rbrrYrZgetr.)rDrcrgrhoptionsrfrdpartsr%r%r&rs   cCsUtjj|krdStjjdk r>tjj|kr>dS|jdrQdSdS)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,sepaltsepr?)r#r%r%r&_looks_like_paths $rscCst|rLtjj|rLt|r4t|Stdjtt |s\dStjj |rxt|S|j dd}t |dkrt|d rdSt 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>rAlenrSwarning)r,r# urlreq_partsr%r%r&_get_url_from_path s"     #rycst|rd}nd}||kri|j|d\}}|j}|sZd}qot|}nd}|j}dtjjtjj|}d}d}t|rt|}n9t |\}}t ||} | dk rt| }|r|j dkrVt j d|jrVtttjjtjj|j}|jrt|j} djtq|jn|t|} fdd} dk ryt} Wntk rtjjkr d }|t7}n;d kr?tfd d tD r?d }nd}| dj}|rs|dj|7}t|YqXx`| jD]L}t|}|j drdj|}d}t!|d|ddqWnd} t"| ||| S)Nz; ;r!filez\.\./z{wheel.name}=={wheel.version}css |Sdj|S)Nz {} (from {}))r<)text) line_sourcer%r& with_source_sz(parse_req_from_line..with_sourcezIt looks like a path.=c3s|]}|kVqdS)Nr%)r5op) 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 specifiers replacementgone_inz21.0)#rrAstriprr8r,normpathr=r r0ryschemer)searchrEris_wheelr filenamer<rur@r3rrrqrWany operatorsr specifierstrendswithrrX)r#r} marker_sepmarkers_as_stringr[r,rZextras_as_stringprEwheelr.r~rUadd_msgrGspecspec_strreplacer%)r}rr&parse_req_from_line-sp         $*         rc Cst||}t|j|d|jd|jd|d|d|rT|jdgngd|rr|jdgngd|r|jdinid |d |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. rZr[rgrhrirjrkrlrfr.rd)rrrYrZr[rmr.) r#rcrgrhrnrfr}rdror%r%r&rs  cCsyt|}Wn'tk r9tdj|YnXtjtjg}|jr|r|jr|jj |krtdj|j |t ||d|d|d|S)NzInvalid requirement: '{}'zkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI. {} depends on {} rhrgrd) rrrr<r file_storage_domainr rErZnetlocr#r) req_stringrcrhrgrdrUdomains_not_allowedr%r%r&install_req_from_req_strings"  rcCs|jr?t|jd|jd|d|jd|d|}nEt|jd|jd|d|d|jd|jd|jd|}|S)Nrcrgrfrhrdrnr}) is_editablerrYrcrfrrnr}) parsed_reqrhrgrdrUr%r%r&#install_req_from_parsed_requirements$           r)H__doc__loggingr8r)Zpip._vendor.packaging.markersrZ"pip._vendor.packaging.requirementsrrZ pip._vendor.packaging.specifiersrZpip._vendor.pkg_resourcesrrpip._internal.exceptionsrpip._internal.models.indexr r pip._internal.models.linkr pip._internal.models.wheelr pip._internal.pyprojectr Zpip._internal.req.req_installrpip._internal.utils.deprecationrpip._internal.utils.filetypesrpip._internal.utils.miscrrpip._internal.utils.typingrpip._internal.utils.urlsrpip._internal.vcsrrtypingrrrrrrZpip._internal.req.req_filer__all__ getLoggerr^rS _operatorskeysrr'r0r3r rWobjectrXrbrrsryrrrrr%r%r%r& sp   .   K    " ]