HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/lib/python3.9/site-packages/pip/_internal/req/__pycache__/constructors.cpython-39.pyc
a

?�f@�@s�dZddlZddlZddlZddlmZddlmZmZddl	m
Z
ddlmZm
Z
ddlmZddlmZmZdd	lmZdd
lmZddlmZdd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/ddl0m1Z1gd�Z2e�3e4�Z5e
j6�7�Z8dd�Z9dd�Z:dd�Z;dd�Z<dd�Z=Gd d!�d!e>�Z?d"d#�Z@d3d%d&�ZAd'd(�ZBd)d*�ZCd+d,�ZDd4d-d.�ZEd5d/d0�ZFd6d1d2�ZGdS)7a~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|�d��}|tvrdSdS)z9Return True if `name` is a considered as an archive file.�TF)r�lowerr)�nameZext�r$�B/usr/lib/python3.9/site-packages/pip/_internal/req/constructors.py�is_archive_file1sr&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_extrasGsr1cCsh|}t|�\}}tj�|�rptj�tj�|d��shd�tj�|��}t|�}tj�	|�r`|d7}t
|��t|�}|���
d�r�t|�j}|r�||td|���jfS||t�fStD](}|���
d�|��r�d�||�}q�q�d|vr�t
d	�|���|�dd
�d��}t�|��s>d�d
d�tjD��}	d�||	�}
t
|
��t|�j}|�s\t
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]
    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/z{}: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#)�.0Zbendsr$r$r%�
<listcomp>��z"parse_editable.<locals>.<listcomp>z2For --editable={}, only {} are currently supportedzZCould not detect requirement name for '{}', please specify one with #egg=your_package_name)r.�osr+�isdir�exists�join�format�abspathr
�isfilerrr"�
startswithr�egg_fragmentrr-r0r�splitZget_backend�backends)�editable_req�urlZ
url_no_extrasr-�msgZpyproject_pathZpackage_nameZversion_controlZvc_typerAZ
error_messager$r$r%r Ns`
���
����
��r cCs�d}tj�|�r�d}zLt|d��.}tt|����|d�|�7}Wd�n1sT0YWq�ty�t	j
d|dd�Yq�0n|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 ({}) 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.)r7r+r9�open�nextr�readr;r�logger�debug)�reqrD�fpr$r$r%�deduce_helpful_msg�s"��(�rOc@seZdZdd�ZdS)�RequirementPartscCs||_||_||_||_dS�N)�requirement�link�markersr-)�selfrRrSrTr-r$r$r%�__init__�szRequirementParts.__init__N)�__name__�
__module__�__qualname__rVr$r$r$r%rP�srPcCs`t|�\}}}|durFzt|�}WqJtyBtd�|���YqJ0nd}t|�}t||d|�S)N�Invalid requirement: '{}')r rrrr;rrP)rBr#rCZextras_overriderMrSr$r$r%�parse_req_from_editable�sr[FcCs^t|�}t|j||d|j||||r.|�dg�ng|r@|�dg�ng|rR|�di�ni|jd�S)NT�install_options�global_options�hashes)�
comes_from�
user_suppliedZeditablerS�
constraint�
use_pep517�isolatedr\r]�hash_optionsr-)r[rrRrS�getr-)rBr_rbrc�optionsrar`�partsr$r$r%r�s�rcCs>tjj|vrdStjjdur,tjj|vr,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)r7r+�sep�altsepr>r3r$r$r%�_looks_like_path�s
rkcCs�t|�r:tj�|�r:t|�r$t|�Stdjfit�����t	|�sFdStj�
|�rZt|�S|�dd�}t|�dkr�t|d�s�dSt
�d|�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)rkr7r+r8rrrr;�localsr&r=r@�lenrKZwarning)r+r#Zurlreq_partsr$r$r%�_get_url_from_paths(
���rocs t|�rd}nd}||vrF|�|d�\}}|��}|s<d}qJt|�}nd}|��}d�tj�tj�|��}d}d}t|�r�t|�}n&t	|�\}}t
||�}	|	dur�t|	�}|�r|jdkr�t�
d|j�r�tttj�tj�|j����}|j�rt|j�}
djfit����n|j�n|�t|�}�fdd�}�du�rzt��}
Wn�t�y�tjj�v�rrd	}|t��7}n,d
�v�r�t�fdd�tD���s�d
}nd}|d����}|�r�|d�|�7}t|��Yn@0|
jD]6}t|�}|� d��r�d�|�}d}t!||dd��q�nd}
t"|
|||�S)Nz; �;r!�filez\.\./z{wheel.name}=={wheel.version}cs�s|Sd�|��S)Nz{} (from {}))r;)�text)�line_sourcer$r%�with_source_sz(parse_req_from_line.<locals>.with_sourcezIt looks like a path.�=c3s|]}|�vVqdSrQr$)r4�op)�
req_as_stringr$r%�	<genexpr>mr6z&parse_req_from_line.<locals>.<genexpr>z,= is not a valid operator. Did you mean == ?rEzInvalid requirement: {!r}z	
Hint: {}�]zExtras after version '{}'.z+moving the extras before version specifiersz21.0)ZreplacementZgone_in)#rr@�striprr7r+�normpathr<rr.ro�schemer(�searchrCrZis_wheelr�filenamer;rmr?r1rrrirO�any�	operatorsrZ	specifier�str�endswithrrP)r#rsZ
marker_sepZmarkers_as_stringrTr+rSZextras_as_string�prCZwheelr-rtrMZadd_msgrD�specZspec_str�replacer$)rsrwr%�parse_req_from_line-sv


�


��

r�c	Csbt||�}t|j||j|j|||r.|�dg�ng|r@|�dg�ng|rR|�di�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.
    r\r]r^)
rSrTrbrcr\r]rdrar-r`)r�rrRrSrTrer-)	r#r_rbrcrfrarsr`rgr$r$r%r�s
�rcCszzt|�}Wn ty,td�|���Yn0tjtjg}|jrh|rh|jrh|jj	|vrhtd�|j
|���t|||||d�S)NrZzkPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI.
{} depends on {} )rcrbr`)rrrr;r	Zfile_storage_domainr
rCrS�netlocr#r)Z
req_stringr_rcrbr`rMZdomains_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)r_rbrarcr`)r_rbrcrfrarsr`)Zis_editablerrRr_rarrfrs)Z
parsed_reqrcrbr`rMr$r$r%�#install_req_from_parsed_requirement�s(�
�
r�)NNFNFF)NNFNFNF)NFNF)FNF)H�__doc__Zloggingr7r(Zpip._vendor.packaging.markersrZ"pip._vendor.packaging.requirementsrrZ pip._vendor.packaging.specifiersrZpip._vendor.pkg_resourcesrrZpip._internal.exceptionsrZpip._internal.models.indexr	r
Zpip._internal.models.linkrZpip._internal.models.wheelrZpip._internal.pyprojectr
Zpip._internal.req.req_installrZpip._internal.utils.deprecationrZpip._internal.utils.filetypesrZpip._internal.utils.miscrrZpip._internal.utils.typingrZpip._internal.utils.urlsrZpip._internal.vcsrr�typingrrrrrrZpip._internal.req.req_filer�__all__Z	getLoggerrWrKZ
_operators�keysr�r&r.r1r rO�objectrPr[rrkror�rr�r�r$r$r$r%�<module>sv
 

	
K�
"]�
!�
%