HEX
Server: nginx/1.24.0
System: Linux webserver 6.8.0-85-generic #85-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 18 15:26:59 UTC 2025 x86_64
User: wpuser (1002)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pip/_internal/req/__pycache__/constructors.cpython-312.pyc
�

��hJJ��x�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+gd�Z,ejZe.�Z/ej`jc�Z2de3dee3e	e3ffd�Z4de	e3de
e3fd�Z5dede
e3defd�Z6de3dee	e3e3e
e3ffd�Z7de3ddfd�Z8de3de3fd�Z9Gd �d!�Z:de3de:fd"�Z;	d?dd#ddd#d#d#dd$�de3d%e	ee e3fd&e	e<d'e<d(e	ee3d)e	ee3ee3fd*e<d+e<d,e<d-e	ee3ee3ee3ffde fd.�Z=d/e3de<fd0�Z>de3d/e3de	e3fd1�Z?d/e3d2e	e3de:fd3�Z@	d?dd#ddd#dd#dd4�d/e3d%e	ee3e fd&e	e<d'e<d(e	ee3d)e	ee3ee3fd*e<d2e	e3d+e<d-e	ee3ee3ee3ffde fd5�ZA				d@d6e3d%e	e d'e<d&e	e<d+e<de fd7�ZB				dAd8ed'e<d&e	e<d+e<d-e	ee3ee3ee3ffde fd9�ZCd:ed;e de fd<�ZDd;e de fd=�ZEd;e dee3de fd>�ZFy)Ba~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�returnc��tjd|�}d}|r&|jd�}|jd�}||fS|}||fS)Nz^(.+)(\[[^\]]+\])$��)�re�match�group)r�m�extras�path_no_extrass    �@/usr/lib/python3/dist-packages/pip/_internal/req/constructors.py�
_strip_extrasr*+sT��
���&��-�A�
�F���������������6�!�!����6�!�!�r'c�f�|s
t�Std|j�z�jS)N�placeholder)�setr�lowerr')r's r)�convert_extrasr07s(����u���=�6�<�<�>�9�:�A�A�Ar+�req�
new_extrasc�@�tjdt|�tj��}|�Jd|�d���|j	d�}|j	d�}|�|�Jd|�d���|rdd	jt
|��znd
}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 .-]+)(\[[^\]]*\])?(.*))�flagszregex match on requirement z! failed, this should never happenr!�z&regex group selection for requirement z[%s]�,�)r#�	fullmatch�str�ASCIIr%�join�sortedr)r1r2r$�pre�postr's      r)�_set_requirement_extrasr?=s���&(�\�\�(��C���h�h�	&�E�	��L�	$�S�E�)J�K�L�����Q��C��+�+�a�.�D���D�,�W�	/��u�4U�V�W�,�;E�&�3�8�8�F�:�$6�7�7�2�F��#��v�h�t�f�-�.�.r+�editable_reqc��|}t|�\}}tjj|�rt	|�}|j�j
d�rMt|�j}|r)||td|j�z�jfS||t�fStD]-}|j�j
|�d��s�&|�d|��}nt|�}|js0djtj�}t!|�d|�d���|j}|st!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]
    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_vcsr;�all_schemesr�format)r@�url�
url_no_extrasr'�package_name�version_control�link�backendss        r)rrVs[���C�*�#�.��M�6�	�w�w�}�}�]�#�#�M�2�
�����'�'��0��M�*�7�7������
����� >�?�F�F��
� ����5�5�����9�9�;�!�!�_�$5�Q�"7�8�$�%�Q�s�e�,�C���
��9�D��;�;��9�9�S�_�_�-����n��'�j��
,�
�	
��$�$�L���
*�*0�&��*>�
�	
���c�e�#�#r+�filenamec�4�t|dd��5}d�d�|D�D�}|D]_}d|vr|d|jd�}|jd�r |dd	j�t	|d
�z}t|�ddd�y	ddd�y#1swYyxYw)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�errorsc3�FK�|]}|r|jd�s|���y�w)�#N)rF��.0�lines  r)�	<genexpr>z2check_first_requirement_in_file.<locals>.<genexpr>�s&����
���D�O�O�C�0�
�
�s�!c3�<K�|]}|j����y�w�N)�striprXs  r)r[z2check_first_requirement_in_file.<locals>.<genexpr>�s����4�$�����4�s�z #N�\���r7)�open�find�endswithr^�nextr)rQ�f�linesrZs    r)�check_first_requirement_in_filerg�s���
�h���	:��a�
�4�!�4�
���	�D��t�|��-�d�i�i��o�.���}�}�T�"��C�R�y���(�4��r�?�:������!��	����s�A+B�B�Bc���tjj|�sd|�d�Sd}	t|�|d|�d�z
}|S#t$rt
j
d|�Y|SwxYw)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. zThe 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.z&Cannot parse '%s' as requirements file)rDr�existsrgr�logger�debug)r1�msgs  r)�deduce_helpful_msgrm�s����7�7�>�>�#�����.�/�/�
"�C�
�'��,�	���u�1�
2�	
���J���D����=�s�C��J�D�s�?�A"�!A"c	�<�eZdZdeedeedeedeefd�Z	y)�RequirementParts�requirementrO�markersr'c�<�||_||_||_||_yr])rprOrqr')�selfrprOrqr's     r)�__init__zRequirementParts.__init__�s!��'�����	������r+N)
�__name__�
__module__�__qualname__rrrr
rr9rt�r+r)roro�s?��
��k�*�
��t�n�
��&�!�	
�
�C��
r+roc��t|�\}}}|�
	t|�}nd}t	|�}t||d|�S#t$rtd|�d���wxYw)N�Invalid requirement: '�')rrrrrro)r@�namerK�extras_overrider1rOs      r)�parse_req_from_editabler~�sr��!/��!=��D�#����	F�)4�T�):�C�����9�D��C��t�_�=�=��"�	F�#�&<�T�F�!�$D�E�E�	F�s	�:�AF)�
use_pep517�isolated�global_options�hash_options�
constraint�
user_supplied�permit_editable_wheels�config_settings�
comes_fromrr�r�r�r�r�r�r�c��t|�}
t|
j||d||
j||||||	|
j��
S)NT)r�r��editabler�rOr�rr�r�r�r�r')r~rrprOr')r@r�rr�r�r�r�r�r�r��partss           r)rr�sP��
$�L�1�E��
����#��5�
�Z�Z����%�!�'��|�|��r+r|c���tjj|vrytjj�tjj|vry|j	d�ryy)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).
    T�.F)rDr�sep�altseprF)r|s r)�_looks_like_pathr�sI��
�w�w�{�{�d���	�w�w�~�~�!�b�g�g�n�n��&<�����s���r+c��t|�rDtjj|�r%t	|�rt|�St
d|�d���t|�sytjj|�rt|�S|jdd�}t|�dk\rt|d�sytjd|�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�@r!r"rzARequirement %r looks like a filename, but the file does not exist)
r�rDrrErrrr�isfile�split�lenrj�warning)rr|�urlreq_partss   r)�_get_url_from_pathr�s������"�'�'�-�-��"5��d�#��t�$�$� ����!*�
*�
�	
��4� ��	�w�w�~�~�d���4� � ��:�:�c�1�%�L�
�<��A��&6�|�A��&G��
�N�N�K����t��r+�line_sourcec	����t|�rd}nd}||vr6|j|d�\}}|j�}|sd}nt|�}nd}|j�}d}tj
j
tj
j|��}d}d}t|�rt|�}n't|�\}	}t|	|�}
|
�t|
�}|r�|jdk(rxtjd|j�rXtttj
j
tj
j|j
����}|j r1t#|j$�}|j&�d|j(��}n|j*}n|}t-|�}dt.dt.f�fd	��d
t.dt0f�fd�}
|�	|
|�}nd}t3||||�S)Nz; �;r!�filez\.\./z==�textrc����s|S|�d��d�S)Nz (from �)rx)r�r�s �r)�with_sourcez(parse_req_from_line.<locals>.with_sourcehs�����K���w�{�m�1�-�-r+�
req_as_stringc����	t��}|jD]/}t|�}|jd�s� d|�d�}t	|��|S#t
$rotjj�vrd}|t��z
}n!d�vrt�fd�tD��sd}nd}�d	����}|r|d
|��z
}t	|��wxYw)N�]zExtras after version 'z'.zIt looks like a path.�=c3�&�K�|]}|�v���
y�wr]rx)rY�opr�s  �r)r[zAparse_req_from_line.<locals>._parse_req_string.<locals>.<genexpr>ts�����2�(*��m�#�2�s�z,= is not a valid operator. Did you mean == ?r7zInvalid requirement: z
Hint: )r�	specifierr9rcrrrDrr�rm�any�	operators)r�r1�spec�spec_strrl�add_msgr�s`     �r)�_parse_req_stringz.parse_req_from_line.<locals>._parse_req_stringms����	1�!�-�0�C�(�
�
�
1���t�9���$�$�S�)�2�8�*�B�?�C�+�C�0�0�	
1�
�
��1"�
	)��w�w�{�{�m�+�1���-�m�<�<���
�%�c�2�.7�2�/�I����� 5�m�5F�G�H�C����'��+�+��#�C�(�(�
	)�s�A�A8C)rr�r^r
