Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pip/_internal/req/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pip/_internal/req/__pycache__/constructors.cpython-312.pyc

�

4Μg�G���dZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZddlmZddlmZmZddlmZddlmZdd	lmZmZdd
lmZddlmZddlm Z dd
l!m"Z"ddl#m$Z$ddl%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,m-Z-gd�Z.ej^e0�Z1ejdjg�Z4de5de
e5ee5ffd�Z6dee5dee5fd�Z7dedee5defd�Z8de5de
ee5e5ee5ffd�Z9de5ddfd�Z:de5de5fd �Z;ed!�"�Gd#�d$��Z<de5de<fd%�Z=	dBdd&ddd&d&d&dd'�de5d(eee"e5fd)ee>d*e>d+ee
e5d,ee	e5e
e5fd-e>d.e>d/e>d0ee	e5ee5e
e5ffde"fd1�Z?d2e5de>fd3�Z@de5d2e5dee5fd4�ZAd2e5d5ee5de<fd6�ZB	dBdd&ddd&dd&dd7�d2e5d(eee5e"fd)ee>d*e>d+ee
e5d,ee	e5e
e5fd-e>d5ee5d.e>d0ee	e5ee5e
e5ffde"fd8�ZC				dCd9e5d(ee"d*e>d)ee>d.e>de"fd:�ZD				dDd;e d*e>d)ee>d.e>d0ee	e5ee5e
e5ffde"fd<�ZEd=ed>e"de"fd?�ZFd>e"de"fd@�ZGd>e"dee5de"fdA�ZHy)Ea~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)�	dataclass)�
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    �I/usr/local/lib/python3.12/site-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_extrasr18s(����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)r2r3r%�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��c�U�6�(�4�&�1�2�2r,�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!d|�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�isdirrr0�
startswithr�egg_fragmentrr(r/r�is_vcsr<�all_schemesr)rA�url�
url_no_extrasr(�package_name�version_control�link�backendss        r*rrWsY���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���5�l�^�D=�
=�
�	
���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)rG��.0�lines  r*�	<genexpr>z2check_first_requirement_in_file.<locals>.<genexpr>�s&����
�4���D�O�O�C�0�
�4�s�!c3�<K�|]}|j����y�w�N)�striprXs  r*r[z2check_first_requirement_in_file.<locals>.<genexpr>�s����4�!�$�����!�s�z #N�\���r8)�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�?�:���D�!��!
;�	:��
;�	:�	:�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)rEr�existsrgr�logger�debug)r2�msgs  r*�deduce_helpful_msgrm�s����7�7�>�>�#�����.�/�/�
"�C�
�'��,�	���u�1�
2�	
���J���D����=�s�C��J�D�s�?�A"�!A"T)�frozenc�N�eZdZUeeed<eeed<eeed<ee	ed<y)�RequirementParts�requirementrO�markersr(N)
�__name__�
__module__�__qualname__rr
�__annotations__rrrr:�r,r*rprp�s,���+�&�&�
�4�.��
�f�
����H�r,rpc��t|�\}}}|�
	t|�}nd}t	|�}t||d|�S#t$r}td|�d|����d}~wwxYw)N�Invalid requirement: �: )rrrrrrp)rA�namerK�extras_overrider2�excrOs       r*�parse_req_from_editabler~�sw��!/��!=��D�#����	M�)8��)>�C�����9�D��C��t�_�=�=��"�	M�#�&;�D�8�2�c�U�$K�L�L��	M�s�:�	A�A�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~rrqrOr()rAr�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)rEr�sep�altseprG)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�rErrFrrrr�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==�textr c����s|S|�d��d�S)Nz (from �)rw)r�r�s �r*�with_sourcez(parse_req_from_line.<locals>.with_sourcecs�����K���w�{�m�1�-�-r,�
req_as_stringc�"���	t��S#t$rv}tjj�vrd}|t��z
}n!d�vrt
�fd�tD��sd}nd}�d��d|���}|r|d|��z
}t|��d}~wwxYw)	NzIt looks like a path.�=c3�&�K�|]}|�v���
y�wr]rw)rY�opr�s  �r*r[zAparse_req_from_line.<locals>._parse_req_string.<locals>.<genexpr>os�����2�.7���m�#�i�s�z,= is not a valid operator. Did you mean == ?r8ryrzz
Hint: )	rrrErr�rm�any�	operatorsr)r�r}�add_msgrlr�s`   �r*�_parse_req_stringz.parse_req_from_line.<locals>._parse_req_stringhs����	)�"�=�1�1��!�
	)��w�w�{�{�m�+�1���-�m�<�<���
�%�c�2�.7�2�/�I����� 5�m�5F�b���N�O�C����'��+�+��#�C�(�(��
	)�s�
�	B�A1B	�	B)rr�r^rrEr�normpath�abspathrr+r��schemer$�searchrKr�is_wheelrrQr{�versionrHr1r:r
rp)r{r��
marker_sep�markers_as_stringrrr�rrO�extras_as_string�prK�wheelr(r�r2r�s `             @r*�parse_req_from_liner�3s����
�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.
    )
rOrrrr�r�r�r�r�r(r�)r�rrqrOrrr()r{r�rr�r�r�r�r�r�r�r�s           r*rr�sS��&
 ��k�2�E��
����
�Z�Z��
�
���%�!�'���|�|�#�
�
r,�
req_stringc�Z�	t|�}tjt
jg}|jrB|r@|jr4|jj|vrtd|j�d|�d���t|||||��S#t$r}td|�d|����d}~wwxYw)NryrzzZPackages installed from PyPI cannot depend on packages which are not also hosted on PyPI.
z depends on � )r�rr�)rrrr�file_storage_domainrrKrO�netlocr{r)r�r�r�rr�r2r}�domains_not_alloweds        r*�install_req_from_req_stringr��s���O��j�)��
	
� � ��$�$���
	�����O�O��O�O�"�"�&9�9� �
3�����|�C�5��
3�
�	
������#����)�O��"7�
�~�R��u� M�N�N��O�s�B�	B*�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_editablerrqr�r�r�options�getr�)r�r�rr�r�r2s      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)r2r�r�rOrrrr�r�r�r�r�)rr2r�r�rrrr�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)r2r�r�rOrrrr�r�r�r�r(r�r�r�)rr2r@r/r�rOrrrr�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(r2r@)r�r(�results   r*�install_req_extend_extrasr�!sg���Y�Y�t�_�F�+�d�k�k�+�F�+�F�M��8�8��	 ����&�-�-�8��J�
�M���J�
�Mr,r])NFNF)FNFN)I�__doc__r��loggingrEr$�dataclassesr�typingrrrrrr	r
�pip._vendor.packaging.markersr�"pip._vendor.packaging.requirementsrr
� 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__�	getLoggerrsrj�
_operators�keysr�r:r+r1r@rrgrmrpr~�boolrr�r�r�rr�r�r�r�r�rwr,r*�<module>r�s������	�	�!�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�3��3�#�c�(�3�{�3�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������
��DL8�c�L8���
�L8�BR�L8�b<@�"�"&��*.�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,

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists