HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/pip/_internal/req/__pycache__/constructors.cpython-310.pyc
o

��h�G�
@s"dZddlmZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZddl
mZmZddlmZdd	lmZdd
lmZmZddlmZddlmZdd
lmZddlmZddlm Z ddl!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(m)Z)gd�Z*e�+e,�Z-ej.�/�Z0dgdd�Z1dhdd�Z2did#d$�Z3djd'd(�Z4dkd+d,�Z5dld-d.�Z6e
d/d0�Gd1d2�d2��Z7dmd3d4�Z8	dndd5ddd5d5d5dd6�dodGdH�Z9dpdJdK�Z:dqdLdM�Z;drdOdP�Z<	dndd5ddd5dd5ddQ�dsdSdT�Z=		5		5dtdudWdX�Z>	5		5	dvdwd[d\�Z?dxd`da�Z@dydbdc�ZAdzdedf�ZBdS){a~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.
�)�annotationsN)�
Collection)�	dataclass)�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�str�return�tuple[str, str | None]cCs<t�d|�}d}|r|�d�}|�d�}||fS|}||fS)Nz^(.+)(\[[^\]]+\])$��)�re�match�group)r�m�extras�path_no_extras�r%�I/usr/local/lib/python3.10/dist-packages/pip/_internal/req/constructors.py�
_strip_extras.s

�r'r#�
str | None�set[str]cCs|st�Std|���jS)N�placeholder)�setr�lowerr#)r#r%r%r&�convert_extras:sr-�reqr�
new_extrascCs�tjdt|�tjd�}|dusJd|�d���|�d�}|�d�}|dur)|dus1Jd|�d���d	�|r<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[{}]�,�)	r�	fullmatchr�ASCIIr!�format�join�sortedr)r.r/r �pre�postr#r%r%r&�_set_requirement_extras@s�

�


�r;�editable_req� tuple[str | None, str, set[str]]cCs�|}t|�\}}tj�|�rt|�}|���d�r2t|�j}|r,||t	d|���j
fS||t�fStD]}|���|�d��rI|�d|��}nq4t|�}|j
sad�tj�}t|�d|�d���|j}|sntd|�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]
    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).z'Could not detect requirement name for 'z1', please specify one with #egg=your_package_name)r'�osr�isdirrr,�
startswithr�egg_fragmentrr#r+r�is_vcsr7�all_schemesr	)r<�url�
url_no_extrasr#�package_name�version_control�link�backendsr%r%r&rYs>
����
�r�filename�NonecCs�t|ddd��E}dd�dd�|D�D�}|D]-}d|vr%|d|�d��}|�d	�r7|dd
���t|d�}t|�Wd�dSWd�dS1sOwYdS)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>�s���
�z2check_first_requirement_in_file.<locals>.<genexpr>css�|]}|��VqdS�N)�striprRr%r%r&rU�s�z #N�\���r3)�open�find�endswithrW�nextr)rL�f�linesrTr%r%r&�check_first_requirement_in_file�s	�
�"�r`cCs^tj�|�sd|�d�Sd}zt|�Wnty$t�d|�Y|Sw|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	���reT)�frozenc@s.eZdZUded<ded<ded<ded<d	S)
�RequirementPartszRequirement | None�requirementzLink | NonerJz
Marker | None�markersr)r#N)�__name__�
__module__�__qualname__�__annotations__r%r%r%r&rg�s

rgc
Csjt|�\}}}|dur(zt|�}Wnty'}z
td|�d|����d}~wwd}t|�}t||d|�S)N�Invalid requirement: �: )rrrr	rrg)r<�namerF�extras_overrider.�excrJr%r%r&�parse_req_from_editable�s��rsF)�
use_pep517�isolated�global_options�hash_options�
constraint�
user_supplied�permit_editable_wheels�config_settings�
comes_from�InstallRequirement | str | Nonert�bool | Noneru�boolrv�list[str] | Nonerw�dict[str, list[str]] | Nonerxryrzr{�!dict[str, str | list[str]] | NonercCs0t|�}
t|
j||d||
j||||||	|
jd�
S)NT)r|ry�editablerzrJrxrtrurvrwr{r#)rsrrhrJr#)r<r|rtrurvrwrxryrzr{�partsr%r%r&r�s 
�rrpcCs>tjj|vrdStjjdurtjj|vrdS|�d�rdSdS)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)rpr%r%r&�_looks_like_paths