rDr�normpath�abspathrr*r��schemer#�searchrKr�is_wheelrrQr|�versionrGr0r9rro)r|r��
marker_sep�markers_as_stringrqr�rrO�extras_as_string�prK�wheelr'r�r1r�s `             @r)�parse_req_from_liner�8s����
�d�|��
��
��T��"&�*�*�Z��";����-�3�3�5�� ��G��.�/�G����:�:�<�D��M�
�7�7���B�G�G�O�O�D�1�2�D��D���
�d�|��D�z��+�D�1���� ��D�)���?���9�D���;�;�&� �R�Y�Y�x����%B���B�G�G�$4�$4�R�W�W�_�_�T�Y�Y�5O�$P�Q�R�D��=�=��$�-�-�(�E�$�z�z�l�"�U�]�]�O�<�M�!�-�-�M��
�
�,�
-�F�.�#�.�#�.�
�����:� �%6�}�%E�����C��w��7�7r+)rr�r�r�r�r�r�r�c��t||�}
t|
j||
j|
j|||||	||
j
|��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.
    )
rOrqrr�r�r�r�r�r'r�)r�rrprOrqr')r|r�rr�r�r�r�r�r�r�r�s           r)rr�sS��&
 ��k�2�E��
����
�Z�Z��
�
���%�!�'���|�|�#�
�
r+�
req_stringc�N�	t|�}tjt
jg}|jrB|r@|jr4|jj|vrtd|j�d|�d���t|||||��S#t$rtd|�d���wxYw)Nrzr{zZPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI.
z depends on � )r�rr�)rrrr�file_storage_domainrrKrO�netlocr|r)r�r�r�rr�r1�domains_not_alloweds       r)�install_req_from_req_stringr��s���H��j�)��
	
