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/local/lib/python3.7/site-packages/pip/_internal/req/__pycache__/constructors.cpython-37.pyc
B

L��gJJ�@s�dZddlZddlZddlZddlZddlmZmZmZm	Z	m
Z
mZmZddl
mZddlmZmZddlmZddlmZddlmZmZdd	lmZdd
lmZddlmZddlm Z dd
l!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*m+Z+dddgZ,e�-e.�Z/ej0�1�Z2e3ee3e	e3fd�dd�Z4e	e3e
e3d�dd�Z5ee
e3ed�dd�Z6e3ee	e3e3e
e3fd�dd�Z7e3dd �d!d"�Z8e3e3d#�d$d%�Z9Gd&d'�d'�Z:e3e:d�d(d)�Z;dIdd*ddd*d*d*dd+�e3e	ee e3fe	e<e<e	ee3e	ee3ee3fe<e<e<e	ee3ee3ee3ffe d,�d-d�Z=e3e<d.�d/d0�Z>e3e3e	e3d1�d2d3�Z?e3e	e3e:d4�d5d6�Z@dJdd*ddd*dd*dd7�e3e	ee3e fe	e<e<e	ee3e	ee3ee3fe<e	e3e<e	ee3ee3ee3ffe d8�d9d�ZAdKe3e	e e<e	e<e<e d:�d;d<�ZBdLee<e	e<e<e	ee3ee3ee3ffe d=�d>d?�ZCee e d@�dAdB�ZDe e dC�dDdE�ZEe ee3e dF�dGdH�ZFdS)Ma~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)�
Collection�Dict�List�Optional�Set�Tuple�Union)�Marker)�InvalidRequirement�Requirement)�	Specifier)�InstallationError)�PyPI�TestPyPI)�Link)�Wheel)�ParsedRequirement)�InstallRequirement)�is_archive_file)�is_installable_dir)�get_requirement)�path_to_url)�is_url�vcs�install_req_from_editable�install_req_from_line�parse_editable)�path�returncCs6t�d|�}d}|r*|�d�}|�d�}n|}||fS)Nz^(.+)(\[[^\]]+\])$��)�re�match�group)r�m�extras�path_no_extras�r'�B/tmp/pip-unpacked-wheel-hv55ucu3/pip/_internal/req/constructors.py�
_strip_extras+s
r))r%rcCs|s
t�Std|���jS)N�placeholder)�setr�lowerr%)r%r'r'r(�convert_extras7sr-)�req�
new_extrasrcCs�tjdt|�tjd�}|dk	s.td|�d���|�d�}|�d�}|dk	rR|dk	sbtd|�d���|rxd	d
�t|��nd}t|�|�|���S)z�
    Returns a new requirement based on the given one, with the supplied extras. If the
    given requirement already has extras those are replaced (or dropped if no new extras
    are given).
    z([\w\t .-]+)(\[[^\]]*\])?(.*))�flagsNzregex match on requirement z! failed, this should never happenr�z&regex group selection for requirement z[%s]�,�)	r!�	fullmatch�str�ASCII�AssertionErrorr#�join�sortedr)r.r/r"�pre�postr%r'r'r(�_set_requirement_extras=s



r<)�editable_reqrcCs�|}t|�\}}tj�|�r$t|�}|���d�rdt|�j}|rX||t	d|���j
fS||t�fSx0tD](}|���|�d��rj|�d|��}PqjWt|�}|j
s�d�tj�}t|�d|�d���|j}|s�td�|���||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]
    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)�osr�isdirrr,�
startswithr�egg_fragmentrr%r+r�is_vcsr8�all_schemesr
�format)r=�url�
url_no_extrasr%�package_name�version_control�link�backendsr'r'r(rVs4

)�filenamerc	Cs�t|ddd��t}dd�dd�|D�D�}xT|D]L}d|krL|d|�d��}|�d	�rp|dd
���t|d�}t|�dSWWdQRXdS)a Check if file is parsable as a requirements file.

    This is heavily based on ``pkg_resources.parse_requirements``, but
    simplified to just check the first meaningful line.

    :raises InvalidRequirement: If the first meaningful line cannot be parsed
        as an requirement.
    zutf-8�ignore)�encoding�errorscss |]}|r|�d�s|VqdS)�#N)rB)�.0�liner'r'r(�	<genexpr>�sz2check_first_requirement_in_file.<locals>.<genexpr>css|]}|��VqdS)N)�strip)rRrSr'r'r(rT�sz #N�\���r3)�open�find�endswithrU�nextr)rM�f�linesrSr'r'r(�check_first_requirement_in_file�s	

r^)r.rcCs^tj�|�sd|�d�Sd}yt|�Wn tk
rHt�d|�YnX|d|�d�7}|S)z�Returns helpful msg in case requirements file does not exist,
    or cannot be parsed.

    :params req: Requirements file path
    z File 'z' does not exist.z The path does exist. z&Cannot parse '%s' as requirements filezThe argument you provided (zx) appears to be a requirements file. If that is the case, use the '-r' flag to install the packages specified within it.)r@r�existsr^r