r�cCs�t|�rtj�|�rt|�rt|�Std|�d���t|�s dStj�|�r*t|�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�@rrrzARequirement %r looks like a filename, but the file does not exist)
r�r@rrArrr	r�isfile�split�lenrb�warning)rrp�urlreq_partsr%r%r&�_get_url_from_paths$	
��r��line_sourcecs\t|�rd}nd}||vr#|�|d�\}}|��}|sd}nt|�}nd}|��}d}tj�tj�|��}d}d}t|�rBt|�}nt	|�\}	}t
|	|�}
|
durUt|
�}|r�|jdkrrt�
d|j�rrtttj�tj�|j����}|jr�t|j�}|j�d|j��}n|j}n|}t|�}d�fd
d��d�fdd�}
|dur�|
|�}nd}t||||�S)Nz; �;r�filez\.\./z==�textrrcs�s|S|�d��d�S)Nz (from �)r%)r�)r�r%r&�with_sourceesz(parse_req_from_line.<locals>.with_source�
req_as_stringrc
s�zt��WStyK}z:tjj�vrd}|t��7}nd�vr.t�fdd�tD��s.d}nd}�d��d|���}|rC|d	|��7}t|��d}~ww)
NzIt looks like a path.�=c3s�|]}|�vVqdSrVr%)rS�op�r�r%r&rUqs�
�zAparse_req_from_line.<locals>._parse_req_string.<locals>.<genexpr>z,= is not a valid operator. Did you mean == ?r3rnroz
Hint: )	rrr@rr�re�any�	operatorsr	)r�rr�add_msgrd)r�r�r&�_parse_req_stringjs"
���z.parse_req_from_line.<locals>._parse_req_string)r�rrr)r�rrr)rr�rWrr@r�normpath�abspathrr'r��schemer�searchrFr�is_wheelr
rLrp�versionrCr-rg)rpr��
marker_sep�markers_as_stringrir�rrJ�extras_as_string�prF�wheelr#r�r.r%)r�r�r&�parse_req_from_line5sH




r�)rtrurvrwrxr�ryr{�str | InstallRequirement | NonecCs2t||�}
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.
    )
rJrirtrurvrwr{rxr#ry)r�rrhrJrir#)rpr|rtrurvrwrxr�ryr{r�r%r%r&r�s
�r�
req_string�InstallRequirement | Nonec
Cs�zt|�}Wnty}z
td|�d|����d}~wwtjtjg}|jr=|r=|jr=|jj|vr=td|j	�d|�d���t
|||||d�S)NrnrozZPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI.
z depends on � )rurtry)rrr	r
�file_storage_domainrrFrJ�netlocrpr)r�r|rurtryr.rr�domains_not_allowedr%r%r&�install_req_from_req_string�s<����������r��
parsed_reqrcCsv|jrt|j|j||j|||d�}|St|j|j|||jr$|j�dg�ng|jr/|j�di�ni|j|j||d�
}|S)N)r|rtrxruryr{rv�hashes)	r|rtrurvrwrxr�ryr{)	�is_editablerrhr|rxr�options�getr�)r�rurtryr{r.r%r%r&�#install_req_from_parsed_requirement�s4����r�rJr�ireqc
Cs2t|j|j|j||j|j|j|j|j|j	|j
d�S)N)r.r|r�rJrirtrurvrwr{ry)rr.r|r�rirtrurvrwr{ry)rJr�r%r%r&�install_req_from_link_and_ireq�s�r�cCsRt|jdur
t|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.r|r�rJrirtrurvrwrxr#r{ryrz)rr.r;r+r�rJrirtrurvrwrxr{ryrz)r�r%r%r&�install_req_drop_extras	s �r��Collection[str]cCsBt�|�}h|j�|�|_|jdurt|j|j�|_|Sd|_|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_extras#s

����r�)rrrr)r#r(rr))r.rr/r)rr)r<rrr=)rLrrrM)r.rrr)r<rrrgrV)r<rr|r}rtr~rurrvr�rwr�rxrryrrzrr{r�rr)rprrr)rrrprrr()rprr�r(rrg)rprr|r�rtr~rurrvr�rwr�rxrr�r(ryrr{r�rr)NFNF)r�rr|r�rurrtr~ryrrr)FNFN)r�rrurrtr~ryrr{r�rr)rJrr�rrr)r�rrr)r�rr#r�rr)C�__doc__�
__future__rr��loggingr@r�collections.abcr�dataclassesr�pip._vendor.packaging.markersr�"pip._vendor.packaging.requirementsrr� pip._vendor.packaging.specifiersr�pip._internal.exceptionsr	�pip._internal.models.indexr
r�pip._internal.models.linkr�pip._internal.models.wheelr
�pip._internal.req.req_filer�pip._internal.req.req_installr�pip._internal.utils.filetypesr�pip._internal.utils.miscr�pip._internal.utils.packagingr�pip._internal.utils.urlsr�pip._internal.vcsrr�__all__�	getLoggerrjrb�
_operators�keysr�r'r-r;rr`rergrsrr�r�r�rr�r�r�r�r�r%r%r%r&�<module>s�







7

��
 

"Q��'�(�
(