� � ��$�$���
	�����O�O��O�O�"�"�&9�9� �
3�����|�C�5��
3�
�	
������#����)�H��"8���A� F�G�G�H�s�B�B$�
parsed_reqc��|jr2t|j|j||j|||��}|St|j|j|||jr|jjdg�ng|jr|jjdi�ni|j|j||��
}|S)N)r�rr�r�r�r�r��hashes)	r�rr�r�r�r�r�r�r�)	�is_editablerrpr�r�r�options�getr�)r�r�rr�r�r1s      r)�#install_req_from_parsed_requirementr��s������'��"�"�!�,�,�!�!�,�,��'�+�
��:�J�%$��"�"�!�,�,�!���%�%��"�"�&�&�'7��<��9C�8J�8J�
�"�"�&�&�x��4�PR�!�,�,�"�.�.�'�+�!
��$�Jr+rO�ireqc
��t|j|j|j||j|j
|j|j|j|j|j��S)N)r1r�r�rOrqrr�r�r�r�r�)rr1r�r�rqrr�r�r�r�r�)rOr�s  r)�install_req_from_link_and_ireqr�sb����H�H��?�?����
�����?�?�����*�*��&�&��,�,��(�(��r+c�d�t|j�t|jt��nd||j|j
|j|j|j|j|j|jg|j|j|j��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)r1r�r�rOrqrr�r�r�r�r'r�r�r�)rr1r?r.r�rOrqrr�r�r�r�r�r�r�)r�s r)�install_req_drop_extrasr�s����8<���8L�#�D�H�H�c�e�4�RV�����
�Y�Y�����?�?�����*�*��&�&��?�?���,�,��(�(�#�:�:�!�r+c���tj|�}h|j�|�|_|j�'t|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'r1r?)r�r'�results   r)�install_req_extend_extrasr�1sg���Y�Y�t�_�F�+�d�k�k�+�F�+�F�M��8�8��	 ����&�-�-�8��J�
�M���J�
�Mr+r])NFNF)FNFN)G�__doc__r��loggingrDr#�typingrrrrrrr	�pip._vendor.packaging.markersr
�"pip._vendor.packaging.requirementsrr� pip._vendor.packaging.specifiersr
�pip._internal.exceptionsr�pip._internal.models.indexrr�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__�	getLoggerrurj�
_operators�keysr�r9r*r0r?rrgrmror~�boolrr�r�r�rr�r�r�r�r�rxr+r)�<module>r�st�����	�	�F�F�F�0�N�6�6�5�*�,�8�<�9�7�9�0�)���
��	�	�8�	$��� � �%�%�'�	�	"��	"��c�8�C�=�&8� 9�	"�B�8�C�=�B�S��X�B�/��/�#�c�(�/�{�/�24$��4$��x��}�c�3�s�8�/K�)L�4$�n�c��d��8�C��C��2��
>�#�
>�2B�
>�*<@��"&��*.�37���#(�BF������1�3�6�7�8�����	�
���T�#�Y�'�
��4��T�#�Y��/�0������!���d�3��c�4��9�n�(=�#=�>�?����@�3��4��&�S������
��DW8�c�W8���
�W8�BR�W8�x<@�"�"&��*.�37��!%��BF�"�

�"���s�$6�6�7�8�"����	"�
�"��T�#�Y�'�
"��4��T�#�Y��/�0�"��"��#��"��"��d�3��c�4��9�n�(=�#=�>�?�"��"�N04��!%��#��#��+�,�#��#����	#�
�#��
#�P�!%��BF�%�!�%��%����%��	%�
�d�3��c�4��9�n�(=�#=�>�?�%��
%�P�
��(����$�"4��9K��4�
���s�O���r+