�logger�debug)r.�msgr'r'r(�deduce_helpful_msg�srcc@s0eZdZeeeeeeeed�dd�Z	dS)�RequirementParts)�requirementrK�markersr%cCs||_||_||_||_dS)N)rerKrfr%)�selfrerKrfr%r'r'r(�__init__�szRequirementParts.__init__N)
�__name__�
__module__�__qualname__rrrr	rr5rhr'r'r'r(rd�srdcCsdt|�\}}}|dk	rJyt|�}WqNtk
rFtd|�d���YqNXnd}t|�}t||d|�S)NzInvalid requirement: '�')rrr
r
rrd)r=�namerG�extras_overrider.rKr'r'r(�parse_req_from_editable�sroF)�
use_pep517�isolated�global_options�hash_options�
constraint�
user_supplied�permit_editable_wheels�config_settings)r=�
comes_fromrprqrrrsrtrurvrwrcCs0t|�}
t|
j||d||
j||||||	|
jd�
S)NT)rxru�editablervrKrtrprqrrrsrwr%)rorrerKr%)r=rxrprqrrrsrtrurvrw�partsr'r'r(r�s
)rmrcCs>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)r@r�sep�altseprB)rmr'r'r(�_looks_like_paths

r~)rrmrcCs�t|�r4tj�|�r4t|�r$t|�Std|�d���t|�s@dStj�|�rTt|�S|�	dd�}t
|�dkr|t|d�s|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�@rr rzARequirement %r looks like a filename, but the file does not exist)
r~r@rrArrr
r�isfile�split�lenr`�warning)rrm�urlreq_partsr'r'r(�_get_url_from_paths 	r�)rm�line_sourcercsnt|�rd}nd}||krF|�|d�\}}|��}|s<d}qJt|�}nd}|��}d}tj�tj�|��}d}d}t|�r�t|�}n&t	|�\}	}t
|	|�}
|
dk	r�t|
�}|�r|jdkr�t�
d|j�r�tttj�tj�|j����}|j�rt|j�}|j�d|j��}n|j}n|}t|�}ttd��fdd	��ttd
��fdd�}
|dk	�r\|
|�}nd}t||||�S)
Nz; �;r�filez\.\./z==)�textrcs�s|S|�d��d�S)Nz (from �)r')r�)r�r'r(�with_sourcehsz(parse_req_from_line.<locals>.with_source)�
req_as_stringrcs�yt��}Wn�tk
r�tjj�kr:d}|t��7}n(d�kr^t�fdd�tD��s^d}nd}�d����}|r�|d|��7}t|��Yn8Xx4|j	D]*}t
|�}|�d	�r�d
|�d�}t|��q�W|S)NzIt looks like a path.�=c3s|]}|�kVqdS)Nr')rR�op)r�r'r(rTuszAparse_req_from_line.<locals>._parse_req_string.<locals>.<genexpr>z,= is not a valid operator. Did you mean == ?r3zInvalid requirement: z
Hint: �]zExtras after version 'z'.)rr
r@rr|rc�any�	operatorsr
�	specifierr5rZ)r�r.�add_msgrb�spec�spec_str)r�)r�r(�_parse_req_stringms(

z.parse_req_from_line.<locals>._parse_req_string)rr�rUr	r@r�normpath�abspathrr)r��schemer!�searchrGr�is_wheelrrMrm�versionrCr-r5rrd)rmr��
marker_sep�markers_as_stringrfr�rrK�extras_as_string�prG�wheelr%r�r.r')r�r�r(�parse_req_from_line8sH





r�)rprqrrrsrtr�rurw)rmrxrprqrrrsrtr�rurwrcCs2t||�}
t|
j||
j|
j|||||	||
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.
    )
rKrfrprqrrrsrwrtr%ru)r�rrerKrfr%)rmrxrprqrrrsrtr�rurwrzr'r'r(r�s
)�
req_stringrxrqrprurcCs�yt|�}Wn$tk
r0td|�d���YnXtjtjg}|jrr|rr|jrr|jj|krrtd|j	�d|�d���t
|||||d�S)NzInvalid requirement: 'rlzZPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI.
z depends on � )rqrpru)rr
r
r�file_storage_domainrrGrK�netlocrmr)r�rxrqrprur.�domains_not_allowedr'r'r(�install_req_from_req_string�s$r�)�
parsed_reqrqrprurwrcCst|jr$t|j|j||j|||d�}nLt|j|j|||jrF|j�dg�ng|jr\|j�di�ni|j|j||d�
}|S)N)rxrprtrqrurwrr�hashes)	rxrprqrrrsrtr�rurw)	�is_editablerrerxrtr�options�getr�)r�rqrprurwr.r'r'r(�#install_req_from_parsed_requirement�s,
r�)rK�ireqrc
Cs2t|j|j|j||j|j|j|j|j|j	|j
d�S)N)r.rxryrKrfrprqrrrsrwru)rr.rxryrfrprqrrrsrwru)rKr�r'r'r(�install_req_from_link_and_ireqsr�)r�rcCsRt|jdk	rt|jt��nd||j|j|j|j|j|j	|j
|jg|j|j
|jd�S)z�
    Creates a new InstallationRequirement using the given template but without
    any extras. Sets the original requirement as the new one's parent
    (comes_from).
    N)r.rxryrKrfrprqrrrsrtr%rwrurv)rr.r<r+ryrKrfrprqrrrsrtrwrurv)r�r'r'r(�install_req_drop_extrassr�)r�r%rcCs8t�|�}|j|�|_|jdk	r.t|j|j�nd|_|S)z�
    Returns a copy of an installation requirement with some additional extras.
    Makes a shallow copy of the ireq object.
    N)�copyr%r.r<)r�r%�resultr'r'r(�install_req_extend_extras1s

r�)N)N)NFNF)FNFN)G�__doc__r��loggingr@r!�typingrrrrrrrZpip._vendor.packaging.markersr	Z"pip._vendor.packaging.requirementsr
rZ pip._vendor.packaging.specifiersr�pip._internal.exceptionsr
�pip._internal.models.indexrr�pip._internal.models.linkr�pip._internal.models.wheelrZpip._internal.req.req_filerZpip._internal.req.req_installr�pip._internal.utils.filetypesr�pip._internal.utils.miscr�pip._internal.utils.packagingr�pip._internal.utils.urlsr�pip._internal.vcsrr�__all__�	getLoggerrir`�
_operators�keysr�r5r)r-r<rr^rcrdro�boolrr~r�r�rr�r�r�r�r�r'r'r'r(�<module>	s�$

"7Z"\^"(#